Atex.OAuth.Cache (atex v0.7.1)

View Source

TTL cache for OAuth authorization server information.

This module manages two separate ConCache instances:

  • Authorization server cache (stores PDS -> authz server mappings)
  • Authorization metadata cache (stores authz server -> metadata mappings)

Both caches use a 1-hour TTL to reduce load on third-party PDSs.

Summary

Functions

Returns a specification to start this module under a supervisor.

Get authorization server from cache.

Get authorization server metadata from cache.

Store authorization server in cache.

Store authorization server metadata in cache.

Starts the OAuth cache supervisor.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get_authorization_server(pds_host)

@spec get_authorization_server(String.t()) :: {:ok, String.t()} | {:error, :not_found}

Get authorization server from cache.

Parameters

Returns

  • {:ok, authorization_server} - Successfully retrieved from cache
  • {:error, :not_found} - Not present in cache

get_authorization_server_metadata(issuer)

@spec get_authorization_server_metadata(String.t()) ::
  {:ok, Atex.OAuth.authorization_metadata()} | {:error, :not_found}

Get authorization server metadata from cache.

Parameters

  • issuer - Authorization server issuer URL

Returns

  • {:ok, metadata} - Successfully retrieved from cache
  • {:error, :not_found} - Not present in cache

set_authorization_server(pds_host, authorization_server)

@spec set_authorization_server(String.t(), String.t()) :: :ok

Store authorization server in cache.

Parameters

  • pds_host - Base URL of the PDS
  • authorization_server - Authorization server URL to cache

Returns

  • :ok

set_authorization_server_metadata(issuer, metadata)

@spec set_authorization_server_metadata(
  String.t(),
  Atex.OAuth.authorization_metadata()
) :: :ok

Store authorization server metadata in cache.

Parameters

  • issuer - Authorization server issuer URL
  • metadata - Authorization server metadata to cache

Returns

  • :ok

start_link(opts)

Starts the OAuth cache supervisor.