← All posts
Oct 3, 20263 min read

Shipping the Cloudflare Access plugin for Atlassian

cloudflareatlassianssojava

A few years ago I took a contractor gig that looked small on paper: make Jira, Confluence and Bitbucket accept logins that had already been approved by Cloudflare Access, the identity-aware proxy in front of them. Two years of maintaining that plugin later, it’s still one of the projects that taught me the most about authentication in the real world.

The problem

Cloudflare Access sits in front of an internal application and asks every visitor to authenticate with your identity provider first. That’s great — until the app behind it has its own user database and login screens, like every Atlassian product does. Users were effectively logging in twice, and the app had no idea who the proxy had already vouched for.

The answer was a plugin that trusts the signed JWT Cloudflare Access attaches to every request, and maps the identity inside it onto a real Atlassian user account.

How the JWT flow works

Every request that passes through Access carries a JWT signed with your team’s public key. The plugin’s whole job boils down to two steps, done in order, on every request: validate, then match.

Validating the token

Validation is where most of the security lives. The plugin checks the signature against the team’s certificates, enforces the audience (aud) claim for the specific app, and rejects anything expired — all before touching the user database.

// Simplified: verifying an Access JWT in a Jira plugin
public ApplicationUser authenticate(String jwt) {
  var claims = validator.verify(jwt);      // signature + aud + expiry
  var email  = claims.get("email");        // set by Cloudflare Access
  return userManager.getUserByEmail(email); // match against Jira's DB
}

Matching users

Once the token is trusted, the plugin takes the verified email and looks up a user in the Atlassian product’s own database. Match found, the session is created as that user — no password prompt, no second login. No match, and the request is rejected: Access proves who someone is, but it never decides who belongs in the app.

An identity-aware proxy answers “who is this?”. Your app still has to answer “should this person be here?”.

Two years of maintenance

Shipping the first version took weeks. Maintaining it took years, and that’s the part nobody scopes:

  • Tracking Atlassian SDK and platform upgrades across Jira, Confluence and Bitbucket
  • Responding to customer deployments with unexpected identity-provider setups
  • Keeping the verification logic in step with Cloudflare Access as it evolved
  • Doing all of it in the open, on GitHub, with real issues and real users

The same flow later spun off into a sibling plugin for Sentry, with the same logic and requirements adapted to a different host application.

Takeaways

Greenfield projects teach you how to start things. Maintaining someone else’s critical path teaches you how to not break things — which is the rarer skill. If you’re wiring SSO in front of an app with its own user database, keep validation and matching strictly separated. It makes the security review trivial and the code easy to test.