handlers

package
v0.0.0-...-3ebf473 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultEncryptionKeyLength = 32

DefaultEncryptionKeyLength is the length of the generated encryption keys used for session management.

View Source
const WebauthnSession = "webauthn-session"

WebauthnSession is the name of the session cookie used to manage session- related information.

Variables

View Source
var ErrInsufficientBytesRead = errors.New("insufficient bytes read")

ErrInsufficientBytesRead is returned in the rare case that an unexpected number of bytes are returned from the crypto/rand reader when creating session cookie encryption keys.

View Source
var ErrMarshal = errors.New("error unmarshaling data")

ErrMarshal is returned if unexpected data is present in a webauthn session.

Functions

func GenerateSecureKey

func GenerateSecureKey(n int) ([]byte, error)

GenerateSecureKey reads and returns n bytes from the crypto/rand reader

func NotFound

func NotFound(c *fiber.Ctx) error

NotFound returns custom 404 page

func ParseCredentialRequestResponse

Parse the credential request response into a format that is either required by the specification or makes the assertion verification steps easier to complete. This takes an io.Reader that contains the assertion response data in a raw, mostly base64 encoded format, and parses the data into manageable structures

Types

type LoginResponse

type LoginResponse struct {
	Response protocol.CredentialAssertionResponse `json:"response"`
	Session  string                               `json:"session"`
}

type RegistrationResponse

type RegistrationResponse struct {
	Response protocol.CredentialCreationResponse `json:"response"`
	Session  string                              `json:"session"`
}

type SessionStore

type SessionStore struct {
	*sessions.CookieStore
}

SessionStore is a wrapper around sessions.CookieStore which provides some helper methods related to webauthn operations.

func NewSessionStore

func NewSessionStore(keyPairs ...[]byte) (*SessionStore, error)

NewSessionStore returns a new session store.

func (*SessionStore) GetWebauthnSession

func (store *SessionStore) GetWebauthnSession(key string, r *http.Request) (webauthn.SessionData, error)

GetWebauthnSession unmarshals and returns the webauthn session information from the session cookie.

func (*SessionStore) SaveWebauthnSession

func (store *SessionStore) SaveWebauthnSession(key string, data *webauthn.SessionData, r *http.Request, w http.ResponseWriter) ([]byte, error)

SaveWebauthnSession marhsals and saves the webauthn data to the provided key given the request and responsewriter

func (*SessionStore) Set

func (store *SessionStore) Set(key string, value interface{}, r *http.Request, w http.ResponseWriter) error

Set stores a value to the session with the provided key.

type WebAuthnHandler

type WebAuthnHandler struct {
	WebAuthn     *webauthn.WebAuthn
	Operations   *operations.Manager
	SessionStore *session.Store
}

func NewWebAuthnHandler

func NewWebAuthnHandler(f *fiber.App, o *operations.Manager, cfg *yaml.YAML) *WebAuthnHandler

func (*WebAuthnHandler) AddRoutes

func (s *WebAuthnHandler) AddRoutes(f *fiber.App)

func (*WebAuthnHandler) BeginLogin

func (s *WebAuthnHandler) BeginLogin(c *fiber.Ctx) error

func (*WebAuthnHandler) BeginRegistration

func (s *WebAuthnHandler) BeginRegistration(c *fiber.Ctx) error

func (*WebAuthnHandler) FinishLogin

func (s *WebAuthnHandler) FinishLogin(c *fiber.Ctx) error

func (*WebAuthnHandler) FinishRegistration

func (s *WebAuthnHandler) FinishRegistration(c *fiber.Ctx) error

func (*WebAuthnHandler) ListCredentials

func (s *WebAuthnHandler) ListCredentials(c *fiber.Ctx) error

func (*WebAuthnHandler) Logoff

func (s *WebAuthnHandler) Logoff(c *fiber.Ctx) error

Jump to

Keyboard shortcuts

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