Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update Readme to have more info on github oauth app #5

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
Expand All @@ -28,7 +22,8 @@ This project uses [`next/font`](https://nextjs.org/docs/app/building-your-applic

In order to allow collaborators to update the content of the site, this project utilizes [DecapCMS](https://decapcms.org/docs/intro/).
This tool allows content editors to make commits to the site repository without touching code or learning Git. When an editor "publishes" a change,
they are making a push to the specified branch (in this project's case, main).
they are making a push to the specified branch (in this project's case, cms). A Github workflow checks for changes over a specified
period of time and pushes the cms branch to main after a period of inactivity, which triggers a App Hosting rollout.

All configuration options for Decap CMS are specified in a ```config.yml``` file, in the public folder. In order to connect
to Github for authentication without using Netlify's proprietary API, we must specify an authentication endpoint within the
Expand All @@ -37,13 +32,24 @@ config's backend section:
```yaml
name: github
repo: brown-ccv/mmp-next
base_url: https://mmp-docker-974587953292.us-central1.run.app/
base_url: https://mmp-lamp.research.brown.edu/
auth_endpoint: api/auth
```

Within the api folder of the project, we have an auth script and a callback script which utilize [simple-oauth2](https://www.npmjs.com/package/simple-oauth2)
in order to authenticate to Github. This connects to a Github Oauth App created within github's developer settings. Within
this app, the callback url is set to the route of the callback script (https://mmp-docker-974587953292.us-central1.run.app/api/callback).
in order to authenticate to Github. This connects to a Github Oauth App created within github's developer settings.

### Github Oauth App

[Gihub Oauth App Docs](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps)

In order for the web app to authenticate to Github, we utilize a Github Oauth App set up for MMP. Within
this app, the callback url must be set to the route of the callback script (https://mmp-lamp.research.brown.edu/api/callback).

This callback url is accessing the web project's /api route. For the Nextjs pages router, this means accessing the page in
the ```src/pages/api``` folder.

For a user to successfully authenticate, the user must have write access to the mmp-next Github repo.

## Learn More

Expand Down