Using Authentik as a Relying Party through OAuth sources: understanding the source concept, creating a GitHub, Google, or Discord source from a client ID and secret, binding the source to authentication and enrollment flows, mapping user profiles, and handling existing users.

Throughout phases 3 and 5, Authentik acted as an Identity Provider — issuing tokens and assertions for applications. In episode 16, this role is reversed: Authentik becomes a Relying Party trusting other identity providers. The facility is called a source, and the most common case is OAuth sources — social login with GitHub, Google, or Discord.
What's the point? You still want Authentik to be the single entry point (single source of truth), but users don't need to register new accounts — they log in with the GitHub or Google account they already have. Authentik maps their profile, creates an internal user, and all Authentik-protected applications still use the Authentik session. Social login is just the entry door, not a replacement for Authentik.
Analogy: your building no longer issues its own ID cards. Instead, you accept the national ID (a Google/GitHub account) as proof, record it in an internal guest book, and grant access based on that record.
A source is a connection from an external identity provider to Authentik. Available types:
The focus of this episode: OAuth sources. The concept is always the same: register an OAuth application at the external provider to get a client_id and client_secret, then install them in Authentik.
Take GitHub as an example. On GitHub, open Developer settings → OAuth Apps → New OAuth App, then fill in:
Authentik.https://authentik.example.com/source/oauth/callback/github/Replace github with the source slug. Once registered, GitHub provides a Client ID and Client Secret — these two values are the connection credentials.
Important
The Client Secret is a password-equivalent credential. Never put it in code or a repository. In Authentik, this value is stored in the internal database — just enter it via the UI, no need to store it anywhere else.
In the Admin interface, open Directory → Federation and Social login → Create, choose the source type, then fill in:
For built-in provider types like GitHub, Google, and Discord, the authorization, token, and profile URLs are filled automatically by Authentik — you only enter the key and secret. For Generic OAuth2, you fill in the Authorization URL, Access Token URL, and Profile URL manually, or simply paste the OIDC well-known URL (.well-known/openid-configuration) if the provider supports it.
Once the source is saved, Authentik automatically creates the source's own authentication and enrollment flows, plus an application for that source.
This is the part that determines login behavior. Each source is bound to two flows:
These flows work with user matching rules. Authentik provides these modes:
identifier — matches based on the provider's unique identifier.email_link — a new user with an email matching an internal user is automatically connected (linked).email_deny — a new user whose email is already used by another user is denied.username_link / username_deny — same, but based on username.Users created through a source are stored at the path goauthentik.io/sources/<slug> — you can see this on the user page, and distinguish internal users from source-created users.
Profiles from external providers are mapped to internal users via property mappings. For GitHub, Authentik provides built-in mappings: the username is taken from the login field, the email from GitHub's email list, and the name from name.
For special needs, create a custom mapping. Example of a mapping that marks the user's origin:
return context["source"].slugContext available in source expressions includes source (the source object), oauth_userinfo (the raw profile data from the provider), and token (the OAuth token). Always test the expression with the tester before using it.
Here's the complete flow when a user presses "Login with GitHub":
This whole process uses the flows you learned in phase 2 — the source is only the entry door; what follows is still controlled by Authentik stages and policies.
A common scenario: an organization already has internal users (for example budi@example.com), then adds social login. Without the right rules, the same user could create duplicate accounts.
The solution is the matching mode: choose email_link on the enrollment flow. When a user logs in with GitHub and their email matches the internal user budi@example.com, Authentik links that internal account with the source connection — not creates a new user. Once linked, subsequent logins via GitHub reuse the same account, complete with its groups and policies.
To check or fix connections, open the user page → the Synced users/sources tab and review the existing connections. If an identity conflict occurs (two users with the same email), decide the source of truth and fix it via the UI before enforcing a stricter matching mode.
Tip
Choose the matching mode deliberately: use email_link if you want accounts with the same email automatically linked, and email_deny if conflicting emails must be denied. Avoid accidentally creating duplicate accounts by testing the enrollment flow in a lab before production use.
This episode used Authentik as a Relying Party through OAuth sources: understanding the source concept, creating an OAuth app at an external provider (GitHub/Google/Discord), installing the client ID and secret, binding the source to authentication and enrollment flows, mapping user profiles with property mappings, and handling existing users through matching modes.
The single entry point stays with Authentik — login sources are just an alternative proof of identity. In episode 17, we discuss another source equally important in the enterprise world: the LDAP source, which synchronizes users and groups from OpenLDAP or Active Directory into Authentik. See you there!