Openmaize v1.0.1 Openmaize.Authenticate

Authenticate the current user, using JSON Web Tokens.

For more information about JSON Web Tokens, see the documentation for the OpenmaizeJWT 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.

There is one option:

  • jwt_verify - the function used to verify the JSON Web Token

    • the default is &OpenmaizeJWT.Verify.verify_token/1

Examples using Phoenix

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

plug Openmaize.Authenticate

Summary

Functions

Authenticate the current user using JSON Web Tokens

Callback implementation for c:Plug.init/1

Functions

call(conn, jwt_verify)

Authenticate the current 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.