Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(webauthn): expose cred params functions #286

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 68 additions & 2 deletions webauthn/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (webauthn *WebAuthn) BeginRegistration(user User, opts ...RegistrationOptio
},
}

credentialParams := defaultRegistrationCredentialParameters()
credentialParams := CredentialParametersDefault()

creation = &protocol.CredentialCreation{
Response: protocol.PublicKeyCredentialCreationOptions{
Expand Down Expand Up @@ -234,7 +234,8 @@ func (webauthn *WebAuthn) CreateCredential(user User, session SessionData, parse
return NewCredential(clientDataHash, parsedResponse)
}

func defaultRegistrationCredentialParameters() []protocol.CredentialParameter {
// CredentialParametersDefault is the default protocol.CredentialParameter list.
func CredentialParametersDefault() []protocol.CredentialParameter {
return []protocol.CredentialParameter{
{
Type: protocol.PublicKeyCredentialType,
Expand Down Expand Up @@ -278,3 +279,68 @@ func defaultRegistrationCredentialParameters() []protocol.CredentialParameter {
},
}
}

// CredentialParametersRecommendedL3 is explicitly the Level 3 recommended protocol.CredentialParameter list.
func CredentialParametersRecommendedL3() []protocol.CredentialParameter {
return []protocol.CredentialParameter{
{
Type: protocol.PublicKeyCredentialType,
Algorithm: webauthncose.AlgEdDSA,
},
{
Type: protocol.PublicKeyCredentialType,
Algorithm: webauthncose.AlgES256,
},
{
Type: protocol.PublicKeyCredentialType,
Algorithm: webauthncose.AlgRS256,
},
}
}

// CredentialParametersExtendedL3 is the Level 3 recommended protocol.CredentialParameter list with all of the other
// parameters supported by the library.
func CredentialParametersExtendedL3() []protocol.CredentialParameter {
return []protocol.CredentialParameter{
{
Type: protocol.PublicKeyCredentialType,
Algorithm: webauthncose.AlgEdDSA,
},
{
Type: protocol.PublicKeyCredentialType,
Algorithm: webauthncose.AlgES256,
},
{
Type: protocol.PublicKeyCredentialType,
Algorithm: webauthncose.AlgES384,
},
{
Type: protocol.PublicKeyCredentialType,
Algorithm: webauthncose.AlgES512,
},
{
Type: protocol.PublicKeyCredentialType,
Algorithm: webauthncose.AlgRS256,
},
{
Type: protocol.PublicKeyCredentialType,
Algorithm: webauthncose.AlgRS384,
},
{
Type: protocol.PublicKeyCredentialType,
Algorithm: webauthncose.AlgRS512,
},
{
Type: protocol.PublicKeyCredentialType,
Algorithm: webauthncose.AlgPS256,
},
{
Type: protocol.PublicKeyCredentialType,
Algorithm: webauthncose.AlgPS384,
},
{
Type: protocol.PublicKeyCredentialType,
Algorithm: webauthncose.AlgPS512,
},
}
}
Loading