GithubHelp home page GithubHelp logo

o2r-project / o2r-guestlister Goto Github PK

View Code? Open in Web Editor NEW
0.0 6.0 2.0 580 KB

An OAuth server implementation to allow offline login with o2r-bouncer

License: Apache License 2.0

JavaScript 80.03% CSS 10.81% Shell 1.40% HTML 3.82% Dockerfile 3.94%

o2r-guestlister's Introduction

o2r-guestlister

A Node.js OAuth2 server implementation to allow offline login with o2r-bouncer as part of the o2r reference-implementation. For more information about OAuth2 see the OAUth2 documentation.

Based on the repository https://github.com/gerges-beshay/oauth2orize-examples and the underlying OAuth2 server implementation oauth2orize.

Requirements:

  • nodejs >= 6.2
  • npm

Important Note: this server is not for production but only for development and demonstration, because it exposes passwords (in the config file) and private session cookies via API.

Endpoints

The Oauth2 server implementation allows trying out the o2r reference-implementation without going through the ORCID app registration. It implements the following endpoints:

  • /oauth/authorize Starts an authorization request granting an authorization code.
  • /oauth/login User login: Allows to chose between three different uses with basic, advanced and admin rights.
  • /oauth/token Exchange an authorization code for an access token.
  • /oauth/cookies/<user id> Retrieve the session cookie of test users for automatic upload.

To mimic the ORCID OAuth2 implementation the demo server submits the username and ORCID ID as custom parameters in the response to the access token request.

Demo data

The service creates three test users when starting the service:

  • A basic user with level 100,
  • an editor with level 500,
  • and an admin with level 1000.

The levels are explained in the o2r-web-api entry on user levels.

The demo data makes exploration of the o2r platform with different user roles possible. It can be configured by editing the testUsers object in config/config.js.

Dockerfile

This project includes a Dockerfile which can be built and run with

docker build -t guestlister .
docker run --rm -it -e DEBUG=* guestlister

Environment variables

To ensure the guestlister allows offline login, these values have to match the the o2r-bouncer configuration, i.e. the client ID, client secret, mongodb configuration and the oauth URLs have to be the same.

  • GUESTLISTER_PORT Define on which port guestlister should listen. Defaults to 8383.
  • BOUNCER_PORT Specifies on which port the bouncer is listening. Defaults to 8083.
  • GUESTLISTER_MONGODB Required Location for the mongo db. Defaults to mongodb://localhost:27017/. You will very likely need to change this.
  • GUESTLISTER_MONGODB_DATABASE Which database inside the mongo db should be used. Defaults to muncher.
  • OAUTH_URL_AUTHORIZATION Authorization URL used for the OAuth2 server. Defaults to /oauth/authorize.
  • OAUTH_URL_TOKEN Token URL for the ORCID OAuth2 API. Defaults to /oauth/token.
  • OAUTH_SCOPE Scope for the ORCID API. Defaults to /authenticate.
  • OAUTH_CLIENT_ID Required The client ID for your instance. Defaults to testClient.
  • OAUTH_CLIENT_SECRET Required The client secret for your instance. Defaults to testSecret.

Sessions

Guestlister uses express-session for the session management with connect-ensure-login. It stores its own sessions in a collection named guestlist.

For simplicity, both the bouncer data and guestlister sessions are stored in the same database.

Development

Settings have to be provided as environment variables, either at start time or via the debug configuration of your IDE.

To start guestlister execute the following steps.

Start a mongodb instance:

mkdir /tmp/o2r-mongodb-data
mongod --dbpath /tmp/o2r-mongodb-data

Start the o2r-bouncer:

DEBUG=* npm start

Start the guestlister:

DEBUG=* npm start

You can then start the offline login process by opening http://localhost:8383/oauth/authorize?response_type=code&scope=/authenticate&client_id=testClient&redirect_uri=http://localhost:8083/api/v1/auth/login and select a test user afterwards.

License

o2r guestlister is licensed under Apache License, Version 2.0, see file LICENSE.

Copyright (C) 2018 - o2r project.

The code form oauth2orize-examples is licensed under MIT license; see the copyright notice contained in the files under the lib directory for more information.

o2r-guestlister's People

Contributors

lukaslohoff avatar nuest avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

lukaslohoff nuest

o2r-guestlister's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.