2024-10-11 16:47:52 -04:00
|
|
|
package orm
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/go-webauthn/webauthn/protocol"
|
|
|
|
"github.com/go-webauthn/webauthn/protocol/webauthncose"
|
|
|
|
)
|
|
|
|
|
2024-10-12 12:52:20 -04:00
|
|
|
func NewCredentialCreationOptions(subject, address string, challenge protocol.URLEncodedBase64) *protocol.PublicKeyCredentialCreationOptions {
|
2024-10-11 16:47:52 -04:00
|
|
|
return &protocol.PublicKeyCredentialCreationOptions{
|
2024-10-12 12:52:20 -04:00
|
|
|
Challenge: challenge,
|
2024-10-11 16:47:52 -04:00
|
|
|
User: protocol.UserEntity{
|
|
|
|
DisplayName: subject,
|
|
|
|
ID: address,
|
|
|
|
},
|
|
|
|
Attestation: defaultAttestation(),
|
|
|
|
AuthenticatorSelection: defaultAuthenticatorSelection(),
|
|
|
|
Parameters: defaultCredentialParameters(),
|
2024-10-12 12:52:20 -04:00
|
|
|
}
|
2024-10-11 16:47:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func buildUserEntity(userID string) protocol.UserEntity {
|
|
|
|
return protocol.UserEntity{
|
|
|
|
ID: userID,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func defaultAttestation() protocol.ConveyancePreference {
|
|
|
|
return protocol.PreferDirectAttestation
|
|
|
|
}
|
|
|
|
|
|
|
|
func defaultAuthenticatorSelection() protocol.AuthenticatorSelection {
|
|
|
|
return protocol.AuthenticatorSelection{
|
|
|
|
AuthenticatorAttachment: "platform",
|
|
|
|
ResidentKey: protocol.ResidentKeyRequirementPreferred,
|
|
|
|
UserVerification: "preferred",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func defaultCredentialParameters() []protocol.CredentialParameter {
|
|
|
|
return []protocol.CredentialParameter{
|
|
|
|
{
|
|
|
|
Type: "public-key",
|
|
|
|
Algorithm: webauthncose.AlgES256,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: "public-key",
|
|
|
|
Algorithm: webauthncose.AlgES256K,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: "public-key",
|
|
|
|
Algorithm: webauthncose.AlgEdDSA,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|