Anvil.Auth.OIDC behaviour (Anvil v0.1.1)
View SourceOIDC (OpenID Connect) authentication behaviour for Anvil.
Defines interface for authenticating labelers via OIDC tokens from identity providers like Auth0, Okta, Keycloak, Google, etc.
Implementations should verify JWT signatures, check expiration, validate issuer, and extract standard OIDC claims.
Summary
Types
Callbacks
@callback authenticate(token(), opts()) :: {:ok, Anvil.Auth.OIDC.Labeler.t()} | {:error, error_reason()}
Authenticates a labeler using an OIDC token.
Returns labeler identity with external_id, email, tenant_id, and default role. Implements just-in-time provisioning - creates labeler on first login.
Options
:tenant_id- Override tenant_id from token claims:role- Override default role (:labeler)
@callback verify_token(token()) :: {:ok, map()} | {:error, error_reason()}
Verifies OIDC token and extracts claims.
Should verify:
- JWT signature using provider's public key
- Token expiration (exp claim)
- Issuer matches expected value (iss claim)
- Audience matches client ID (aud claim)