user

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package user handle the database users.

Index

Constants

This section is empty.

Variables

View Source
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

func (u *User) WebAuthnDisplayName() string

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

func (u *User) WebAuthnID() []byte

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

func (u *User) WebAuthnIcon() string

WebAuthnIcon is a deprecated option. Deprecated: this has been removed from the specification recommendation. Suggest a blank string.

func (*User) WebAuthnName

func (u *User) WebAuthnName() string

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL