OpenStax.Keystone v1.0.0 OpenStax.Keystone.Endpoint.Registry View Source

This module is responsible for storing registry of Keystone endpoints.

Link to this section Summary

Types

Endpoint identifier

Return value of starting registry

Options passed while starting registry

Functions

Returns current auth token for the given endpoint

Returns current configuration for the given endpoint

Registers new endpoint that uses username/password for authentication

Registers new endpoint that uses token for authentication

Sets the auth token for the given endpoint

Starts a new registry for storing configuration and links it to the calling process

Link to this section Types

Link to this type endpoint_id_t() View Source
endpoint_id_t() :: Map.key()

Endpoint identifier

Link to this type on_start_t() View Source
on_start_t() :: Agent.on_start()

Return value of starting registry

Options passed while starting registry

Link to this section Functions

Link to this function get_auth_token(endpoint_id, timeout \\ 5000) View Source

Returns current auth token for the given endpoint.

It returns {:ok, {auth_token, expires}} on success, {:error, reason} otherwise.

It is up to the application to check if auth token has not expired before usage.

Possible error reasons are:

  • :invalid_endpoint_id - endpoint with given ID is not registered
Link to this function get_config(endpoint_id, timeout \\ 5000) View Source
get_config(endpoint_id_t(), timeout()) ::
  {:ok, OpenStax.Keystone.Endpoint.Config.t()} | {:error, any()}

Returns current configuration for the given endpoint.

It returns {:ok, config} on success, {:error, reason} otherwise.

Possible error reasons are:

  • :invalid_endpoint_id - endpoint with given ID is not registered

Registers new endpoint that uses username/password for authentication.

Endpoint URL is a URL to the authentication service, along with /v2.0 suffix.

According to the specification Tenant’s ID and Name are mutually exclusive so you have to specify only one of them (put nil as second one).

It returns :ok on success, {:error, reason} otherwise.

FIXME: currently in case of trying to register the two endpoints with the same ID the configuration of the existing endpoint will be overridden despite returning the error.

Registers new endpoint that uses token for authentication.

Endpoint URL is a URL to the authentication service, along with /v2.0 suffix.

According to the specification Tenant’s ID and Name are mutually exclusive so you have to specify only one of them (put nil as second one).

It returns :ok on success, {:error, reason} otherwise.

Possible error reasons are:

  • :already_registered - endpoint with given ID is already registered

FIXME: currently in case of trying to register the two endpoints with the same ID the configuration of the existing endpoint will be overridden despite returning the error.

Link to this function set_auth_token(endpoint_id, auth_token, expires) View Source
set_auth_token(
  endpoint_id_t(),
  OpenStax.Keystone.Endpoint.Config.auth_token_t(),
  DateTime.t() | nil
) :: :ok | {:error, any()}

Sets the auth token for the given endpoint.

Link to this function start_link(opts \\ []) View Source
start_link(options_t()) :: on_start_t()

Starts a new registry for storing configuration and links it to the calling process.