Lightning.Credentials.OauthClient (Lightning v2.19.0-pre)

View Source

Defines the Ecto schema for an OAuth client. This schema is responsible for representing OAuth client data in the database, including details such as client ID, client secret, and endpoints necessary for OAuth operations. It also links to associated users and projects through relational fields.

Summary

Functions

Builds a changeset for an OAuth client based on the provided attributes.

Changeset for creating a client, where the owner (:user_id) is settable.

Types

t()

@type t() :: %Lightning.Credentials.OauthClient{
  __meta__: Ecto.Schema.Metadata.t(),
  authorization_endpoint: term(),
  client_id: term(),
  client_secret: term(),
  global: term(),
  id: Ecto.UUID.t() | nil,
  inserted_at: term(),
  introspection_endpoint: term(),
  mandatory_scopes: term(),
  name: String.t(),
  optional_scopes: term(),
  project_names: term(),
  project_oauth_clients: term(),
  projects: term(),
  revocation_endpoint: term(),
  scopes_doc_url: term(),
  token_endpoint: term(),
  updated_at: term(),
  user: term(),
  user_id: term(),
  userinfo_endpoint: term()
}

Functions

changeset(oauth_client, attrs, opts \\ [])

Builds a changeset for an OAuth client based on the provided attributes.

Parameters

  • oauth_client: The existing %OauthClient{} struct (or a new struct for creation).
  • attrs: A map of attributes to set on the OAuth client.

Returns

  • An %Ecto.Changeset{} that can be used to create or update an OAuth client.

This function validates the presence of essential fields, ensures that URLs are valid, and handles associations with projects through nested changesets.

Options

  • :allow_global - when true, permits casting :global (which publishes the client instance-wide). Defaults to false, so :global is dropped from the params unless the caller has authorized it; only superusers may set it.

create_changeset(oauth_client, attrs, opts \\ [])

Changeset for creating a client, where the owner (:user_id) is settable.

Lightning.OauthClients authorises every write by asking who owns the client, so an update that could move :user_id would let the owner hand the client, and the secret they already know, to another person's account. Same split as Lightning.Credentials.Credential.