Skip to content

Commit 73e07bd

Browse files
committed
fix: remove deprecated Session.find upsert behaviour
BREAKING CHANGE: Session.find default upsert behaviour is changed to return a new empty session instead
1 parent ef40f6d commit 73e07bd

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

lib/actions/authorization/resume.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = function getResumeAction(provider, whitelist, resumeRouteName)
1717
throw new SessionNotFound('authorization request has expired');
1818
}
1919

20-
const interactionSession = await provider.Session.find(cookieId, { upsert: false });
20+
const interactionSession = await provider.Session.find(cookieId);
2121
if (!interactionSession) {
2222
throw new SessionNotFound('interaction session not found');
2323
}

lib/models/session.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
const assert = require('assert');
2-
const { deprecate } = require('util');
32

43
const uuid = require('uuid/v4');
54
const hash = require('object-hash');
65

76
const epochTime = require('../helpers/epoch_time');
87
const instance = require('../helpers/weak_cache');
98

10-
const deprecated = deprecate(() => {}, 'Session.find returning new sessions if none is found is deprecated');
11-
129
const NON_REJECTABLE_CLAIMS = new Set(['sub', 'sid', 'auth_time', 'acr', 'amr', 'iss']);
1310
const NON_REJECTABLE_SCOPES = new Set(['openid']);
1411

@@ -169,7 +166,7 @@ module.exports = function getSession(provider) {
169166
return getterSetTransformation(authorization.rejectedClaims);
170167
}
171168

172-
static async find(id, { upsert = true } = {}) {
169+
static async find(id) {
173170
assert(id, 'id must be provided to Session#find');
174171
const data = await getAdapter().find(id);
175172
if (data) {
@@ -180,11 +177,7 @@ module.exports = function getSession(provider) {
180177
return new Session(id, data);
181178
}
182179
}
183-
/* istanbul ignore if */
184-
if (upsert) {
185-
deprecated();
186-
return new Session(id);
187-
}
180+
188181
return undefined;
189182
}
190183

@@ -196,7 +189,7 @@ module.exports = function getSession(provider) {
196189

197190
let session;
198191
if (sessionId) {
199-
session = await this.find(sessionId, { upsert: false });
192+
session = await this.find(sessionId);
200193
}
201194
if (!session) {
202195
sessionId = uuid();

lib/provider.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ async function getInteraction(req, res) {
6161
if (!id) {
6262
throw new SessionNotFound('interaction session id cookie not found');
6363
}
64-
const interaction = await this.Session.find(id, { upsert: false });
64+
const interaction = await this.Session.find(id);
6565
if (!interaction) {
6666
throw new SessionNotFound('interaction session not found');
6767
}

0 commit comments

Comments
 (0)