Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
var express = require('express');
var session = require('express-session');
var RedisStore = require('connect-redis')(session);
var Strategy = require('./passport-openidconnect/index').Strategy;
module.exports.configure = function configure(app, passport) {
var identityServer = '';
var auth = {
authorizationURL: identityServer + '/connect/authorize',
tokenURL: identityServer + '/connect/token',
userInfoURL: identityServer + '/connect/userinfo',
clientID: 'spa.eventday',
clientSecret: '^secret',
callbackURL: '/auth/callback',
scope: 'openid email profile offline_access phone manageEvents'
secret: 'bleargh',
resave: false,
saveUninitialized: false,
secure: true,
store: new RedisStore({
host: '',
port: 6379
passport.use(new Strategy(auth, function (iss, sub, profile, jwtClaims, accessToken, refreshToken, params, verified) {
verified(null, Object.assign({}, profile, {token: accessToken}));
passport.serializeUser(function (user, done) {
done(null, {id:, name: user.displayName, token: user.token});
passport.deserializeUser(function (user, done) {
done(null, user);
app.get('/auth/login', passport.authenticate('openidconnect', {}));
app.get('/auth/callback', passport.authenticate('openidconnect', {}),
function (req, res) {
if (!req.user) {
throw new Error('user null');
app.get('/auth/logout',function(req, res){
var token = req.user.token;
var uri = identityServer + '/connect/endsession?id_token=token&post_logout_redirect_uri=';
var express = require('express');
var passport = require('passport');
var bodyParser = require('body-parser');
var auth = require('./auth.config');
var app = express();
app.use(bodyParser.urlencoded({extended: false}));
auth.configure(app, passport);

This comment has been minimized.

Copy link

Astimus commented May 31, 2016

Hello. U did nice job. Many thanks for that big job. I'm a beginner in dealing with passport, OpenID connect and etc. This snippet helped me alot.
But i have error after page with allowing personal information permissions. I have created question on stackoverflow.
Can u help me figure out where is the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.