OAuth2 Provider
The OAuth2 provider enables browser-based sign-in against a generic OAuth2 or OpenID Connect provider. Use it when you need a flexible OIDC-capable provider without relying on a built-in integration such as oauth2.google.
Capabilities
- Authentication: Interactive OAuth2 authorization code flow
- Generic Integration: Works with providers that expose standard OIDC discovery or standard authorization/token endpoints
- Identity Discovery: Builds user identities from an ID token or a compatible
userinfoendpoint - OIDC Discovery: Can derive OAuth2 endpoints from an OIDC discovery document
- Customizable Endpoints: Lets you override discovered endpoints explicitly when needed
Prerequisites
OAuth2 Service Setup
- OAuth2 Service: Access to an OAuth2 or OpenID Connect provider
- Application Registration: Registered application with that provider
- Client Credentials: Client ID and client secret from the provider
- Redirect URI: A redirect URI registered for your agent login callback
Required OAuth2 Configuration
- Authority or Endpoints: Either an OIDC authority URL or explicit authorization and token endpoint URLs
- Client ID: OAuth2 application client identifier
- Client Secret: OAuth2 application client secret
Configuration Options
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
client_id | string | Yes | - | OAuth2 client ID |
client_secret | string | Yes | - | OAuth2 client secret |
authority | string | Yes* | - | OIDC issuer URL or full /.well-known/openid-configuration URL |
auth_url | string | Yes* | Derived from discovery | Explicit authorization endpoint override |
token_url | string | Yes* | Derived from discovery | Explicit token endpoint override |
userinfo_url | string | No | Derived from discovery | Explicit userinfo endpoint override |
username_claim | string | No | preferred_username, then username | Claim copied into user.username |
redirect_url | string | No | - | Default redirect URI if one is not supplied at login time |
scopes | array | No | ["openid"] | Scopes requested during authorization |
* Set either authority, or both auth_url and token_url.
Behavior Notes
- This provider is built around the OAuth2 authorization code flow used for browser login.
- If
authorityis set, the provider fetches the OIDC discovery document lazily at login time and readsauthorization_endpoint,token_endpoint, anduserinfo_endpointfrom it. authorityaccepts either an issuer base URL such ashttps://auth.example.com/realms/demoor a full discovery URL ending in/.well-known/openid-configuration.- Explicit
auth_url,token_url, anduserinfo_urlvalues override the discovered defaults when they are set. - The provider always includes the
openidscope during authorization if it is missing from the requested scope list. - User details are read from the returned
id_tokenwhen present. If no ID token is returned, the provider tries the resolveduserinfoendpoint and finally falls back to deriving one fromtoken_urlby replacing/tokenwith/userinfo. user.usernameis populated fromusername_claimwhen configured. If omitted, the provider triespreferred_usernameand thenusername.- Username is never inferred from the email local-part.
Example Configurations
Generic OAuth2 / OIDC Service
version: "1.0"
providers:
oauth2-service:
name: OAuth2 Service
description: Generic OAuth2 authentication
provider: oauth2
enabled: true
config:
client_id: YOUR_CLIENT_ID
client_secret: YOUR_CLIENT_SECRET
authority: https://auth.example.com
username_claim: preferred_username
redirect_url: https://agent.example.com/auth/callback
scopes:
- openid
- profile
- email
OIDC Discovery With Explicit Overrides
version: "1.0"
providers:
internal-oidc:
name: Internal OIDC
description: OIDC authentication with an internal token and userinfo path override
provider: oauth2
enabled: true
config:
client_id: YOUR_CLIENT_ID
client_secret: YOUR_CLIENT_SECRET
authority: https://auth.example.com/realms/team-a
token_url: https://auth.internal.example.com/realms/team-a/protocol/openid-connect/token
userinfo_url: https://auth.internal.example.com/realms/team-a/protocol/openid-connect/userinfo
scopes:
- openid
- profile
- email
If you only need Google sign-in, prefer oauth2.google, which already includes Google’s endpoint configuration.