Coherence v0.3.0 Coherence.Authentication.Token

Implements token based authentication. To use add

plug Coherence.Authentication.Token, source: :params, param: "auth_token"

or

plug Coherence.Authentication.Token, source: :session, param: "auth_token"

or

plug Coherence.Authentication.Token, source: :header, param: "X-Auth-Token"

or

plug Coherence.Authentication.Token, source: { module, function, ["my_param"]} end

or

plug Coherence.Authentication.Token, source: :params_session, param: "auth_token"

to your pipeline.

Options

  • source - where to locate the token
  • error - The error message if not authenticated
  • assigns_key - The key to user in assigns (:current_uer)
  • store - Where to store the token data

Summary

Functions

add_credentials(token, user_data, store \\ Coherence.CredentialStore.Agent)

Add the credentials for a token. user_data can be any term but must not be nil.

call(conn, opts)
check_token_from_session(arg, param)
generate_token()

Utility function to generate a random authentication token.

get_token_from_header(conn, param)
get_token_from_params(conn, param)
get_token_from_params_session(conn, param)
get_token_from_session(conn, param)
init(opts)
remove_credentials(token, store \\ Coherence.CredentialStore.Agent)

Remove the credentials for a token.

save_token_in_session(arg, param)