Yes, Cloudflare Zero Trust (specifically Cloudflare Access) can act as an identity provider or, more accurately, facilitate OIDC authentication for your self-hosted applications, but the mechanism isn't exactly like registering with a traditional IdP like Okta, Azure AD, or Keycloak where you typically obtain a client ID and client secret from the IdP for your application.
Here's how it works and the nuances:
- Cloudflare Access as a Gateway: Cloudflare Access acts as a secure gateway or proxy in front of your self-hosted application. It intercepts incoming requests.
- Authentication Enforcement: When a request hits Cloudflare, Access checks if the user is authenticated according to the policies you've configured.
- If the user isn't authenticated, Cloudflare redirects them to authenticate. This authentication can happen via:
- Cloudflare's built-in IdPs: Like email OTP, Google, GitHub, etc.
- An external IdP configured in Cloudflare: Like Azure AD, Okta, SAML, or another OIDC provider.
- Issuing Identity Tokens (OIDC/JWT): Once the user is successfully authenticated (either via Cloudflare's methods or an integrated IdP), Cloudflare Access can generate and issue identity tokens (often JWTs containing OIDC claims like
sub, email, name, groups, etc.) to your application.
- Application Configuration (Trusting Cloudflare): Your self-hosted application needs to be configured to:
- Trust Cloudflare Access as the authentication source.
- Validate the tokens issued by Cloudflare. This typically involves:
- Knowing the Issuer URL: This is usually
https://<your-team-name>.cloudflareaccess.com.
- Fetching Cloudflare's Public Keys (JWKS): Cloudflare provides a JWKS endpoint (e.g.,
https://<your-team-name>.cloudflareaccess.com/.well-known/jwks.json) which your application uses to verify the signature of the JWT issued by Cloudflare.
- Validating standard JWT claims:
iss (issuer), aud (audience - often the app's unique identifier configured in Cloudflare), exp (expiration time), etc.
Key Differences from Traditional OIDC Registration:
- No Client ID/Secret Registration with Cloudflare: You don't typically go to Cloudflare's Zero Trust dashboard to "register" your self-hosted application and receive a unique client ID and client secret from Cloudflare for that specific app.
- Policy-Based Configuration: Instead, you configure policies within Cloudflare Access that define which application (identified by its hostname/path) is protected and who (based on identity provider, email, group membership, etc.) is allowed to access it.
- Cloudflare Provides Issuer & Keys: Cloudflare acts as the issuer of the tokens, and you configure your application to trust this issuer and validate its tokens using the provided JWKS URL.
In Summary:
You can absolutely use Cloudflare Zero Trust to secure your self-hosted apps and leverage OIDC principles for identity assertion. Your application will receive OIDC-compliant JWTs from Cloudflare after successful user authentication via Cloudflare Access. The setup involves configuring policies in Cloudflare and setting up your application to trust and validate tokens issued by Cloudflare's specific issuer URL and JWKS endpoint, rather than performing a traditional OIDC client registration with Cloudflare itself.
You would configure your application's authentication flow to rely on the JWT provided by Cloudflare (often passed via a specific header like CF-Access-JWT or redirect parameters) and validate it.