Packages

ory_client

1.22.87
1.22.87 1.22.86 1.22.85 1.22.84 1.22.83 1.22.82 1.22.81 1.22.80 1.22.79 1.22.78 1.22.66 1.22.65 1.22.64 1.22.63 1.22.62 1.22.61 1.22.60 1.22.59 1.22.58 1.22.57 1.22.56 1.22.55 1.22.54 1.22.53 1.22.52 1.22.51 1.22.50 1.22.49 1.22.48 1.22.47 1.22.46 1.22.45 1.22.44 1.22.43 1.22.42 1.22.41 1.22.40 1.22.39 1.22.38 1.22.37 1.22.36 1.22.35 1.22.34 1.22.33 1.22.32 1.22.28 1.22.27 1.22.26 1.22.25 1.22.24 1.22.23 1.22.22 1.22.21 1.22.16 1.22.15 1.22.14 1.22.13 1.22.12 1.22.11 1.22.10 1.22.9 1.22.8 1.22.7 1.22.6 1.22.5 1.22.4 1.22.3 1.22.2 1.22.1 1.22.0 1.21.6 1.21.5 1.21.4 1.21.3 1.21.2 1.21.1 1.21.0 1.20.23 1.20.22 1.20.11 1.20.10 1.20.9 1.20.8 1.20.7 1.20.6 1.20.5 1.20.4 1.20.3 1.20.2 1.20.1 1.20.0 1.19.0 1.18.5 1.18.4 1.17.2 1.17.1 1.16.10 1.6.2 1.6.1 1.5.2 1.5.1 1.5.0 1.4.9 1.4.8 1.4.7 1.4.6 1.4.5 1.4.4 1.4.3 1.4.2 1.4.1 1.4.0 1.3.0 1.2.17 1.2.16 1.2.15 1.2.14 1.2.11 1.2.10 1.2.9 1.2.8 1.2.7 1.2.6 1.2.5 1.2.4 1.2.3 1.2.2 1.2.1 1.2.0 1.1.51 1.1.50 1.1.49 1.1.48 1.1.47 1.1.46 1.1.45 1.1.44 1.1.41 1.1.40 1.1.39 1.1.39-alpha.0 1.1.38 1.1.37 1.1.36 1.1.35 1.1.34 1.1.33 1.1.32 1.1.31 1.1.30 1.1.29 1.1.28 1.1.27 1.1.26 1.1.25 1.1.24 1.1.23 1.1.22 1.1.21 1.1.20 1.1.19 1.1.18 1.1.17 1.1.7 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.2 1.0.1 1.0.0 1.0.0-alpha.0 0.2.0-alpha.60 0.2.0-alpha.48 0.2.0-alpha.47 0.2.0-alpha.46 0.2.0-alpha.45 0.2.0-alpha.44 0.2.0-alpha.43 0.2.0-alpha.42 0.2.0-alpha.41 0.2.0-alpha.40 0.2.0-alpha.39 0.2.0-alpha.38 0.2.0-alpha.37 0.2.0-alpha.36 0.2.0-alpha.35 0.2.0-alpha.34 0.2.0-alpha.33 0.2.0-alpha.32 0.2.0-alpha.31 0.2.0-alpha.30 0.2.0-alpha.29 0.2.0-alpha.28 0.2.0-alpha.27 0.2.0-alpha.26 0.2.0-alpha.25 0.2.0-alpha.24 0.2.0-alpha.23 0.2.0-alpha.22 0.2.0-alpha.21 0.2.0-alpha.20 0.2.0-alpha.19 0.2.0-alpha.18 0.2.0-alpha.16 0.2.0-alpha.15 0.2.0-alpha.14 0.2.0-alpha.4 0.2.0-alpha.2 0.1.0-alpha.12 0.1.0-alpha.11 0.1.0-alpha.10 0.1.0-alpha.9 0.1.0-alpha.8 0.1.0-alpha.7 0.1.0-alpha.6 0.1.0-alpha.5 0.1.0-alpha.4 0.1.0-alpha.3 0.1.0-alpha.2 0.1.0-alpha.1 0.0.1-alpha.189 0.0.1-alpha.188 0.0.1-alpha.187

OpenAPI API client for Ory Network, Ory's web-scale API for identity and access control.

Current section

Files

Jump to
ory_client lib ory api jwk.ex
Raw

lib/ory/api/jwk.ex

# NOTE: This file is auto generated by OpenAPI Generator 7.12.0 (https://openapi-generator.tech).
# Do not edit this file manually.

defmodule Ory.Api.Jwk do
  @moduledoc """
  API calls for all endpoints tagged `Jwk`.
  """

  alias Ory.Connection
  import Ory.RequestBuilder

  @doc """
  Create JSON Web Key
  This endpoint is capable of generating JSON Web Key Sets for you. There are different strategies available, such as symmetric cryptographic keys (HS256, HS512) and asymmetric cryptographic keys (RS256, ECDSA). If the specified JSON Web Key Set does not exist, it will be created.  If the set already exists, the newly generated key is added to it and all existing keys are kept. This allows you to rotate keys: tokens signed with an older key in the set remain verifiable. Exception: when Ory Hydra is configured to use a Hardware Security Module (HSM), generating a key replaces the set, which then contains only the new key. To replace a set and all of its keys instead, use the `setJsonWebKeySet` operation (`PUT /admin/keys/{set}`).  A JSON Web Key (JWK) is a JavaScript Object Notation (JSON) data structure that represents a cryptographic key. A JWK Set is a JSON data structure that represents a set of JWKs. A JSON Web Key is identified by its set and key id. ORY Hydra uses this functionality to store cryptographic keys used for TLS and JSON Web Tokens (such as OpenID Connect ID tokens), and allows storing user-defined keys as well.  While `jwks.admin_api.expose_private_keys` is disabled, responses contain public key material only, and a key with no public representation is omitted. The generated key is stored in full either way.

  ### Parameters

  - `connection` (Ory.Connection): Connection to server
  - `set` (String.t): The JSON Web Key Set ID
  - `create_json_web_key_set` (CreateJsonWebKeySet): 
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, Ory.Model.JsonWebKeySet.t}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec create_json_web_key_set(Tesla.Env.client, String.t, Ory.Model.CreateJsonWebKeySet.t, keyword()) :: {:ok, Ory.Model.ErrorOAuth2.t} | {:ok, Ory.Model.JsonWebKeySet.t} | {:error, Tesla.Env.t}
  def create_json_web_key_set(connection, set, create_json_web_key_set, _opts \\ []) do
    request =
      %{}
      |> method(:post)
      |> url("/admin/keys/#{set}")
      |> add_param(:body, :body, create_json_web_key_set)
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {201, Ory.Model.JsonWebKeySet},
      {:default, Ory.Model.ErrorOAuth2}
    ])
  end

  @doc """
  Delete JSON Web Key
  Use this endpoint to delete a single JSON Web Key.  A JSON Web Key (JWK) is a JavaScript Object Notation (JSON) data structure that represents a cryptographic key. A JWK Set is a JSON data structure that represents a set of JWKs. A JSON Web Key is identified by its set and key id. ORY Hydra uses this functionality to store cryptographic keys used for TLS and JSON Web Tokens (such as OpenID Connect ID tokens), and allows storing user-defined keys as well.

  ### Parameters

  - `connection` (Ory.Connection): Connection to server
  - `set` (String.t): The JSON Web Key Set
  - `kid` (String.t): The JSON Web Key ID (kid)
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, nil}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec delete_json_web_key(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, nil} | {:ok, Ory.Model.ErrorOAuth2.t} | {:error, Tesla.Env.t}
  def delete_json_web_key(connection, set, kid, _opts \\ []) do
    request =
      %{}
      |> method(:delete)
      |> url("/admin/keys/#{set}/#{kid}")
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {204, false},
      {:default, Ory.Model.ErrorOAuth2}
    ])
  end

  @doc """
  Delete JSON Web Key Set
  Use this endpoint to delete a complete JSON Web Key Set and all the keys in that set.  A JSON Web Key (JWK) is a JavaScript Object Notation (JSON) data structure that represents a cryptographic key. A JWK Set is a JSON data structure that represents a set of JWKs. A JSON Web Key is identified by its set and key id. ORY Hydra uses this functionality to store cryptographic keys used for TLS and JSON Web Tokens (such as OpenID Connect ID tokens), and allows storing user-defined keys as well.

  ### Parameters

  - `connection` (Ory.Connection): Connection to server
  - `set` (String.t): The JSON Web Key Set
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, nil}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec delete_json_web_key_set(Tesla.Env.client, String.t, keyword()) :: {:ok, nil} | {:ok, Ory.Model.ErrorOAuth2.t} | {:error, Tesla.Env.t}
  def delete_json_web_key_set(connection, set, _opts \\ []) do
    request =
      %{}
      |> method(:delete)
      |> url("/admin/keys/#{set}")
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {204, false},
      {:default, Ory.Model.ErrorOAuth2}
    ])
  end

  @doc """
  Get JSON Web Key
  This endpoint returns a singular JSON Web Key contained in a set. It is identified by the set and the specific key ID (kid).  While `jwks.admin_api.expose_private_keys` is disabled, responses contain public key material only, and a key with no public representation is omitted.

  ### Parameters

  - `connection` (Ory.Connection): Connection to server
  - `set` (String.t): JSON Web Key Set ID
  - `kid` (String.t): JSON Web Key ID
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, Ory.Model.JsonWebKeySet.t}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec get_json_web_key(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, Ory.Model.ErrorOAuth2.t} | {:ok, Ory.Model.JsonWebKeySet.t} | {:error, Tesla.Env.t}
  def get_json_web_key(connection, set, kid, _opts \\ []) do
    request =
      %{}
      |> method(:get)
      |> url("/admin/keys/#{set}/#{kid}")
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, Ory.Model.JsonWebKeySet},
      {:default, Ory.Model.ErrorOAuth2}
    ])
  end

  @doc """
  Retrieve a JSON Web Key Set
  This endpoint can be used to retrieve JWK Sets stored in ORY Hydra.  A JSON Web Key (JWK) is a JavaScript Object Notation (JSON) data structure that represents a cryptographic key. A JWK Set is a JSON data structure that represents a set of JWKs. A JSON Web Key is identified by its set and key id. ORY Hydra uses this functionality to store cryptographic keys used for TLS and JSON Web Tokens (such as OpenID Connect ID tokens), and allows storing user-defined keys as well.  While `jwks.admin_api.expose_private_keys` is disabled, responses contain public key material only, and a key with no public representation is omitted.

  ### Parameters

  - `connection` (Ory.Connection): Connection to server
  - `set` (String.t): JSON Web Key Set ID
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, Ory.Model.JsonWebKeySet.t}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec get_json_web_key_set(Tesla.Env.client, String.t, keyword()) :: {:ok, Ory.Model.ErrorOAuth2.t} | {:ok, Ory.Model.JsonWebKeySet.t} | {:error, Tesla.Env.t}
  def get_json_web_key_set(connection, set, _opts \\ []) do
    request =
      %{}
      |> method(:get)
      |> url("/admin/keys/#{set}")
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, Ory.Model.JsonWebKeySet},
      {:default, Ory.Model.ErrorOAuth2}
    ])
  end

  @doc """
  Set JSON Web Key
  Use this method if you do not want to let Hydra generate the JWKs for you, but instead save your own.  The key is created or updated under the `{kid}` path parameter. If the request body carries a `kid`, it must equal the path parameter, or the request is rejected with `400`. A body without a `kid` takes the path parameter as its `kid`.  A JSON Web Key (JWK) is a JavaScript Object Notation (JSON) data structure that represents a cryptographic key. A JWK Set is a JSON data structure that represents a set of JWKs. A JSON Web Key is identified by its set and key id. ORY Hydra uses this functionality to store cryptographic keys used for TLS and JSON Web Tokens (such as OpenID Connect ID tokens), and allows storing user-defined keys as well.  The response echoes the key as it was stored, including any private key material the request carried. `jwks.admin_api.expose_private_keys` governs what a read discloses and does not apply here, because this response returns only what the request already contained.  While that setting is disabled, writing a public key over the last private key of a set is rejected with `400`, because reading the set returns public keys only and writing that response back would discard the key it signs with.

  ### Parameters

  - `connection` (Ory.Connection): Connection to server
  - `set` (String.t): The JSON Web Key Set ID
  - `kid` (String.t): JSON Web Key ID
  - `opts` (keyword): Optional parameters
    - `:body` (JsonWebKey): 

  ### Returns

  - `{:ok, Ory.Model.JsonWebKey.t}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec set_json_web_key(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, Ory.Model.ErrorOAuth2.t} | {:ok, Ory.Model.JsonWebKey.t} | {:error, Tesla.Env.t}
  def set_json_web_key(connection, set, kid, opts \\ []) do
    optional_params = %{
      :body => :body
    }

    request =
      %{}
      |> method(:put)
      |> url("/admin/keys/#{set}/#{kid}")
      |> add_optional_params(optional_params, opts)
      |> ensure_body()
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, Ory.Model.JsonWebKey},
      {400, Ory.Model.ErrorOAuth2},
      {:default, Ory.Model.ErrorOAuth2}
    ])
  end

  @doc """
  Update a JSON Web Key Set
  Use this method if you do not want to let Hydra generate the JWKs for you, but instead save your own.  This operation replaces the entire JSON Web Key Set: keys that exist in the set but are not part of the request body are deleted. To add a newly generated key to the set while keeping the existing keys, use the `createJsonWebKeySet` operation (`POST /admin/keys/{set}`).  A JSON Web Key (JWK) is a JavaScript Object Notation (JSON) data structure that represents a cryptographic key. A JWK Set is a JSON data structure that represents a set of JWKs. A JSON Web Key is identified by its set and key id. ORY Hydra uses this functionality to store cryptographic keys used for TLS and JSON Web Tokens (such as OpenID Connect ID tokens), and allows storing user-defined keys as well.  The response echoes the key set as it was stored, including any private key material the request carried. `jwks.admin_api.expose_private_keys` governs what a read discloses and does not apply here, because this response returns only what the request already contained.  While that setting is disabled, a request that would leave the key set without a private key is rejected with `400`. Reading a key set returns public keys only, so writing that response back would discard the private keys the set signs with. Retiring one key to its public half stays possible as long as the set keeps another private key, and a key set is removed with the `deleteJsonWebKeySet` operation.

  ### Parameters

  - `connection` (Ory.Connection): Connection to server
  - `set` (String.t): The JSON Web Key Set ID
  - `opts` (keyword): Optional parameters
    - `:body` (JsonWebKeySet): 

  ### Returns

  - `{:ok, Ory.Model.JsonWebKeySet.t}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec set_json_web_key_set(Tesla.Env.client, String.t, keyword()) :: {:ok, Ory.Model.ErrorOAuth2.t} | {:ok, Ory.Model.JsonWebKeySet.t} | {:error, Tesla.Env.t}
  def set_json_web_key_set(connection, set, opts \\ []) do
    optional_params = %{
      :body => :body
    }

    request =
      %{}
      |> method(:put)
      |> url("/admin/keys/#{set}")
      |> add_optional_params(optional_params, opts)
      |> ensure_body()
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, Ory.Model.JsonWebKeySet},
      {400, Ory.Model.ErrorOAuth2},
      {:default, Ory.Model.ErrorOAuth2}
    ])
  end
end