README
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.
- Include the module in your project :
npm install --save viarezo-auth
- 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, }
- You can access every information on the user in
req.session.user
object.
Version history
1.0.0 Allow only full authneticated website