ObanPowertools.Auth behaviour (oban_powertools v0.5.0)

Copy Markdown View Source

Defines the strict Auth behaviour for Oban Powertools.

Summary

Callbacks

Returns the stable principal envelope used for durable audit attribution.

Returns an explicit authorization outcome for the actor, action, and resource.

Returns the current actor from the connection or socket.

Functions

Compatibility shim for older mutation services that still accept only an actor id.

Normalizes the stable principal envelope used for durable audit attribution.

Returns the configured host auth module, if any.

Returns the explicit authorization outcome from the configured host auth module. Falls back to the legacy boolean callback when needed.

Compatibility shim for older boolean call sites. New code should use authorization_outcome/3.

Resolves the current actor through the configured host auth module.

Callbacks

audit_principal(actor)

@callback audit_principal(actor :: any()) :: map() | nil

Returns the stable principal envelope used for durable audit attribution.

authorize(actor, action, resource)

@callback authorize(actor :: any(), action :: atom(), resource :: any()) ::
  :ok | {:error, term()}

Returns an explicit authorization outcome for the actor, action, and resource.

current_actor(arg1)

@callback current_actor(Plug.Conn.t() | map()) :: any()

Returns the current actor from the connection or socket.

Functions

actor_id(actor)

Compatibility shim for older mutation services that still accept only an actor id.

audit_principal(actor)

Normalizes the stable principal envelope used for durable audit attribution.

auth_module(opts \\ [])

Returns the configured host auth module, if any.

auth_module!(opts \\ [])

authorization_outcome(actor, action, resource)

Returns the explicit authorization outcome from the configured host auth module. Falls back to the legacy boolean callback when needed.

authorize(actor, action, resource)

Compatibility shim for older boolean call sites. New code should use authorization_outcome/3.

current_actor(conn_or_socket_or_session)

Resolves the current actor through the configured host auth module.