oauth2_token_manager v0.1.0 OAuth2TokenManager.Store behaviour View Source

Token store behaviour

There are 3 types of data to store:

  • access tokens
  • refresh tokens
  • claims and ID token

Link to this section Summary

Functions

Acts as a "flag" to mark this module as a Knigge module.

Access Knigge internal values, such as the implementation being delegated to etc.

See OAuth2TokenManager.Store.Local.delete_access_token/1.

See OAuth2TokenManager.Store.Local.delete_refresh_token/1.

See OAuth2TokenManager.Store.Local.get_access_token/1.

See OAuth2TokenManager.Store.Local.get_access_tokens_client_credentials/2.

See OAuth2TokenManager.Store.Local.get_access_tokens_for_subject/2.

See OAuth2TokenManager.Store.Local.get_claims/2.

See OAuth2TokenManager.Store.Local.get_id_token/2.

See OAuth2TokenManager.Store.Local.get_refresh_token/1.

See OAuth2TokenManager.Store.Local.get_refresh_tokens_client_credentials/2.

See OAuth2TokenManager.Store.Local.get_refresh_tokens_for_subject/2.

See OAuth2TokenManager.Store.Local.put_access_token/4.

See OAuth2TokenManager.Store.Local.put_claims/3.

See OAuth2TokenManager.Store.Local.put_id_token/3.

See OAuth2TokenManager.Store.Local.put_refresh_token/3.

Callbacks

Deletes an access token

Deletes a refresh token

Returns the access token and its metadata

Returns all the access tokens in the client credentials flow for a client

Returns all the access tokens for a given subject

Returns claims for a subject

Returns an ID token for the subject

Returns the refresh token and its metadata

Returns all the refresh tokens in the client credentials flow for a client

Returns all the refresh tokens for a given subject

Registers claims for a subject

Saves an ID token for a subject

Link to this section Functions

Specs

__knigge__() :: :ok

Acts as a "flag" to mark this module as a Knigge module.

Specs

__knigge__(:behaviour) :: module()
__knigge__(:implementation) :: module()
__knigge__(:options) :: Knigge.Options.t()

Access Knigge internal values, such as the implementation being delegated to etc.

Link to this function

delete_access_token(arg1)

View Source

See OAuth2TokenManager.Store.Local.delete_access_token/1.

Link to this function

delete_refresh_token(arg1)

View Source

See OAuth2TokenManager.Store.Local.delete_refresh_token/1.

See OAuth2TokenManager.Store.Local.get_access_token/1.

Link to this function

get_access_tokens_client_credentials(arg1, arg2)

View Source

See OAuth2TokenManager.Store.Local.get_access_tokens_client_credentials/2.

Link to this function

get_access_tokens_for_subject(arg1, arg2)

View Source

See OAuth2TokenManager.Store.Local.get_access_tokens_for_subject/2.

See OAuth2TokenManager.Store.Local.get_claims/2.

Link to this function

get_id_token(arg1, arg2)

View Source

See OAuth2TokenManager.Store.Local.get_id_token/2.

See OAuth2TokenManager.Store.Local.get_refresh_token/1.

Link to this function

get_refresh_tokens_client_credentials(arg1, arg2)

View Source

See OAuth2TokenManager.Store.Local.get_refresh_tokens_client_credentials/2.

Link to this function

get_refresh_tokens_for_subject(arg1, arg2)

View Source

See OAuth2TokenManager.Store.Local.get_refresh_tokens_for_subject/2.

Link to this function

put_access_token(arg1, arg2, arg3, arg4)

View Source

See OAuth2TokenManager.Store.Local.put_access_token/4.

Link to this function

put_claims(arg1, arg2, arg3)

View Source

See OAuth2TokenManager.Store.Local.put_claims/3.

Link to this function

put_id_token(arg1, arg2, arg3)

View Source

See OAuth2TokenManager.Store.Local.put_id_token/3.

Link to this function

put_refresh_token(arg1, arg2, arg3)

View Source

See OAuth2TokenManager.Store.Local.put_refresh_token/3.

Link to this section Callbacks

Link to this callback

delete_access_token(arg1)

View Source

Specs

delete_access_token(OAuth2TokenManager.access_token()) ::
  :ok | {:error, Exception.t()}

Deletes an access token

Link to this callback

delete_refresh_token(arg1)

View Source

Specs

delete_refresh_token(OAuth2TokenManager.refresh_token()) ::
  :ok | {:error, Exception.t()}

Deletes a refresh token

Specs

Returns the access token and its metadata

If the access token doesn't exist, returns {:ok, nil} instead. {:error, e} is returned only in case of error.

The returned token is expected to be valid. The OAuth2TokenManager.token_valid?/1 can be used to verify it.

Link to this callback

get_access_tokens_client_credentials(arg1, arg2)

View Source

Specs

Returns all the access tokens in the client credentials flow for a client

An empty list is returned if there are not access tokens for the client in the client credentials flow.

The returned tokens are expected to be valid. The OAuth2TokenManager.token_valid?/1 can be used to verify it.

Link to this callback

get_access_tokens_for_subject(arg1, arg2)

View Source

Specs

Returns all the access tokens for a given subject

An empty list is returned if there are not access tokens for the subject.

The returned tokens are expected to be valid. The OAuth2TokenManager.token_valid?/1 can be used to verify it.

Specs

get_claims(OAuth2TokenManager.issuer(), OAuth2TokenManager.subject()) ::
  {:ok,
   {OAuth2TokenManager.claims() | nil, updated_at :: non_neg_integer() | nil}}
  | {:error, Exception.t()}

Returns claims for a subject

Link to this callback

get_id_token(arg1, arg2)

View Source

Specs

Returns an ID token for the subject

There is no obligation to save all of the ID tokens. Instead, the most recent one is typically preferred

Specs

get_refresh_token(OAuth2TokenManager.refresh_token()) ::
  {:ok,
   {OAuth2TokenManager.refresh_token(), OAuth2TokenManager.token_metadata(),
    updated_at :: non_neg_integer()}}
  | {:ok, nil}
  | {:error, Exception.t()}

Returns the refresh token and its metadata

If the refresh token doesn't exist, returns {:ok, nil} instead. {:error, e} is returned only in case of error.

The returned token is expected to be valid. The OAuth2TokenManager.token_valid?/1 can be used to verify it.

Link to this callback

get_refresh_tokens_client_credentials(arg1, arg2)

View Source

Specs

get_refresh_tokens_client_credentials(
  OAuth2TokenManager.issuer(),
  OAuth2TokenManager.client_id()
) ::
  {:ok,
   {OAuth2TokenManager.refresh_token(), OAuth2TokenManager.token_metadata(),
    updated_at :: non_neg_integer()}}
  | {:error, Exception.t()}

Returns all the refresh tokens in the client credentials flow for a client

An empty list is returned if there are not refresh tokens for the client in the client credentials flow.

The returned tokens are expected to be valid. The OAuth2TokenManager.token_valid?/1 can be used to verify it.

Link to this callback

get_refresh_tokens_for_subject(arg1, arg2)

View Source

Specs

Returns all the refresh tokens for a given subject

An empty list is returned if there are not refresh tokens for the subject.

The returned tokens are expected to be valid. The OAuth2TokenManager.token_valid?/1 can be used to verify it.

Link to this callback

put_access_token(access_token, token_type, access_token_metadata, issuer)

View Source

Specs

put_access_token(
  access_token :: OAuth2TokenManager.access_token(),
  token_type :: OAuth2TokenManager.token_type(),
  access_token_metadata :: OAuth2TokenManager.token_metadata(),
  issuer :: OAuth2TokenManager.issuer()
) :: {:ok, OAuth2TokenManager.token_metadata()} | {:error, Exception.t()}

Saves an access token and its metadata

Link to this callback

put_claims(arg1, arg2, arg3)

View Source

Specs

Registers claims for a subject

Link to this callback

put_id_token(arg1, arg2, arg3)

View Source

Specs

Saves an ID token for a subject

There is no obligation to save all of the ID tokens. Instead, the most recent one is typically preferred

Link to this callback

put_refresh_token(refresh_token, refresh_token_metadata, issuer)

View Source

Specs

put_refresh_token(
  refresh_token :: OAuth2TokenManager.refresh_token(),
  refresh_token_metadata :: OAuth2TokenManager.token_metadata(),
  issuer :: OAuth2TokenManager.issuer()
) :: {:ok, OAuth2TokenManager.token_metadata()} | {:error, Exception.t()}

Saves a refresh token and its metadata