Pasexto.Keyring (pasexto v0.1.1)

Copy Markdown View Source

A keyring can be used to store a collection of keys for use in the building and parsing of tokens.

Just like a Pasexto.Key, a keyring is also scoped to a protocol's version and purpose. Keys added to the keyring must have an identifier assigned to them, it is recommended to use Pasexto.Paserk to achieve this.

A key can be added to the keyring like so:

iex> key = Key.new(:v4, :local)
iex> keyring = Keyring.new(:v4, :local) |> Keyring.put("key1", key)

Summary

Functions

Get the key for a given key identifier.

Creates an empty keyring for use with the given protocol version and purpose.

Put a key in the keyring for the given key identifier.

Types

t()

@type t() :: %Pasexto.Keyring{
  keys: term(),
  purpose: Pasexto.Key.purpose(),
  version: Pasexto.Key.version()
}

Functions

get(keyring, id)

@spec get(t(), binary()) :: Pasexto.Key.t() | nil

Get the key for a given key identifier.

new(version, purpose)

Creates an empty keyring for use with the given protocol version and purpose.

put(keyring, id, key)

@spec put(t(), binary(), Pasexto.Key.t()) :: t()

Put a key in the keyring for the given key identifier.

If the key does not have the protocol version and purpose then the key is not added.