Documentation ¶
Index ¶
- Constants
- Variables
- func CreateRestrictedToken(key string, identity string) (string, error)
- func CreateToken(key string, identity string) (string, error)
- func New(h Handler) func(events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
- type Error
- type Handler
- type Request
- type Response
Constants ¶
const ( AuthHeader = "Authorization" AuthType = "Targetblank" )
Expected authorization header configuration.
const ( ErrPageNotFound = "page not found" ErrInvalidEmail = "invalid email address" ErrInvalidPassword = "password is too short" ErrGeneric = "something went wrong" )
Common client error messages.
Variables ¶
var ( // ErrRestrictedToken is returned when authenticating restricted tokens. ErrRestrictedToken = fmt.Errorf("restricted token") )
Functions ¶
func CreateRestrictedToken ¶
CreateRestrictedToken creates a new authentication token that expires.
func CreateToken ¶
CreateToken creates a new authentication token that never expires.
func New ¶
func New(h Handler) func(events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
New creates a lambda handler from a Handler and a Config.
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error adds a status code to the error type.
func InternalErr ¶
InternalErr creates a new function error with an encrypted message.
func ObfuscatedAuthErr ¶
func ObfuscatedAuthErr() *Error
ObfuscatedAuthErr creates a 404 status function error. Should be used to hide the existence of pages.
type Request ¶
type Request events.APIGatewayProxyRequest
Request replaces the api gateway request event.
func (*Request) Authenticate ¶
Authenticate validates the token in the request. Returns time at which token was issued and/or an authentication error. Returns ErrRestrictedToken if token is restricted.
type Response ¶
type Response events.APIGatewayProxyResponse
Response replaces the api gateway response event.
func (*Response) ContentType ¶
ContentType adds the content-type header to the request.