Documentation ¶
Index ¶
Constants ¶
View Source
const ContextAttrSession = 0
ContextAttrSession is the key associated with the current session attached to an authenticated request as a context value.
View Source
const CookieAttrSession = "session"
View Source
const SessionTimeout = 30 * time.Minute
Variables ¶
View Source
var ErrBadRequest = errors.New("bad request")
View Source
var ErrExpired = errors.New("expired")
Functions ¶
func Authenticate ¶
func Authenticate(auth Authenticator) http.HandlerFunc
Authenticate accepts POST requests with a valid login request. Reply codes and conditions as follows.
405 Method not allowed
- If the method is not "POST"
400 Bad request
- If the request didn't contain a valid credentials model
401 Unauthorized
- If the credentials could not be authenticated
200 OK
- If the credentials were authenticated
If successful a session cookie named "session" is attached to the reply.
Types ¶
type Authenticator ¶
type Authenticator interface { // Authenticate a session based on the payload available in r. // On success return a session and the session timeout. Authenticate(io.ReadCloser) (*http.Cookie, error) }
type Authorizer ¶
type PasetoSessionCodec ¶
type PasetoSessionCodec struct {
// contains filtered or unexported fields
}
PasetoSessionCodec provides PASETO security tokens
func NewPasetoSessionCodec ¶
func NewPasetoSessionCodec(key []byte) *PasetoSessionCodec
NewPasetoSessionCodec creates a new PasetoSessionCodec using key
Click to show internal directories.
Click to hide internal directories.