Auth0Client.Management.Connection (auth0_client v1.0.0)

Copy Markdown View Source

A module representing connection resource

Summary

Functions

Gets all the connections

Gets the clients that have this connection enabled

Creates a new connection

Provisions the initial connection keys

Delete a connection

Delete a specified connection user by its email

Get a connection

Gets the connection keys

Rotates the connection keys

Checks whether an AD/LDAP connection is online

Update a connection

Enables or disables this connection for the given clients

Functions

all(params \\ %{})

Gets all the connections

Past 1,000 connections, offset pagination stops working — use checkpoint pagination instead, passing from and take.

iex> Auth0Client.Management.Connection.all()
iex> Auth0Client.Management.Connection.all(%{name: "some_name"})
iex> Auth0Client.Management.Connection.all(take: 100)

clients(id, params \\ %{})

Gets the clients that have this connection enabled

The mirror of Auth0Client.Management.Client.connections/2. Uses checkpoint pagination: omit from on the first call, then pass the next value from the response.

iex> Auth0Client.Management.Connection.clients("some_conn_id")
iex> Auth0Client.Management.Connection.clients("some_conn_id", take: 50)

create(body)

Creates a new connection

iex> Auth0Client.Management.Connection.create(%{name: "some_name", strategy: "email"})

create_keys(id, body \\ %{})

Provisions the initial connection keys

Okta and OIDC strategies only. Create the keys before configuring the connection to use Private Key JWT, so the transition needs no downtime.

signing_alg is one of RS256, RS384, RS512, PS256, PS384, ES256 or ES384.

iex> Auth0Client.Management.Connection.create_keys("some_conn_id", %{signing_alg: "RS256"})

delete(id)

Delete a connection

iex> Auth0Client.Management.Connection.delete("some_conn_id")

delete_conn_user(id, email)

Delete a specified connection user by its email

iex> Auth0Client.Management.Connection.delete_conn_user("some_conn_id", "samar@example.com")

get(id)

Get a connection

iex> Auth0Client.Management.Connection.get("some_conn_id")
iex> Auth0Client.Management.Connection.get("some_conn_id", [fields: "id,name"])

get(id, params)

keys(id)

Gets the connection keys

Okta and OIDC strategies only.

iex> Auth0Client.Management.Connection.keys("some_conn_id")

rotate_keys(id, body \\ %{})

Rotates the connection keys

iex> Auth0Client.Management.Connection.rotate_keys("some_conn_id")
iex> Auth0Client.Management.Connection.rotate_keys("some_conn_id", %{signing_alg: "RS256"})

status(id)

Checks whether an AD/LDAP connection is online

A 404 here means the connection is offline, not that it does not exist — that is how Auth0 reports the state, so it arrives as an error like any other 404:

case Auth0Client.Management.Connection.status(conn_id) do
  {:ok, _} -> :online
  {:error, %Auth0Client.Error{status: 404}} -> :offline
  {:error, error} -> {:error, error}
end

iex> Auth0Client.Management.Connection.status("some_conn_id")

update(id, body)

Update a connection

name and strategy are immutable — Auth0 rejects an attempt to change either, so a connection has to be recreated to rename it.

enabled_clients is superseded by update_clients/2, which changes one client at a time rather than replacing the whole list.

iex> Auth0Client.Management.Connection.update("some_conn_id", %{display_name: "New name"})
iex> Auth0Client.Management.Connection.update("some_conn_id", %{options: %{brute_force_protection: true}})

update_clients(id, clients)

Enables or disables this connection for the given clients

Takes a list of %{client_id: _, status: _} — a JSON array, not an object — and changes only the clients named. Auth0 accepts at most 50 per request. This is the replacement for setting enabled_clients through update/2, which replaces the entire list and so races with anyone else editing the connection.

Returns :ok; Auth0 answers 204 with no body.

iex> Auth0Client.Management.Connection.update_clients("some_conn_id", [
...>   %{client_id: "abc123", status: true},
...>   %{client_id: "def456", status: false}
...> ])