2.2.0 • Published 10 months ago

pub-pkg-google-oauth v2.2.0

Weekly downloads
52
License
MIT
Repository
github
Last release
10 months ago

pub-pkg-google-oauth

installation

This package is included with pub-server. It can be activated by including it as a theme on the command line or in pub-config.

pub -t pub-pkg-google-oauth

credentials

pub-pkg-google-oauth requires the client ID and a client secret to be specified as environment variables GID and GCS respectively.

export GID={client_ID}
export GCS={client_secret}

configuring your app URL endpoint

oauth requires an endpoint for the protocol to redirect to after authenticating. In addition, google will not allow a site to authenticate with oauth unless the site has been registered as a "javascript origin".

If you are using heroku, you can use your heroku app URL for this.

If you are running on your own machine over a local area network (or on wifi), you will need to configure a tunnel service like localtunnel or ngrok so that your server can be reached from the Internet.

npm install -g localtunnel
lt --port 3001 --subdomain {yourname}

In either case, once you know your app URL, you can configure pub-server and pub-pkg-google-auth to use it by setting the APP environment variable. E.g.

export APP=https://{yourname}.localtunnel.me

oauth configuration on google

  • use the google developers console and create project if you don't already have one
  • under Credentials, create a new Client ID (type Web Application)
  • set the Javascript origin to match your app URL
  • set the Redirect URI to {your app url}/server/auth/google/callback npm.io
  • note the new Client ID and Client secret

configuring google email addressses to access pub-server

ACLs are configured using environment variables ACL_ADMIN, ACL_EDIT, and ACL_READ. These contain comma-separated lists of users.

E.g. To grant yourself admin rights, and 3 other users read access:

export ACL_ADMIN={your-email}
export ACL_READ={email-1},{email-2},{email-3}

You can also open public/anonymous access to non-protected pages by running pub -P or setting opts.publicPages

to test locally

  • make sure you have set environment variables GID, GCS, APP, and ACL_ADMIN (or some other ACL_)
  • start localtunnel or similar service
  • start pub-server with google oauth
$ pub -t pub-pkg-google-oauth
  • now point your browser to https://{yourname}.localtunnel.me
  • when running with auth, the default behavior is to require authentication for all pages

  • you should see a login prompt npm.io

  • this will be followed by the google oauth confirmation npm.io

  • if all is well you will then be able to read the markdown page in the directory where pub was launched.

  • if you have not configured the access properly for this email you will see another login prompt npm.io

to disable auth even when this module is included

Set environment variable DISABLE_AUTH to run pub-server without authentication when this package is included.

credits

2.2.0

10 months ago

2.1.3

3 years ago

2.1.2

3 years ago

2.1.1

3 years ago

2.1.0

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.5.3

10 years ago

0.5.2

10 years ago

0.5.1

10 years ago

0.5.0

10 years ago