Skip to content

A github oauth authentication gateway for Decap CMS login, runnable as a cloudflare worker

License

Notifications You must be signed in to change notification settings

ottmartens/decap-cms-github-oauth-provider-cloudflare

Repository files navigation

decap-cms-github-oauth-api-cloudflare-worker

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.

Setup

  1. Create a github app

  2. Fork this repository

  3. Create a cloudflare account if you don't have one

  4. Install the (Cloudflare) wrangler CLI and login with your account

npm install --global wrangler
wrangler login
  1. Edit the wrangler.toml file, change the value for account_id to your own (wrangler whoami shows account ID)

  2. 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
  1. 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.

  2. Add the following config to you Decap CMS config:

   backend:
     name: github
     repo: <your-repo>
     base_url: <cloudflare-worker-url>

Credits

Inspiration from:

About

A github oauth authentication gateway for Decap CMS login, runnable as a cloudflare worker

Resources

License

Stars

Watchers

Forks