Documentation ¶
Overview ¶
Package user handle the database users.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUserNotFound happens when the user if not found in the database. ErrUserNotFound = errors.New("user not found") // ErrCredentialNotFound happens when the credential if not found in the database. ErrCredentialNotFound = errors.New("credential not found") )
Functions ¶
This section is empty.
Types ¶
type Repository ¶
type Repository interface { GetOrCreateByName(ctx context.Context, name string) (*User, error) GetByName(ctx context.Context, name string) (*User, error) Get(ctx context.Context, id []byte) (*User, error) Create(ctx context.Context, name string, displayName string) (*User, error) AddCredential(ctx context.Context, id []byte, credential *webauthn.Credential) error UpdateCredential(ctx context.Context, credential *webauthn.Credential) error RemoveCredential(ctx context.Context, id []byte, credentialID []byte) error }
Repository defines the user methods.
func NewRepository ¶
func NewRepository(db *sql.DB) Repository
NewRepository wraps around a SQL database to execute the counter methods.
type User ¶
type User struct { ID []byte Name string DisplayName string Credentials []webauthn.Credential }
User stores WebAuthn related information.
func (*User) ExcludeCredentialDescriptorList ¶
func (u *User) ExcludeCredentialDescriptorList() []protocol.CredentialDescriptor
ExcludeCredentialDescriptorList provides a list of credentials already registered. This is an extension to WebAuthn.
Specification: §5.4.3. User Account Parameters for Credential Generation (https://w3c.github.io/webauthn/#sctn-op-make-cred)
func (*User) WebAuthnCredentials ¶
func (u *User) WebAuthnCredentials() []webauthn.Credential
WebAuthnCredentials provides the list of Credential objects owned by the user.
func (*User) WebAuthnDisplayName ¶
WebAuthnDisplayName provides the name attribute of the user account during registration and is a human-palatable name for the user account, intended only for display. For example, "Alex Müller" or "田中倫". The Relying Party SHOULD let the user choose this, and SHOULD NOT restrict the choice more than necessary.
Specification: §5.4.3. User Account Parameters for Credential Generation (https://www.w3.org/TR/webauthn/#dom-publickeycredentialuserentity-displayname)
func (*User) WebAuthnID ¶
WebAuthnID provides the user handle of the user account. A user handle is an opaque byte sequence with a maximum size of 64 bytes, and is not meant to be displayed to the user.
To ensure secure operation, authentication and authorization decisions MUST be made on the basis of this id member, not the displayName nor name members. See Section 6.1 of [RFC8266].
It's recommended this value is completely random and uses the entire 64 bytes.
Specification: §5.4.3. User Account Parameters for Credential Generation (https://w3c.github.io/webauthn/#dom-publickeycredentialuserentity-id)
func (*User) WebAuthnIcon ¶
WebAuthnIcon is a deprecated option. Deprecated: this has been removed from the specification recommendation. Suggest a blank string.
func (*User) WebAuthnName ¶
WebAuthnName provides the name attribute of the user account during registration and is a human-palatable name for the user account, intended only for display. For example, "Alex Müller" or "田中倫". The Relying Party SHOULD let the user choose this, and SHOULD NOT restrict the choice more than necessary.
Specification: §5.4.3. User Account Parameters for Credential Generation (https://w3c.github.io/webauthn/#dictdef-publickeycredentialuserentity)