Documentation ¶
Index ¶
- Variables
- func App() *buffalo.App
- func AuthenticateNonce(next buffalo.Handler) buffalo.Handler
- func AuthenticateToken(options Options) buffalo.MiddlewareFunc
- func GenerateToken(c buffalo.Context) error
- func SampleHandler(c buffalo.Context) error
- type Error
- type GenerateTokenPayload
- type GenerateTokenResult
- type Options
- type TokenPayload
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTokenInvalid is returned when the token provided is invalid ErrTokenInvalid = errors.New("token invalid") // ErrNoToken is returned if no token is supplied in the request. ErrNoToken = errors.New("token not found in request") // FOOTER is the footer used in the Paseto token FOOTER = envy.Get("PASETO_FOOTER", "LicenseServer") )
Functions ¶
func AuthenticateNonce ¶ added in v0.2.0
AuthenticateNonce checks if the nonce provided in the request matches the stored nonce. WARNING: Deletes token if the nonces mismatch.
func AuthenticateToken ¶ added in v0.2.0
func AuthenticateToken(options Options) buffalo.MiddlewareFunc
AuthenticateToken validates a PASETO token passed in the Authorization HTTP header with type 'Bearer'. Token jti needs to be stored as AuthToken in the db to be valid.
func GenerateToken ¶
GenerateToken generates a new token for the user
func SampleHandler ¶
SampleHandler is a dummy handler to test API authentication.
Types ¶
type Error ¶ added in v0.2.0
type Error struct {
Error string `json:"error"`
}
Error is a generic error struct with an error message.
type GenerateTokenPayload ¶ added in v0.2.0
type GenerateTokenPayload struct { LicenseID uuid.UUID `json:"license_id"` UserID uuid.UUID `json:"user_id"` MachineID uuid.UUID `json:"machine_id"` }
GenerateTokenPayload represents the expected json payload for token generation requests.
type GenerateTokenResult ¶ added in v0.2.0
type GenerateTokenResult struct { // Token is a Paseto token bound to a license allowing access to an application. Token string `json:"token"` // Nonce is the initial nonce for the new api token. Nonce int `json:"nonce"` }
GenerateTokenResult represents the json returned from the token generation.
type Options ¶
type Options struct {
Key []byte
}
Options provide a way to pass arguments to the paseto middleware.
type TokenPayload ¶ added in v0.2.0
type TokenPayload struct { // LicenseID is the license this token is bound to. LicenseID uuid.UUID `json:"license_id"` }
TokenPayload represents the encrypted json data included in each api token.