top

Package secure manages client side session tokens for stateless web applications.

Tokens are stored as an http cookie. An encrypted connection (https) is required.

Call 'Configure()' once to provide the information for the package to operate, including the type of the authentication data that will be used. The actual configuration parameters are stored in a 'Config' type struct, which can be synced with an external database, through the 'DB' interface.

Once configured, call 'Authentication()' to retrieve the data from the token. It will redirect to a login page if no valid token is present (unless the 'optional' argument was 'true'). 'LogIn()' creates a new token, stores the provided data in it, and redirects back to the page that required the authentication. 'Update()' updates the authentication data in the current token. 'LogOut()' deletes the token cookie.

You'll probably want to wrap 'Authentication()' in a function that converts the 'interface{}' result to the type that you use for the token data.

Imported by 10 package(s)

  1. github.com/wscherphof/essix/app/routes
  2. github.com/wscherphof/essix/messages
  3. github.com/wscherphof/essix/ratelimit
  4. github.com/wscherphof/essix/routes
  5. github.com/wscherphof/essix/routes/account
  6. github.com/wscherphof/essix/secure
  7. github.com/wscherphof/essix/server
  8. github.com/wscherphof/essix/template
  9. github.com/wscherphof/expeertise/ratelimit
  10. github.com/wscherphof/expeertise/secure

Imports 2 package(s)

  1. github.com/gorilla/securecookie
  2. github.com/gorilla/sessions