Documentation
¶
Overview ¶
Package user handle the database users.
Index ¶
- Variables
- type Repository
- func (r *Repository) AddCredential(ctx context.Context, id []byte, credential *webauthn.Credential) error
- func (r *Repository) Create(ctx context.Context, name string, displayName string) (*User, error)
- func (r *Repository) Get(ctx context.Context, id []byte) (*User, error)
- func (r *Repository) GetByName(ctx context.Context, name string) (*User, error)
- func (r *Repository) GetOrCreateByName(ctx context.Context, name string) (*User, error)
- func (r *Repository) RemoveCredential(ctx context.Context, id []byte, credentialID []byte) error
- func (r *Repository) UpdateCredential(ctx context.Context, credential *webauthn.Credential) error
- type User
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 ¶
Repository wraps around a SQL database to execute the webauthn methods.
func NewRepository ¶
func NewRepository(db *sql.DB) *Repository
NewRepository instanciates a new user repository.
func (*Repository) AddCredential ¶
func (r *Repository) AddCredential( ctx context.Context, id []byte, credential *webauthn.Credential, ) error
AddCredential to a user from the database.
func (*Repository) GetOrCreateByName ¶
GetOrCreateByName a user from the databse.
func (*Repository) RemoveCredential ¶
RemoveCredential of a user from the database.
func (*Repository) UpdateCredential ¶
func (r *Repository) UpdateCredential(ctx context.Context, credential *webauthn.Credential) error
UpdateCredential of a user from the database.
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)