Openmaize v0.11.0 Openmaize.Authenticate

Plug to authenticate users, using Json Web Tokens.

For more information about Json Web Tokens, see the documentation for the Openmaize.Token module.

It is important to note that this module only checks the identity of the user. For authorization / access control, you need to perform further checks - see the Openmaize.AccessControl module for more information.

Examples using Phoenix

Add the following line to the pipeline in the web/router.ex file:

plug Openmaize.Authenticate

There are no options. If you are using cookies to store the tokens, make sure that you call plug fetch_cookies before Openmaize.Authenticate.

Summary

Functions

Authenticate the user using JSON Web Tokens

Callback implementation for c:Plug.init/1

Functions

call(conn, opts)

Authenticate the user using JSON Web Tokens.

This function checks the token, which is either in a cookie or the request headers, and authenticates the user based on the information in the token.

It also sets the current_user variable, which, if you are using Phoenix, can then be used in your templates. If no token is found, the current_user is set to nil.

init(opts)

Callback implementation for c:Plug.init/1.