Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateSecureKey(n int) ([]byte, error)
- func NotFound(c *fiber.Ctx) error
- func ParseCredentialCreationResponse(ccr protocol.CredentialCreationResponse) (*protocol.ParsedCredentialCreationData, error)
- func ParseCredentialRequestResponse(car protocol.CredentialAssertionResponse) (*protocol.ParsedCredentialAssertionData, error)
- type LoginResponse
- type RegistrationResponse
- type SessionStore
- func (store *SessionStore) GetWebauthnSession(key string, r *http.Request) (webauthn.SessionData, error)
- func (store *SessionStore) SaveWebauthnSession(key string, data *webauthn.SessionData, r *http.Request, w http.ResponseWriter) ([]byte, error)
- func (store *SessionStore) Set(key string, value interface{}, r *http.Request, w http.ResponseWriter) error
- type WebAuthnHandler
- func (s *WebAuthnHandler) AddRoutes(f *fiber.App)
- func (s *WebAuthnHandler) BeginLogin(c *fiber.Ctx) error
- func (s *WebAuthnHandler) BeginRegistration(c *fiber.Ctx) error
- func (s *WebAuthnHandler) FinishLogin(c *fiber.Ctx) error
- func (s *WebAuthnHandler) FinishRegistration(c *fiber.Ctx) error
- func (s *WebAuthnHandler) ListCredentials(c *fiber.Ctx) error
- func (s *WebAuthnHandler) Logoff(c *fiber.Ctx) error
Constants ¶
const DefaultEncryptionKeyLength = 32
DefaultEncryptionKeyLength is the length of the generated encryption keys used for session management.
const WebauthnSession = "webauthn-session"
WebauthnSession is the name of the session cookie used to manage session- related information.
Variables ¶
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.
var ErrMarshal = errors.New("error unmarshaling data")
ErrMarshal is returned if unexpected data is present in a webauthn session.
Functions ¶
func GenerateSecureKey ¶
GenerateSecureKey reads and returns n bytes from the crypto/rand reader
func ParseCredentialCreationResponse ¶
func ParseCredentialCreationResponse(ccr protocol.CredentialCreationResponse) (*protocol.ParsedCredentialCreationData, error)
func ParseCredentialRequestResponse ¶
func ParseCredentialRequestResponse(car protocol.CredentialAssertionResponse) (*protocol.ParsedCredentialAssertionData, error)
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