A github oauth authentication gateway for Decap CMS login, runnable as a cloudflare worker
Use case - you want to use your Github repo as a CMS with Decap CMS, but don't want to rely on Netlify authentication backend. You can host this service on a cloudflare worker to authenticate with Github without a 3rd party.
-
Fork this repository
-
Create a cloudflare account if you don't have one
-
Install the (Cloudflare)
wrangler
CLI and login with your account
npm install --global wrangler
wrangler login
-
Edit the
wrangler.toml
file, change the value for account_id to your own (wrangler whoami
shows account ID) -
Add the following secrets to your Cloudflare worker:
CLIENT_ID
,CLIENT_SECRET
: In your GitHub App's settings page, find the Client ID and generate a Client Secret
wrangler secret put CLIENT_ID
wrangler secret put CLIENT_SECRET
-
Configure Github action for deploying the worker – create a new Cloudflare API token(Use "Edit Cloudflare Workers" template) and add it as a secret in your fork's repository settings->secrets->actions.
-
Add the following config to you Decap CMS config:
backend:
name: github
repo: <your-repo>
base_url: <cloudflare-worker-url>
Inspiration from: