Skip to content

Commit

Permalink
Custom Session Stores
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpatrick committed Feb 9, 2021
1 parent a25f393 commit 7ffdc03
Show file tree
Hide file tree
Showing 7 changed files with 352 additions and 260 deletions.
30 changes: 30 additions & 0 deletions examples/custom-session-store.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const express = require('express');
const { auth } = require('../');

const app = express();
const IN_MEMORY_SESSION = {};

app.use(
auth({
idpLogout: true,
sessionStore: function Store(config) {
return {
get: function get (id, cb) {
console.log('sessionStoreget', {id});
cb(null, IN_MEMORY_SESSION[id]);
},
set: function set (id, data, cb) {
console.log('sessionstoreSave', {id, data});
IN_MEMORY_SESSION[id] = data;
cb();
}
}
}
})
);

app.get('/', (req, res) => {
res.send(`hello ${req.oidc.user.sub}`);
});

module.exports = app;
236 changes: 0 additions & 236 deletions lib/appSession.js

This file was deleted.

1 change: 1 addition & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { defaultState: getLoginState } = require('./hooks/getLoginState');
const isHttps = /^https:/i;

const paramsSchema = Joi.object({
sessionStore: Joi.function().optional(),
secret: Joi.alternatives([
Joi.string().min(8),
Joi.binary().min(8),
Expand Down
Loading

0 comments on commit 7ffdc03

Please sign in to comment.