Pow v1.0.15 Pow.Store.CredentialsCache View Source

Default module for credentials session storage.

A key (session id), is used to store, fetch or delete credentials. When credentials are stored or deleted, a credentials key will be generated. The value of that key will be all current keys (session ids), and the most recent credentials.

When a key is updated, all expired keys will be pruned from the credentials key.

The credentials are expected to take the form of {credentials, session_metadata}, where session metadata is data exclusive to the session id.

Link to this section Summary

Functions

Delete the user credentials data from the backend store.

Fetch user credentials from the backend store from session id.

Add user credentials with the session id to the backend store.

List all existing sessions for the user fetched from the backend store.

List all user for a certain user struct.

Link to this section Functions

Link to this function

backend_config(config)

View Source
backend_config(Pow.Config.t()) :: Pow.Config.t()

Delete the user credentials data from the backend store.

This following two key-value will be deleted:

  • {session_id, {[user_struct, :user, user_id], metadata}}
  • {[user_struct, :user, user_id, :session, session_id], inserted_at}

The {[user_struct, :user, user_id], user} key-value is expected to expire when reaching its TTL.

Link to this function

get(config, key)

View Source
get(Pow.Config.t(), binary()) :: {map(), list()} | :not_found

Fetch user credentials from the backend store from session id.

Add user credentials with the session id to the backend store.

The credentials are expected to be in the format of {credentials, metadata}.

This following three key-value will be inserted:

  • {session_id, {[user_struct, :user, user_id], metadata}}
  • {[user_struct, :user, user_id], user}
  • {[user_struct, :user, user_id, :session, session_id], inserted_at}

If metadata has :fingerprint any active sessions for the user with the same :fingerprint in metadata will be deleted.

Link to this function

sessions(config, user)

View Source
sessions(Pow.Config.t(), map()) :: [binary()]

List all existing sessions for the user fetched from the backend store.

Link to this function

users(config, struct)

View Source
users(Pow.Config.t(), module()) :: [any()]

List all user for a certain user struct.

Sessions for a user can be looked up with sessions/3.