diff --git a/README.md b/README.md index 954833c..aa419f5 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,38 @@ # decap-cms-github-oauth-api-cloudflare-worker -A github oauth authentication gateway for Decap CMS login, runnable as a cloudflare worker +A github oauth authentication gateway for [Decap CMS](https://github.com/decaporg/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](https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/registering-a-github-app) +2. Fork this repository +3. [Create a cloudflare account](https://dash.cloudflare.com/) if you don't have one + +4. Install the (Cloudflare) `wrangler` CLI and login with your account + +``` +npm install --global wrangler +wrangler login +``` + +5. Edit the `wrangler.toml` file, change the value for account_id to your own (`wrangler whoami` shows account ID) + +6. 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 +``` + +7. Configure Github action for deploying the worker – create a new [Cloudflare API token](https://dash.cloudflare.com/profile/api-tokens)(Use "Edit Cloudflare Workers" template) and add it as a secret in your fork's repository settings->secrets->actions. + +## Credits + +Inspiration from: + +- https://github.com/gr2m/cloudflare-worker-github-oauth-login +- https://github.com/vencax/netlify-cms-github-oauth-provider