api

package
v0.0.0-...-fd5a099 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: MIT Imports: 19 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 UserSession = "user-session"
View Source
const UserSessionMaxAge = 30 // 30 seconds
View Source
const WebauthnSession = "webauthn-session"

Two sessions, one for webauthn registration/login, one for persisting login after webauthn is done

View Source
const WebauthnSessionMaxAge = 30 // 30 seconds

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 CreateBegin

func CreateBegin(w http.ResponseWriter, r *http.Request)

func CreateFinish

func CreateFinish(w http.ResponseWriter, r *http.Request)

func GenerateSecureKey

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

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

func Init

func Init()

func SignCSR

func SignCSR(w http.ResponseWriter, r *http.Request)

Types

type AuthKeyRequest

type AuthKeyRequest struct {
	AuthPublicKey string `json:"authPublicKey"`
}

type CSRRequest

type CSRRequest struct {
	CSR string `json:"CSR"`
}

type CertificateResponse

type CertificateResponse struct {
	Certificate string `json:"certificate"`
}

type Store

type Store struct {
	*sessions.CookieStore
}

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

func NewStore

func NewStore(keyPairs ...[]byte) (*Store, error)

NewStore returns a new session store.

func (*Store) GetWebauthnSession

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

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

func (*Store) SaveWebauthnSession

func (store *Store) SaveWebauthnSession(key string, data *webauthn.SessionData, r *http.Request, w http.ResponseWriter) error

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

func (*Store) Set

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

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

Jump to

Keyboard shortcuts

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