OAuth source
The OAuth source lets users log in to authentik, and enroll themselves, with an external OAuth-based identity provider. In this setup, authentik is the OAuth client. The generic OAuth source expects the identity provider to return OpenID Connect-compatible information. Vendor-specific implementations have their own OAuth source, and guides for specific identity providers are under External identity providers.
This page covers the OAuth source, where an external identity provider logs users in to authentik. To let an application log users in with authentik as the OAuth 2.0 or OpenID Connect identity provider, use the OAuth2 provider instead.
-
Policies: Allow/Forbid users from linking their accounts with this identity provider.
-
Icon: Optional icon or image shown for the source. See File picker values.
-
Request Token URL: This field is used for OAuth v1 implementations and will be provided by the identity provider.
-
Authorization URL: This value will be provided by the identity provider.
-
Access Token URL: This value will be provided by the identity provider.
-
Profile URL: This URL is called by authentik to retrieve user information upon successful authentication.
-
Consumer key/Consumer secret: These values will be provided by the identity provider.
-
Scopes: Configure additional scopes to send to the identity provider.
Starting with authentik 2022.10, the default scopes can be replaced by prefixing the value for scopes with
*.
OpenID Connect
Well-known
Instead of configuring the URLs for a source manually, if the application you're configuring implements the OpenID Connect Discovery Spec, you can configure the source with a single URL. The URL should always end with .well-known/openid-configuration. Many applications don't explicitly mention this URL, but for most of them it will be https://application.company/.well-known/openid-configuration.
This URL is fetched upon saving the source, and all the URLs will be replaced by the ones from the Discovery document. No automatic re-fetching is done.
JWKS
To simplify machine-to-machine authentication, you can create an OAuth source as a trusted source of JWTs. Create a source and configure either the Well-known URL or the OIDC JWKS URL. You can also manually enter the JWKS data.
Afterward, this source can be selected in one or more OAuth 2.0 providers. Any JWT issued by the configured source's JWKS can authenticate. To learn more about this, see JWT authentication.
login_hint parameter
If the OAuth authentication was started from within an authentik flow and the user has already identified themselves, authentik will set the login_hint parameter to the email address of the user. If the Identification stage has the Pretend user exists option enabled and a user could not be found, the login_hint value will be set to the identifier that the user entered.
OAuth source property mappings
See the overview for information on how property mappings work.
Expression data
The following variables are available to OAuth source property mappings:
info: A Python dictionary containing OAuth claims. For example (values might differ depending on the source):{"iss": "https://source.company","sub": "f153e7da687eec8c8789c72b6cc6bb5197df7b48b263b3151f36908e1bc10691","aud": "01e4DmQiG1d3kaewD3Mkz7E7kXknk9j43eZMkNaE","aud": "a7809c1b1c4aaa50adfb68660a6273dd9c8d15e4","email": "user@authentik.company","email_verified": True,"name": "User","given_name": "User","preferred_username": "user","nickname": "user",}client: The OAuth client for this login. Callclient.do_request(method, url, token=token, **kwargs)to make an authenticated request to the identity provider. It accepts request options such asparamsandheadersand returns arequests.Response. Callraise_for_status()before reading the response if an API error should stop the mapping.token: A Python dictionary containing the OAuth tokens for this login. Pass it toclient.do_requestwhen making an authenticated request.
For example, a user property mapping can retrieve a field that the profile response does not include:
response = client.do_request("GET", "https://source.company/api/user", token=token)
response.raise_for_status()
return {"attributes": {"department": response.json().get("department")}}
Replace the URL and response field with values from your identity provider's API. For a working provider-specific example, see GitHub organization membership.