Overview
TheWebAuthn service manages FIDO2/WebAuthn passkey credentials for end-users. Generate registration options, verify attestation responses, list credentials, and delete them.
Register Options
Generate WebAuthn registration options for a principal. Returns aPublicKeyCredentialCreationOptions-compatible struct to send to the browser.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
principalID | string | Yes | The ID of the principal to register a passkey for. |
Response (WebAuthnRegisterOptions)
| Field | Type | Description |
|---|---|---|
Challenge | string | Base64url-encoded challenge for the registration. |
RP | RelyingParty | Relying party information (Name, ID). |
User | WebAuthnUser | User entity (ID, Name, DisplayName). |
PubKeyCredParams | []PubKeyCredParam | Supported public key algorithms. |
Timeout | int | Timeout in milliseconds. |
Attestation | string | Attestation conveyance preference. |
ExcludeCredentials | []CredentialDescriptor | Existing credentials to prevent re-registration. |
Register Verify
Verify a WebAuthn registration response. On success, the credential is stored and associated with the principal.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
PrincipalID | string | Yes | The principal ID this credential belongs to. |
Credential | map[string]any | Yes | The WebAuthn attestation response from the browser. |
Response (WebAuthnCredential)
| Field | Type | Description |
|---|---|---|
CredentialID | string | Unique credential identifier. |
PublicKey | string | Base64url-encoded public key. |
SignCount | int | The signature counter value. |
CreatedAt | string | ISO 8601 timestamp when the credential was registered. |
AAGUID | string | The authenticator attestation GUID. |
LastUsedAt | *string | ISO 8601 timestamp of last authentication, or nil. |
List Credentials
List all WebAuthn credentials registered for a principal.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
principalID | string | Yes | The principal ID to list credentials for. |
Response
Returns[]WebAuthnCredential. See above for field descriptions.
Delete Credential
Delete a WebAuthn credential by its ID.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
credentialID | string | Yes | The credential ID to delete. |
nil on success.