Paladin Client v0.2.1 PaladinClient behaviour

Provides helper functions for working with the Paladin service and a Behaviour for adapters

Summary

Functions

When using Paladin, your issuer should be your application ID

Fetch the url of Paladin in this environment

Fetch the paladin id from config via the name

When you have an existing Guardian JWT you may use it to exchange via Paladin for a token of the application you wish to talk to

Without an existing token, you may generate your own token to make use as an exchange for Paladin

When there is no existing token. This is useful for when there is no user you are acting on behalf of. Primarily system to system

Callback implementation for Application.start/2

Types

app_id()
app_id :: atom | String.t
assertion_token()
expiry()
expiry :: non_neg_integer
jwt()
reason()
reason :: atom | String.t

Functions

client_id()

When using Paladin, your issuer should be your application ID.

endpoint()

Fetch the url of Paladin in this environment

fetch_app_id(app_id)

Fetch the paladin id from config via the name

In your configuration you should add a KWList of name: id

config :paladin_client, PaladinClient,

 apps: [
   app_one: "app-one-id",
   app_two: "app-two-id",
 ]

PaladinClient.fetch_app_id(:app_one) == “app-one-id”

from_existing_token(token, app_id, opts \\ %{})
from_existing_token(jwt, app_id, Map.t) ::
  {:ok, jwt} |
  {:error, reason}

When you have an existing Guardian JWT you may use it to exchange via Paladin for a token of the application you wish to talk to

new_assertion_token(app_id, user, claims \\ %{})
new_assertion_token(app_id, term, Map.t) ::
  {:ok, jwt} |
  {:error, term}

Without an existing token, you may generate your own token to make use as an exchange for Paladin

service_token(app_id, claims \\ %{})
service_token(app_id, Map.t) :: {:ok, token} :: {:error, term}

When there is no existing token. This is useful for when there is no user you are acting on behalf of. Primarily system to system

start(type, args)

Callback implementation for Application.start/2.

Callbacks

access_token(assertion_token)
access_token(assertion_token) ::
  {:ok, jwt, expiry} |
  {:error, reason}