webauthn

package
v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package webauthn is a provider package offering Passkey login functionality

Index

Constants

View Source
const (
	ProviderName = "WEBAUTHN"
)

Variables

View Source
var (
	// ErrUserNotFound is returned when the user couldn't be found
	ErrUserNotFound = errors.New("user not found")

	// ErrSessionNotFound is returned when the session couldn't be found
	ErrSessionNotFound = errors.New("session not found")
)
View Source
var Sessions = map[string]*webauthn.SessionData{}
View Source
var Users = map[string]*User{}

Functions

func NewWithConfig

func NewWithConfig(config ProviderConfig) *webauthn.WebAuthn

NewWithConfig returns a configured Webauthn Provider

Types

type ProviderConfig

type ProviderConfig struct {
	// Enabled is the provider enabled
	Enabled bool `json:"enabled" koanf:"enabled" default:"true"`
	// DisplayName is the site display name
	DisplayName string `json:"displayName" koanf:"displayName" jsonschema:"required" default:"Datum"`
	// RelyingPartyID is the relying party identifier
	// set to localhost for development, no port
	RelyingPartyID string `json:"relyingPartyId" koanf:"relyingPartyId" jsonschema:"required" default:"localhost"`
	// RequestOrigin the origin domain for authentication requests
	// include the scheme and port
	RequestOrigin string `json:"requestOrigin" koanf:"requestOrigin" jsonschema:"required"  default:"http://localhost:3001"`
	// MaxDevices is the maximum number of devices that can be associated with a user
	MaxDevices int `json:"maxDevices" koanf:"maxDevices" default:"10"`
	// EnforceTimeout at the Relying Party / Server. This means if enabled and the user takes too long that even if the browser does not
	// enforce a timeout, the server will
	EnforceTimeout bool `json:"enforceTimeout" koanf:"enforceTimeout" default:"true"`
	// Timeout is the timeout in seconds
	Timeout time.Duration `json:"timeout" koanf:"timeout" default:"60s"`
	// Debug enables debug mode
	Debug bool `json:"debug" koanf:"debug" default:"false"`
}

ProviderConfig represents the configuration settings for a Webauthn Provider

type User

type User struct {
	ID                  string
	FirstName           string
	LastName            string
	DisplayName         string
	Name                string
	Email               string
	WebauthnCredentials []webauthn.Credential `json:"-"`
}

func (*User) CredentialExcludeList

func (u *User) CredentialExcludeList() []protocol.CredentialDescriptor

CredentialExcludeList returns a list of credentials to exclude from the webauthn credential list

func (*User) WebAuthnCredentials

func (u *User) WebAuthnCredentials() []webauthn.Credential

WebAuthnCredentials is the user's webauthn credentials

func (*User) WebAuthnDisplayName

func (u *User) WebAuthnDisplayName() string

WebAuthnDisplayName is the user's webauthn display name

func (*User) WebAuthnID

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

WebAuthnID is the user's webauthn ID

func (*User) WebAuthnIcon

func (u *User) WebAuthnIcon() string

WebAuthnIcon is the user's webauthn icon

func (*User) WebAuthnName

func (u *User) WebAuthnName() string

WebAuthnName is the user's webauthn name

Jump to

Keyboard shortcuts

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