pub-pkg-github-oauth
v1.2.10
Published
pub-server style plugin for github oauth
Downloads
27
Readme
pub-pkg-github-oauth
NOTE: this package is no longer being maintained
This module provides a pub-server style plugin for github oauth.
It is used by pub-gatekeeper to mediate oauth access, allowing static sites hosted on github pages to be edited from the browser.
flow
Browsers start by checking for an existing oauth access token at
/server/auth/github/status
using JSONP or similar mechanism. The first time they do this, it initiates a session with the pub-gatekeeper server, and the server returns a JSON object with no access_token.To start a new authentication process, browsers then navigate to
/server/auth/github?ref={fully-qualified url}
. Theref
parameter specifies where to direct the browser after authentication. The server will immediately redirect to github's oauth page at https://github.com/login/oauth/authorize. New users will be asked to login, and confirm the scope of the auth request.After the user has confirmed oauth access, github will redirect back to the gatekeeper server at
server/auth/github/callback
. This triggers the 2nd step in the authentication process, in which the server requests a user-specific access token from github.When the response with the access token comes back, the gatekeeper stores this in the browser's session, and then redirects back to the
ref
parameter location from step 1, adding a temporarycode
parameter for fetching the access token.Step 1 is repeated with the temporary code, and this time, the request returns an access token. This token opens the door to perform commits or reads on the user's repo on github.
api
require('pub-pkg-github-oauth')(server);
server.app
: express application used to mount routesserver.opts.github.url
: route prefix defaults to'/server/auth/github'
server.opts.github.timeout
: ms value defaults to'4s'
.server.opts.github.expire
: ms for browser to fetch token
GitHub credentials
GitHub developer application credentials must be exported in the following environment variables.
export GHID={github client ID}
export GHCD={github client secret}