0.3.1 • Published 7 years ago

passport-emploi-store v0.3.1

Weekly downloads
1
License
-
Repository
github
Last release
7 years ago

Passport-PoleEmploi

Passport strategy for authenticating with Emploi Store using OpenID 2.0.

This module lets you authenticate using Pôle Emploi in your Node.js applications. By plugging into Passport, Pôle emploi authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.

Install

$ npm install passport-emploi-store

Usage

Configure Strategy

The Emploi Store authentication strategy authenticates users using a Emploi Store account, which is also an OpenID 2.0 identifier. The strategy requires a validate callback, which accepts this identifier and calls done providing a user. Additionally, options can be supplied to specify a return URL and realm.

passport.use(new EmploiStoreStrategy({
    returnURL: 'http://localhost:3000/auth/emploistore/return',
    realm: '/individu',
    response_type: 'code',
    client_id: 'XXXX',
    scope: 'application_XXXXX%20api_authentificationindividuv1%20openid%20profile%20email',
    state: 'STATE_ID',
    nonce: 'NOOCE'
  },
  function(identifier, done) {
    User.findByOpenID({ openId: identifier }, function (err, user) {
      return done(err, user);
    });
  }
));

Authenticate Requests

Use passport.authenticate(), specifying the 'emploi-store' strategy, to authenticate requests.

For example, as route middleware in an Express application:

app.get('/auth/emploistore',
  passport.authenticate('emploi-store'));

app.get('/auth/emploistore/return', 
  passport.authenticate('emploi-store', { failureRedirect: '/login' }),
  function(req, res) {
    // Successful authentication, redirect home.
    res.redirect('/');
  });

Examples

For a complete, working example, refer to the signon example.

Tests

$ npm install --dev
$ make test

Build Status

License

The MIT License

Copyright (c) 2011-2017 Interactive Object [https://interactive-object.com/](https://interactive-object.com/)