You can’t today “passthrough” the Cloudflare-Access two-leg OAuth flow directly into your app’s own OIDC-SSO session — Access lives on *.cloudflareaccess.com and sets its own cookies, so your app still sees you as “not logged in.”
What you can do instead is have Access inject a signed JWT (or header) at the edge, and then teach your app to consume & trust that JWT so it never presents its own login screen.
—
1) Configure your Access Application to emit a JWT header
- In the Zero Trust Dashboard → Access → Applications → Add an application (or edit your existing one).
- Under Session duration pick how long you want a user to stay “logged in.”
- Under Application settings → Token forwarding, turn on JSON Web Token.
- Choose the header name you like (the default is
Cf-Access-Jwt-Assertion).
- Select which claims you’d like (email, groups, etc.).
When a user hits myapp.mydomain.com, Access now:
• Authenticates them via your Google IdP once.
• Issues them an Access JWT.
• Forwards that JWT in the request to your origin.
—
2) Make your app auto-login from the JWT
You now need a tiny bit of code or middleware in your app to:
- Read the incoming JWT from the header (e.g.
Cf-Access-Jwt-Assertion).
- Fetch Cloudflare’s public JWK set to verify the signature:
https://<YOUR_ACCOUNT>.cloudflareaccess.com/cdn-cgi/access/certs
- Parse the payload, extract
email, groups, etc.
- Establish a local session (or auto‐provision a user) so your app never shows its login form.
Here’s a very rough Node/Express example:
const express = require("express");
const jwt = require("jsonwebtoken");
const jwksRsa = require("jwks-rsa");
const app = express();
// 1) Configure a JWKS client pointing at Cloudflare
const client = jwksRsa({
cache: true,
jwksUri: "https://<YOUR_ACCOUNT>.cloudflareaccess.com/cdn-cgi/access/certs"
});
// 2) Middleware to verify the Cf-Access JWT
async function verifyCfAccessJWT(req, res, next) {
const token = req.get("Cf-Access-Jwt-Assertion");
if (!token) return res.status(401).send("No Access JWT");
// a) get the signing key
const decodedHeader = jwt.decode(token, { complete: true });
const kid = decodedHeader.header.kid;
const key = await client.getSigningKey(kid);
const pubkey = key.getPublicKey();
// b) verify
jwt.verify(token, pubkey, { audience: "<YOUR_APP_AUDIENCE>" }, (err, payload) => {
if (err) return res.status(403).send("Invalid Access JWT");
// c) stash the user info
req.user = {
email: payload.email,
name: payload.name,
groups: payload.groups
};
next();
});
}
// 3) Protect your routes
app.use(verifyCfAccessJWT);
app.get("/", (req, res) => {
res.send(`Hello ${req.user.email}, you’re in!`);
});
app.listen(3000, () => console.log("listening on 3000"));
Adjust the above to your language/framework. Once you’ve got this in place, Cloudflare does the heavy lifting of “login with Google,” passes you a signed token, and your app never again shows its own login screen.
—
Alternate (less common) approaches
• If your app itself can be an OIDC client, you could try pointing it at the same Google IdP you’ve configured in Cloudflare Access. In theory you’d get two parallel OAuth sessions with Google, but most apps won’t transparently share the Cloudflare-issued cookie, so you’ll still see two logins.
• Some mature apps/plugins have built-in “Cloudflare Access” integrations (e.g. certain GitLab/Confluence plugins) so you just flip on the header-trust feature instead of rolling your own.
In practice the JWT-injection + header verification flow is the most bullet-proof way today to get true SSO (one click → full access) with Cloudflare Zero Trust + your self-hosted app.