13 minute read

I recently moved my Cloudflare account off a password and an authenticator app and onto Microsoft Entra ID. This post covers why I did it and how, in three phases you can stop between.

Who this is for. A personal or small-business Cloudflare account with one or two admins, including accounts on the Cloudflare Free plan. Everything here works on Free: dashboard SSO has been free on every plan since September 2025, and the Zero Trust organisation it needs can be on the free tier.

If you’re a Cloudflare Enterprise customer, see the note on SCIM at the end.

Out of scope for now: moving all API access to GitHub Actions with environment approvals, so no person holds a long-lived Cloudflare token. I plan to cover that in a separate post.

Why bother with a free account

Whoever controls your Cloudflare account controls your DNS. With that they can:

  • Redirect your site, or just its sign-in pages, by changing one record.
  • Receive your mail by changing the MX records. Password resets and security alerts for that domain go to them.
  • Get a valid TLS certificate for your domain, because certificate authorities accept DNS-based validation.

If the same domain is the email domain for your Microsoft 365, GitHub or registrar accounts, your Cloudflare login is also the recovery path for all of them.

DNS is only part of it. More people now run much of their stack on Cloudflare, often on the free tier, and each service adds to what the same login controls:

  • Workers and Pages run your site and APIs. Changing the code changes what every visitor runs, including your sign-in pages.
  • R2, D1 and KV hold files, databases and configuration. Whoever has the account can read, change or delete that data.
  • Tunnels connect a home lab or internal app to the internet. A new tunnel or route opens a path into your network.
  • Zero Trust Access protects internal apps. Edit a policy and the app is open to anyone.
  • Email Routing forwards mail for your domain, so redirecting one address takes one rule.
  • Registrar holds the domain itself. The account can unlock it and get the transfer code.
  • Workers AI and AI Gateway hold provider keys and run up usage on your bill.

The more of these you use, the more a single Cloudflare login is worth to someone else.

Most personal accounts are protected by a password and a TOTP code stored in the same password manager. The daily laptop also tends to hold wrangler login OAuth grants, API tokens in .env files, and a signed-in dashboard session. An AI coding agent with shell access on that laptop can read all of it.

Before and after: the daily laptop holds every key; afterwards admin access goes through Entra ID with PIM, and the laptop holds nothing

Static version of this diagram

The plan

Phase 1 SSO and clean-up, Phase 2 PIM for Groups, Phase 3 optional advanced controls, and later API access through GitHub Actions

Static version of this diagram

  1. Phase 1: SSO and clean-up. Remove what’s lying around, then make the Cloudflare dashboard sign in through Entra ID. Your old login becomes the break-glass account. Phase 1 on its own already removes most of the risk.
  2. Phase 2: PIM for Groups. Nobody can sign in to Cloudflare until they activate a time-limited group membership.
  3. Phase 3 (optional): advanced controls. Require a phishing-resistant sign-in from a privileged workstation (PAW) or a Global Secure Access compliant network, including for the PIM activation itself.

Phase 1: SSO and clean-up

1. Clean up what already has access

This works on any plan, and you can do it today.

API tokens. Cloudflare has two kinds of token:

Match every token to what uses it: a CI secret, a Terraform workspace, a script. Disable anything you can’t place, and delete it a week later if nothing breaks. The token update API takes status: disabled (send the token’s existing name and policies with it):

curl -X PUT "https://api.cloudflare.com/client/v4/user/tokens/<token-id>" \
  -H "Authorization: Bearer <token with API Tokens edit>" \
  -H "Content-Type: application/json" \
  --data '{"name":"<existing name>","policies":<existing policies>,"status":"disabled"}'

Leave the Workers Builds tokens alone. Cloudflare creates one automatically when you connect a Worker to a Git repository (mine were named <project> build token), and the build fails if it’s deleted or rolled.

For the tokens you keep: one job per token, the narrowest permission and zone, and an expiry. IP filtering is fine for a fixed address but breaks GitHub-hosted runners and serverless callers, whose addresses change.

OAuth grants. Go to Profile → Access Management → Connected Applications and revoke Wrangler, the new cf CLI and anything else. Running Workers and token-based CI keep working.

The daily laptop. Run wrangler logout, delete plaintext tokens (.env files, ~/.wrangler, shell history), and sign the browser out of the dashboard. From now on, don’t run wrangler login or cf auth login on this machine. cf auth login uses a link and a one-time code, the same pattern as device-code phishing.

Sessions. My Profile → Sessions lists your active sessions. Revoke the ones you don’t need, one at a time. There’s no sign-out-everywhere button, and Cloudflare asks for your password first, so do this before you switch to SSO.

2. Create the Entra enterprise app

In the Entra admin center, go to Enterprise applications → New application and add Cloudflare Dashboard from the gallery, or create a non-gallery SAML app.

Under Single sign-on → SAML:

Setting Value
Identifier (Entity ID) https://<team>.cloudflareaccess.com/cdn-cgi/access/callback
Reply URL https://<team>.cloudflareaccess.com/cdn-cgi/access/callback
Name ID user.userprincipalname, format Email address
Additional claim email → user.userprincipalname

<team> is the Zero Trust team name you’ll pick in the next step. If the identifier doesn’t match exactly, Entra returns AADSTS700016.

I used SAML rather than the “Azure AD” option in Cloudflare because that option is OIDC and needs a client secret. SAML only needs Entra’s public signing certificate.

Under Properties, set Assignment required to Yes, then assign your admin accounts. Copy the App Federation Metadata URL.

Add a Conditional Access policy that requires MFA for this app, phishing-resistant if your admins already have security keys or passkeys.

3. Turn on dashboard SSO in Cloudflare

Cloudflare made dashboard SSO free for everyone on 25 September 2025.

  1. Create the Zero Trust organisation. Open Zero Trust from the account home and pick a team name. That gives you <team>.cloudflareaccess.com.
  2. Add Entra as a SAML identity provider. Go to Zero Trust → Integrations → Identity providers → Add new identity provider → SAML. Paste the federation metadata URL so Cloudflare fills in the sign-on URL and certificates and picks up new certificates when Entra rolls them. Set the email attribute to email. (Cloudflare’s SAML reference)
  3. Test it. Cloudflare won’t let you use an identity provider for dashboard SSO until it passes a test.
  4. Enable SSO for the dashboard. Go to Manage Account → Members → Settings (moved there in October 2025). Add your admin email domain, for example admins.contoso.com, add the cloudflare_dashboard_sso=<number> TXT record it gives you, then choose Actions → Enable. The dashboard SSO docs walk through each screen.

Before you move on:

  • Cloudflare asks you to create a backup Account API token with the SSO Connector Edit role, so you can turn SSO off through the API if Entra breaks. I skipped it because the break-glass login in step 5 covers the same failure without a standing token. If you don’t set up break-glass, create the token and keep it offline.
  • Enabling SSO creates an Access application called SSO App with an “allow” policy for your email domain. Don’t delete it. Cloudflare warns that admins lose dashboard access if you do.
  • Turn on 2FA Enforcement. SSO users can’t set up Cloudflare 2FA, so for them MFA comes from Entra. The setting applies to logins outside the SSO domain, such as break-glass.

4. Give the SSO account its role

Entra only decides whether you can sign in. Roles still live in Cloudflare.

In Members, create a member group such as “Prod admins” with the role you need, invite the admin’s UPN, and add it to the group. Cloudflare matches the email in the SAML assertion to that member. Nothing syncs between Entra groups and Cloudflare groups.

If your admin accounts have no mailbox

Mine don’t, on purpose: if an admin identity can receive mail, anything that recovers accounts by email can take it over. That gets in the way twice. Cloudflare invites only arrive by email, and in my case an SSO-only user couldn’t create API tokens until its email was verified.

What I did:

  • The admin domain keeps an MX record but has no recipients, so mail to it bounces.
  • When I need to receive one mail, I open a short “mail window”: I make the admin a forwarding mail user, receive the mail, then remove it.
  • To skip the invite email, sign in through SSO, create a short-lived user token with User → Memberships → Edit, find the pending membership with GET /memberships?status=pending, and accept it with PUT /memberships/<id> and {"status":"accepted"} (API reference). Then delete the token.

Two traps: Microsoft 365 Business Premium includes Exchange Online, so admin accounts get a mailbox unless you turn the Exchange Online app off in the licence. And don’t onboard a Microsoft 365 mail domain to Cloudflare Email Routing, because Email Routing needs Cloudflare’s MX records.

5. Turn the old login into break-glass

Your original Cloudflare login, with a password, is now the way back in if Entra or the SSO set-up breaks.

Break-glass path: offline password, two security keys and backup codes, an emergency member outside the SSO domain, Cloudflare login, Super Administrator

Static version of this diagram

  • Keep its email outside the SSO domain, otherwise SSO applies to it too.
  • Keep it as Super Administrator.
  • Register two security keys and nothing else. Remove the daily keys and the authenticator app.
  • Regenerate the backup codes and change the password. Store both offline, not in your daily password manager, and remove any saved Cloudflare passwords from your browsers.
  • If it signs in with Google, you can’t unlink that yet, but Cloudflare still asks for its own 2FA afterwards. Put that Google account in Advanced Protection, because it receives Cloudflare’s recovery mail.
  • Test it every quarter: sign in, check the login events in the audit log, sign out.

At the end of phase 1, the daily laptop holds nothing for Cloudflare, admins sign in through Entra with MFA, and there’s a tested way back in.

Phase 2: Just-in-time access with PIM for Groups

In phase 1 the admin accounts are always assigned to the app. Phase 2 makes that assignment temporary.

  1. Create a security group, for example sg-cloudflare-admins, and assign the group to the Cloudflare Dashboard app. Remove the direct user assignments.
  2. Manage the group with PIM for Groups and make your admins eligible members. Leave no active members.
  3. In the group’s Member role settings, set the activation maximum duration to about 2 hours, require justification, and turn on activation notifications.

Now, outside an activation, the admin isn’t a member of the group, so Entra refuses the sign-in with AADSTS50105 and Cloudflare never receives a request.

Sign-in flow: privileged workstation, PIM activation, Entra sign-in, SAML assertion, Cloudflare Access, member group and role

Static version of this diagram

The two sides stay separate:

  Lives in Decides
sg-cloudflare-admins (PIM) Entra ID Whether you can sign in, and when
“Prod admins” member group Cloudflare What you can do once signed in

PIM needs Entra ID P2 (or Entra ID Governance) for the admin accounts. Assigning a group to an app needs P1.

Phase 3 (optional): Advanced controls

Phase 3 makes admin access depend on a specific device or network as well as the account.

  • Phishing-resistant sign-in. Use the built-in Phishing-resistant MFA authentication strength in the Conditional Access policy for the app.
  • Authentication context on PIM activation. In the PIM group settings, require a Conditional Access authentication context on activation, and create a policy for that context with the same requirements. Then nobody can even activate from the daily laptop. Scope that policy to the admin accounts, not the PIM group, because the user isn’t a member yet when they activate. Set sign-in frequency to Every time.
  • Only from a privileged workstation. Block the app for admins except from devices that match a device filter, such as device.extensionAttribute1 -eq "PAW". Extension attributes only work on Intune-managed, compliant or hybrid-joined devices, so use block-with-exclusion rather than a positive include. Microsoft’s privileged access devices guidance has the full picture.
  • Or from a compliant network. If you use Global Secure Access, require the compliant network condition instead of, or as well as, the device filter.

Turn each policy on in report-only mode first and check the sign-in logs before enforcing it.

What to watch afterwards

  • Cloudflare audit logs: break-glass sign-ins outside your quarterly test, new API tokens, member or role changes, and SSO changes.
  • Entra sign-in logs for the Cloudflare app: AADSTS50105 failures and Conditional Access blocks.
  • PIM activation alerts: every activation should be one you remember.
  • SAML certificate expiry in Entra: test a sign-in after it rolls.
  • Tokens and Connected Applications: review them during the quarterly break-glass test.
  • The admin mail domain: check it has no recipients after any mail window.

Next: API access through GitHub Actions

After phase 3, the remaining standing access is API tokens. The next step is to stop people holding them at all: keep account tokens only as GitHub Actions secrets, run every Cloudflare change from a workflow, and put production behind an environment with required reviewers. I’ll cover that in a separate post.

Cloudflare Enterprise: use SCIM too

Enterprise accounts can use dashboard SCIM provisioning from Entra to create and remove Cloudflare members and member groups automatically. Membership follows assignment to the Entra app: unassign someone and they’re removed from Cloudflare. Cloudflare also warns that misconfigured SCIM groups can remove all of the account’s Super Administrators, so keep the recovery token they describe and keep break-glass outside SCIM.

SCIM doesn’t suit the setup in this post. With PIM, the group assigned to the app is empty most of the time, so SCIM would remove the admins when an activation ends and add them back a few minutes into the next one. Microsoft’s PIM for Groups guidance handles this with an always-active group for provisioning and an eligible group for privilege. That suits larger teams with their own access reviews and approvals; for a one- or two-person account it’s more set-up than it saves.

I couldn’t find a guide to Cloudflare dashboard SSO with Entra ID. These are the closest:

References