CRCSI Accounts passport strategy
Development based on passport-google-openidconnect package.
This module lets you authenticate using CRCSI Accounts OpenID Connect in your Node.js applications.
Install
$ npm install passport-crcsi-openidconnect
Configure Strategy
The CRCSI OpenIDConnect authentication strategy authenticates users using a CRCSI account
and OpenIDConnect tokens. The strategy requires a verify
callback, which accepts
these credentials and calls done
providing a user, as well as options
specifying a client ID, client secret, and callback URL.
var StrategyCRCSI = require('passport-crcsi-openidconnect').Strategy;
passport.use(new StrategyCRCSI({
endpointURL: "http://accounts.crcsi.com.au"
clientID: CRCSI_CLIENT_ID,
clientSecret: CRCSI_CLIENT_SECRET,
callbackURL: "http://localhost:3000/auth/callback"
},
function(iss, sub, profile, accessToken, refreshToken, done) {
return done(null, profile);
}
));
Options
- endpointURL (Optional) - CRCSI accounts endpoint, Defaults to http://accounts.crcsi.com.au
- clientID (Required) - Client ID for the application. This is required, you can get a clientID when a product is created in CRCSI Accounts
- clientSecret (Required) - Client Secret for the application. This is required, you can get a clientSecret when a product is created in CRCSI Accounts
- callbackURL (Required) - Callback endpoint to pass the authentication information
- scope (Optional) - Claim scopes requested by the application. Should be an array of scopes or space seperated strings. Defaults to ['profile']
- profile - Provides name, first_name, last_name, picture, jobtitle, jobrole, organization
- email - Provides user's email details
- phone - Provides user's phone contact details
- address - Provides user's address details
- subscription - Provides user's subscription details to the application
Authenticate Requests
Use passport.authenticate()
, specifying the 'crcsi-openidconnect'
strategy, to
authenticate requests.
An example application is available provide repository details:
app.get('/auth/crcsi',
passport.authenticate('crcsi-openidconnect'));
app.get('/auth/crcsi/callback',
passport.authenticate('crcsi-openidconnect', { failureRedirect: '/login' }),
function(req, res) {
// Successful authentication, redirect home.
res.redirect('/');
});