1.1.4 • Published 6 years ago

viarezo-auth v1.1.4

Weekly downloads
2
License
MIT
Repository
gitlab
Last release
6 years ago

ViaRézo Auth Module

What do this module do

It provides a middleware and a request path to handle oauth2 protocol at ViaRézo, for web servers using Express 4.

Why would I use it ?

Because it is very simple, and very usefull. You won't need mush time to set a ViaRézo Authentication on your website.

How to use it ?

First of all, you need to have a client registered on auth.viarezo.fr, its id and secret. Donc forget to add http://mysite.cs-campus.fr/auth to redirect uri. 1. Include the module in your project : npm install --save viarezo-auth 2. Include this fiew lines in your app :

  • Include these modules needed by viarezo-auth (don't forget to install them) : const bodyParser = require('body-parser'); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })); const session = require('express-session'); app.use(session({ secret: 'yourSecret', resave: false, proxy: true, // Especially if unsing nginx/apache saveUninitialized: true, cookie: { secure: true } }));
  • Include viarezo-auth module : const auth = require("viarezo-auth"); app.use(auth.OAuthMiddleware(config)); app.get('/auth', (req,res)=>auth.AuthCallback(req, res));
  • The most important thing is to give the right configuration to the middleware. config objects looks like : config = { client_id: my_client_id, client_secret: even_more_secret, domain: mysite.cs-campus.fr, }
  1. You can access every information on the user in req.session.user object.

Version history

1.0.0 Allow only full authneticated website

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago