Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ErrorHandler ¶
type ErrorHandler func(w http.ResponseWriter, r *http.Request, err error)
ErrorHandler receives an error and can use that to return an error to the HTTP Request
type FooterKey ¶
type FooterKey string
FooterKey defines the key to access the decrypted paseto footer
type Option ¶
type Option func(*PasetoMiddleware)
Option is a function for setting options within the PasetoMiddleware struct
func CredentialsOptional ¶
CredentialsOptional allows the user to not be authenticated on a path with this middleware.
func Decryptor ¶
func Decryptor(d TokenDecryptor) Option
Decryptor decrypts the Paseto token that was retrieved through Extractor
func Error ¶
func Error(eh ErrorHandler) Option
Error handles any errors that occur in the middleware process
func Extractor ¶
func Extractor(e TokenExtractor) Option
Extractor extracts the Paseto token from the request.
func FooterProperty ¶
FooterProperty defines where the unencrypted Paseto footer should be stored in the context of the request.
func TokenProperty ¶
TokenProperty defines where the unencrypted Paseto token should be stored in the context of the request.
type PasetoMiddleware ¶
type PasetoMiddleware struct { Extractor TokenExtractor Decryptor TokenDecryptor // The name of the property where the token will be stored // Default value: token TokenProperty TokenKey // Default value: paseto footer FooterProperty FooterKey ErrorHandler ErrorHandler CredentialsOptional bool Debug bool }
PasetoMiddleware struct for specifying all the configuration options for this middleware
func New ¶
func New(options ...Option) (*PasetoMiddleware, error)
New constructs a PasetoMiddleware structure with the supplied options
func (*PasetoMiddleware) Next ¶
func (p *PasetoMiddleware) Next(handler http.Handler) http.HandlerFunc
Next goes through the middleware and passes itself onto another http.Handler
func (*PasetoMiddleware) NextFunc ¶
func (p *PasetoMiddleware) NextFunc(handler http.HandlerFunc) http.HandlerFunc
NextFunc goes through the middleware and passes itself onto another http.HandlerFunc
type TokenDecryptor ¶
TokenDecryptor decrypts the encrypted paseto token and puts it in the token and footer pointers.
type TokenExtractor ¶
TokenExtractor extracts the token from a request and returns that or an error