Coherence.Authentication.Token (Coherence v0.8.0)
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"]} endor
plug Coherence.Authentication.Token, source: :params_session, param: "auth_token"to your pipeline.
Options
source- where to locate the tokenerror- The error message if not authenticatedassigns_key- The key to user in assigns (:current_uer)store- Where to store the token data
Summary
Functions
Add the credentials for a token. user_data can be any term but must not be nil.
Callback implementation for Plug.call/2.
Utility function to generate a random authentication token.
Callback implementation for Plug.init/1.
Remove the credentials for a token.
Types
Link to this type
conn()
@type conn() :: Plug.Conn.t()
@type t() :: Ecto.Schema.t() | map()
Functions
Link to this function
add_credentials(token, user_data, store \\ Coherence.CredentialStore.Server)
Add the credentials for a token. user_data can be any term but must not be nil.
Link to this function
call(conn, opts)
Callback implementation for Plug.call/2.
Link to this function
check_token_from_session(arg, param)
Link to this function
generate_token()
@spec generate_token() :: String.t()
Utility function to generate a random authentication token.
Link to this function
get_token_from_header(conn, param)
Link to this function
get_token_from_params(conn, param)
Link to this function
get_token_from_params_session(conn, param)
Link to this function
get_token_from_session(conn, param)
Link to this function
init(opts)
Callback implementation for Plug.init/1.
Link to this function
remove_credentials(token, store \\ Coherence.CredentialStore.Server)
Remove the credentials for a token.
Link to this function