AshAuthentication.Oauth2Server.AuthorizationCodeResource (ash_authentication_oauth2_server v0.2.1)

Copy Markdown View Source

Resource extension for OAuth 2.1 authorization-code rows.

Adds an auto-generated :expunge_expired destroy action and exposes configuration for the AshAuthentication.Oauth2Server.Expunger GenServer, which periodically removes:

  • rows whose expires_at has passed
  • rows whose consumed_at is older than consumed_grace

Usage

use Ash.Resource,
  extensions: [AshAuthentication.Oauth2Server.AuthorizationCodeResource],
  ...

oauth2_server do
  expunge_interval 1
  consumed_grace 86_400
end

Removing expired records

Add AshAuthentication.Oauth2Server.Supervisor to your application supervision tree; it starts the expunger which scans on each resource's configured interval.

Summary

Functions

Bulk-destroy authorization-code rows that have expired or whose consumed_at is older than the configured consumed_grace.

Functions

expunge_expired(resource, opts \\ [])

@spec expunge_expired(
  Ash.Resource.t(),
  keyword()
) :: :ok | {:error, any()}

Bulk-destroy authorization-code rows that have expired or whose consumed_at is older than the configured consumed_grace.

oauth2_server(body)

(macro)