KittenBlue.JWK (kitten_blue v0.5.0)

Structure containing kid, alg, JOSE.JWK and handling functions

Link to this section Summary

Functions

Convert compact storable format to KittenBlue.JWK.

Fetch jwks uri and return jwk list.

Convert config format to KittenBlue.JWK for main issuerance.

Convert compact storable format to KittenBlue.JWK.

Convert JSON Web Key Sets format public key to KittenBlue.JWK.

Convert KittenBlue.JWK List to compact storable format for configration.

Convert KittenBlue.JWK list to JSON Web Key Sets format public keys.

kid = "sample_201804"
alg = "RS256"
key = JOSE.JWK.from_pem_file("rsa-2048.pem")

kb_jwk = KittenBlue.JWK.new([kid, alg, key])
kb_jwk = KittenBlue.JWK.new([kid: kid, alg: alg, key: key])
kb_jwk = KittenBlue.JWK.new(%{kid: kid, alg: alg, key: key})

Convert JSON Web Key Sets format public keys to KittenBlue.JWK list.

Convert KittenBlue.JWK to compact storable format for configration.

Convert KittenBlue.JWK to JSON Web Key Sets format public key.

Link to this section Types

Specs

t() :: %KittenBlue.JWK{alg: String.t(), key: JOSE.JWK.t(), kid: String.t()}

Link to this section Functions

Link to this function

compact_to_list(jwk_compact_list)

Specs

compact_to_list(jwk_compact_list :: list()) :: t()

Convert compact storable format to KittenBlue.JWK.

kb_jwk_list = KittenBlue.JWK.compact_to_list(kb_jwk_list_config)
Link to this function

fetch!(jwks_uri)

Specs

fetch!(jwks_uri :: String.t()) :: [t()] | nil

Fetch jwks uri and return jwk list.

kb_jwk_list = KittenBlue.JWK.fetch!(jwks_uri)

NOTE: The HTTP client must be implemented using Scratcher.HttpClient as the Behavior.

Link to this function

find_key_to_issue(config)

Specs

find_key_to_issue(config :: Keyword.t()) :: t() | nil

Convert config format to KittenBlue.JWK for main issuerance.

For JWT (JWS) signatures, there are cases where a single key is used to issue a signature and multiple keys are used for verification. You can easily get the issuing key from the config with the following description.

config :your_app, Your.Module,
  kid: "kid20200914",
  keys: [["kid20200914", "HS256", "AyM1SysPpbyDfgZld3umj1qzKObwVMkoqQ-EstJQLr_T-1qS0gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr1Z9CAow"]]

The key specified by :kid must be included in :keys.

@config Application.fetch_env!(:your_app, Your.Module)

kb_jwk_to_issue = find_key_to_issue(@config)
Link to this function

from_compact(jwk_compact)

Specs

from_compact(jwk_compact :: list()) :: t() | nil

Convert compact storable format to KittenBlue.JWK.

kb_jwk = KittenBlue.JWK.from_compact(kb_jwk_config)
Link to this function

from_public_jwk_set(jwk_map)

Specs

from_public_jwk_set(public_json_web_key_set :: map()) :: t() | nil

Convert JSON Web Key Sets format public key to KittenBlue.JWK.

kb_jwk = KittenBlue.JWK.from_public_jwk_set(public_jwk_set)
Link to this function

list_to_compact(jwk_list, opts \\ [])

Specs

list_to_compact(jwk_list :: List.t(), opts :: Keyword.t()) :: List.t()

Convert KittenBlue.JWK List to compact storable format for configration.

kb_jwk_list = [kb_jwk]
kb_jwk_list_config = KittenBlue.JWK.list_to_compact(kb_jwk_list)
Link to this function

list_to_public_jwk_sets(jwk_list)

Specs

list_to_public_jwk_sets(jwk_list :: List.t()) :: map() | nil

Convert KittenBlue.JWK list to JSON Web Key Sets format public keys.

kb_jwk_list = [kb_jwk]
public_jwk_sets = KittenBlue.JWK.list_to_public_jwk_sets(kb_jwk_list)

Specs

new(params :: Keywords.t()) :: t()
new(params :: List.t()) :: t()
new(params :: Map.t()) :: t()
kid = "sample_201804"
alg = "RS256"
key = JOSE.JWK.from_pem_file("rsa-2048.pem")

kb_jwk = KittenBlue.JWK.new([kid, alg, key])
kb_jwk = KittenBlue.JWK.new([kid: kid, alg: alg, key: key])
kb_jwk = KittenBlue.JWK.new(%{kid: kid, alg: alg, key: key})
Link to this function

public_jwk_sets_to_list(public_json_web_key_sets)

Specs

public_jwk_sets_to_list(public_json_web_key_sets :: map()) :: List.t()

Convert JSON Web Key Sets format public keys to KittenBlue.JWK list.

kb_jwk_list = KittenBlue.JWK.public_jwk_sets_to_list(public_jwk_sets)
Link to this function

to_compact(jwk, opts \\ [])

Specs

to_compact(jwk :: t(), opts :: Keyword.t()) :: List.t()

Convert KittenBlue.JWK to compact storable format for configration.

kb_jwk_config = KittenBlue.JWK.to_compact(kb_jwk)
Link to this function

to_public_jwk_set(jwk)

Specs

to_public_jwk_set(jwk :: t()) :: map() | nil

Convert KittenBlue.JWK to JSON Web Key Sets format public key.

public_jwk_set = KittenBlue.JWK.to_public_jwk_set(kb_jwk)