WebAuthn internals (goauth/webauthn)
The passkey provider delegates cryptography to github.com/izetmolla/goauth/webauthn — standard library only.
Package structure
| File | Responsibility |
|---|---|
encoding.go | Base64url, CredentialJSON types |
cbor.go | Minimal CBOR decoder (maps, byte strings) |
cose.go | COSE EC2 P-256 key parse, ES256 verify |
authdata.go | Authenticator data layout |
rp.go | RP, options builders, VerifyRegistration, VerifyLogin |
Registration verification
- Parse
clientDataJSON— type must bewebauthn.create - Challenge must match server-issued challenge (from verification token)
- Origin must equal
RP.Origin - Decode
attestationObject(CBOR) →authDatabytes - Parse attested credential data → credential ID + COSE public key
- Verify RP ID hash =
SHA256(rp.id) - Store credential (attestation format not validated beyond
none)
Login verification
clientDataJSON.type=webauthn.get- Challenge + origin checks
- Load stored COSE key
- Verify signature over
authenticatorData || SHA256(clientDataJSON) - Reject if
signCountdid not increase (when both counters non-zero)
RP configuration
rp := &webauthn.RP{
ID: "app.example.com",
Name: "My App",
Origin: "https://app.example.com",
}
opts := rp.LoginOptionsForCredentials(challenge, allowCredentialIDs)
cred, err := rp.VerifyLogin(credentialJSON, challengeBytes, storedCredential)
Extending
To support additional algorithms (e.g. EdDSA) or packed attestation, extend cose.go and VerifyRegistration — keep changes inside webauthn/ to preserve the stdlib-only core guarantee.
Testing
go test ./webauthn/...
Add golden-vector tests with real browser-captured assertions for regression safety.