Documentation ¶
Index ¶
Constants ¶
View Source
const (
// SessionCookieName is the name of the session cookie.
SessionCookieName = "session"
)
Variables ¶
This section is empty.
Functions ¶
func CSRFTokenMiddleware ¶
func CSRFTokenMiddleware() negroni.HandlerFunc
CSRFTokenMiddleware enforces a CSRF token in the ?token= part of the URL.
func GenerateCSRFToken ¶
func GenerateCSRFToken() string
GenerateCSRFToken generates a new csrf token.
func GenerateSid ¶
GenerateSid generates a new session id.
The session id gets prefixed with the user id, so sessions can be invalidated for an user in case an account gets blocked or deleted.
func MustBeAnonymousMiddleware ¶
func MustBeAnonymousMiddleware() negroni.HandlerFunc
MustBeAnonymousMiddleware only lets the request proceed if the account is not logged in.
func MustBeLoggedInMiddleware ¶
func MustBeLoggedInMiddleware() negroni.HandlerFunc
MustBeLoggedInMiddleware only lets the request proceed if an account is logged in.
Types ¶
type Middleware ¶
type Middleware struct { SecureCookie bool CookieName string // contains filtered or unexported fields }
Middleware is the session middleware.
func NewMiddleware ¶
func NewMiddleware(logger logrus.FieldLogger, store keyvalue.Store) *Middleware
func (*Middleware) DeleteSession ¶
func (m *Middleware) DeleteSession(w http.ResponseWriter, r *http.Request)
DeleteSession removes the current session.
func (*Middleware) RegenerateSession ¶
func (m *Middleware) RegenerateSession(w http.ResponseWriter, r *http.Request, id uuid.UUID) error
RegenerateSession invalidates the previous session and creates a new one.
func (*Middleware) ServeHTTP ¶
func (m *Middleware) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
Click to show internal directories.
Click to hide internal directories.