GitHub SSO Setup — Cloudflare Access
This guide configures GitHub OAuth SSO for portal.spwhin.com using Cloudflare Zero Trust Access (free tier supports up to 50 users).
How it works
Browser → portal.spwhin.com → Cloudflare Access (GitHub OAuth check)
↓
Is user in spwhin GitHub org?
✅ Yes → Allow
❌ No → Block
No changes required to the Docusaurus app itself — protection is at the CDN/proxy layer.
Prerequisites
- Domain
spwhin.commanaged by Cloudflare (or proxied through it) - GitHub org:
spwhin - Cloudflare account (free tier works)
portal.spwhin.comalready points to the CloudFront distribution that serves the portal
DNS / traffic flow
Cloudflare Access protects the hostname, while CloudFront serves the static site from S3:
Browser -> Cloudflare Access -> CloudFront -> S3 bucket
Create portal.spwhin.com in Cloudflare as a proxied DNS record pointing at the CloudFront distribution domain before enabling the Access application.
Step 1 — Enable Cloudflare Zero Trust
- Log in to dash.cloudflare.com
- Click Zero Trust in the sidebar
- Choose a team name:
spwhin - Select Free plan
Step 2 — Add GitHub as Identity Provider
- Go to Settings → Authentication → Login methods
- Click Add new → GitHub
- In GitHub, go to Settings → Developer Settings → OAuth Apps → New OAuth App:
- Application name:
SPW HI Portal SSO - Homepage URL:
https://portal.spwhin.com - Callback URL:
https://spwhin.cloudflareaccess.com/cdn-cgi/access/callback
- Application name:
- Copy Client ID and Client Secret back into Cloudflare
- Enable "Proof Key for Code Exchange (PKCE)"
- Save
Step 3 — Create an Access Application
- Go to Access → Applications → Add an application
- Select Self-hosted
- Configure:
- App name:
SPW HI Developer Portal - Subdomain:
portal/ Domain:spwhin.com - Session duration:
24 hours
- App name:
- Click Next
Step 4 — Create an Access Policy
- Policy name:
SPW GitHub Org Members - Action: Allow
- Include rule:
- Selector:
GitHub → Organization - Value:
spwhin
- Selector:
- Save and deploy
Step 5 — Verify
- Open an incognito window →
https://portal.spwhin.com - You should see the Cloudflare Access login screen
- Click Sign in with GitHub
- Authorize → redirected to portal ✅
Members outside the spwhin GitHub org will get a "Access Denied" page.
Adding/Removing Access
Access is entirely managed through GitHub org membership:
- Grant access: Invite to
spwhinGitHub org - Revoke access: Remove from
spwhinGitHub org
No Cloudflare config changes needed.
Cost
| Users | Cost |
|---|---|
| Up to 50 | Free |
| 50+ | $7/user/month (Cloudflare Access) |
For SPW HI's team size, this will remain free for the foreseeable future.