Implementing "Login with GitHub" on a GitHub Pages static site

Viewed 1770

I'm trying to write a website that can be hosted a static site on GitHub Pages, that will support a "Login with GitHub" option.

The user credentials will then be used to access and contribute to the repository that the GitHub Pages website is based on, thereby allowing it to act somewhat as though it were a non-static site.

I want, if at all possible, to avoid hosting anything anywhere other than GitHub.

I believe that what I need to use is an OAuth app, and I've found the documentation here.

The problem I'm having lies in the client secret required by an OAuth app. Being a secret, I obviously can't store this in the static site's repository.

Is there some way around this? A way to implement "Login with GitHub" without requiring a client secret, or a place to store the client secret in some sort of secure fashion?

1 Answers

You can try the github-secret-keeper. It is a small microservice written in node.js for enabling static, server-less applications to log in using GitHub. This microservice lets you create a single service that knows about all client IDs and secrets making it possible to register an app for each environment you need to test in (for example, staging, production).

Demo implementation is available here.

Related