@c9up/warden 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/strategies/SessionStrategy.d.ts +48 -1
- package/dist/strategies/SessionStrategy.d.ts.map +1 -1
- package/dist/strategies/SessionStrategy.js +70 -4
- package/dist/strategies/SessionStrategy.js.map +1 -1
- package/index.darwin-arm64.node +0 -0
- package/index.darwin-x64.node +0 -0
- package/index.linux-arm64-gnu.node +0 -0
- package/index.linux-x64-gnu.node +0 -0
- package/index.win32-x64-msvc.node +0 -0
- package/package.json +2 -2
- package/src/strategies/SessionStrategy.ts +121 -4
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { AuthClientResponse, AuthResult, AuthStrategy, UserPayload } from "../AuthManager.js";
|
|
10
10
|
import { type RememberMeTokenDriver } from "../RememberMeToken.js";
|
|
11
|
+
import type { TokenBlacklist } from "../TokenBlacklist.js";
|
|
11
12
|
export interface SessionStore {
|
|
12
13
|
get(key: string): unknown;
|
|
13
14
|
/**
|
|
@@ -26,6 +27,20 @@ export interface SessionStore {
|
|
|
26
27
|
* directly so this is wired automatically.
|
|
27
28
|
*/
|
|
28
29
|
regenerate(): void;
|
|
30
|
+
/**
|
|
31
|
+
* The session's lifetime in seconds, which a revocation has to outlast.
|
|
32
|
+
* Ream's `Session` carries it; another store may leave it out and set
|
|
33
|
+
* `sessionAge` instead.
|
|
34
|
+
*/
|
|
35
|
+
readonly config?: {
|
|
36
|
+
readonly ttl: number;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Whether ending the session on the server ends every copy of it. Ream's
|
|
40
|
+
* `Session` answers `false` under the cookie store; a store that leaves it
|
|
41
|
+
* out is taken to keep its sessions on the server.
|
|
42
|
+
*/
|
|
43
|
+
readonly revocable?: boolean;
|
|
29
44
|
}
|
|
30
45
|
export interface SessionStrategyConfig {
|
|
31
46
|
sessionKey?: string;
|
|
@@ -53,6 +68,32 @@ export interface SessionStrategyConfig {
|
|
|
53
68
|
* rides a cross-site POST unless the app says so here.
|
|
54
69
|
*/
|
|
55
70
|
rememberMeCookie?: RememberMeCookieAttributes;
|
|
71
|
+
/**
|
|
72
|
+
* Revoke each sign-in at logout, as `JwtStrategy`'s `blacklist` revokes a
|
|
73
|
+
* token: every login gets an id, logout lists it until every copy of the
|
|
74
|
+
* session has expired, and a session carrying a listed id is signed out.
|
|
75
|
+
*
|
|
76
|
+
* What makes a logout hold under the COOKIE session driver, where the
|
|
77
|
+
* session lives in the browser and nothing on the server can delete it — a
|
|
78
|
+
* copy taken before the logout, or a request that was running across it and
|
|
79
|
+
* re-sent the signed-in cookie after, would otherwise be signed in still.
|
|
80
|
+
* The server-side drivers do not need it: logout rotates the session id and
|
|
81
|
+
* a request still in flight cannot write the old entry back.
|
|
82
|
+
*
|
|
83
|
+
* NAMED DEVIATION: upstream's session guard has no revocation; its cookie
|
|
84
|
+
* store has both holes.
|
|
85
|
+
*/
|
|
86
|
+
blacklist?: TokenBlacklist;
|
|
87
|
+
/**
|
|
88
|
+
* Session lifetime in SECONDS, when the session does not carry it (Ream's
|
|
89
|
+
* does). A revocation is kept for twice this, so it outlives the cookie a
|
|
90
|
+
* request running across the logout re-issued: Ream's cookie store dates
|
|
91
|
+
* that cookie from when the request read the session, so it ends within one
|
|
92
|
+
* lifetime of the logout, however long the request ran. A store that dated
|
|
93
|
+
* it from the response would need a listing kept as long as its slowest
|
|
94
|
+
* request.
|
|
95
|
+
*/
|
|
96
|
+
sessionAge?: number;
|
|
56
97
|
}
|
|
57
98
|
/** What an app may set on the remember-me cookie. */
|
|
58
99
|
export interface RememberMeCookieAttributes {
|
|
@@ -170,7 +211,13 @@ export declare class SessionStrategy implements AuthStrategy {
|
|
|
170
211
|
*/
|
|
171
212
|
authenticateAsClient(user: UserPayload): AuthClientResponse;
|
|
172
213
|
/**
|
|
173
|
-
* Logout — remove the user id from the session.
|
|
214
|
+
* Logout — remove the user id from the session, and rotate its id.
|
|
215
|
+
*
|
|
216
|
+
* Rotating is the named deviation (upstream only forgets the key): the old
|
|
217
|
+
* id is what a request still running holds, and with the old entry gone it
|
|
218
|
+
* has nothing to write its signed-in copy back to. A copy of the old id
|
|
219
|
+
* points at nothing either. With a `blacklist`, the sign-in is also listed,
|
|
220
|
+
* which is what holds under the cookie driver.
|
|
174
221
|
*
|
|
175
222
|
* The remember-me token is revoked separately through
|
|
176
223
|
* {@link revokeRememberMeToken}, because only the caller holds the cookie.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionStrategy.d.ts","sourceRoot":"","sources":["../../src/strategies/SessionStrategy.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"SessionStrategy.d.ts","sourceRoot":"","sources":["../../src/strategies/SessionStrategy.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EACX,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,WAAW,EACX,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAGN,KAAK,qBAAqB,EAE1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,MAAM,WAAW,YAAY;IAC5B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B;;;;;OAKG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IACvC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;;;;;OAMG;IACH,UAAU,IAAI,IAAI,CAAC;IACnB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CAC7B;A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AAK,CAAC,EAAE,iBAAiB,GACvB,OAAO,CAAC,IAAI,CAAC;IAYhB;;;;;;OAMG;IACH,oBAAoB,CAAC,IAAI,EAAE,WAAW,GAAG,kBAAkB;IAS3D;;;;;;;;;;;OAWG;IACG,MAAM,CACX,OAAO,EAAE,YAAY,EACrB,KAAK,CAAC,EAAE,iBAAiB,GACvB,OAAO,CAAC,IAAI,CAAC;CAiBhB"}
|
|
@@ -6,8 +6,11 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @implements MISS-7
|
|
8
8
|
*/
|
|
9
|
+
import { randomUUID } from "node:crypto";
|
|
9
10
|
import { WardenError } from "../errors.js";
|
|
10
11
|
import { decodeTokenValue, mintRememberMeToken, verifyAndRecycleRememberMeToken, } from "../RememberMeToken.js";
|
|
12
|
+
/** Ream's default session lifetime, two hours. */
|
|
13
|
+
const DEFAULT_SESSION_AGE_SECONDS = 7200;
|
|
11
14
|
/** Two years, Adonis' `rememberMeTokensAge` default. */
|
|
12
15
|
const DEFAULT_REMEMBER_AGE_SECONDS = 63_072_000;
|
|
13
16
|
/** A fresh set of per-request flags, all false. */
|
|
@@ -29,6 +32,11 @@ export class SessionStrategy {
|
|
|
29
32
|
if (age !== undefined && (!Number.isSafeInteger(age) || age <= 0)) {
|
|
30
33
|
throw new WardenError("INVALID_CONFIG", `rememberMeAge must be a positive whole number of seconds, got ${String(age)}`);
|
|
31
34
|
}
|
|
35
|
+
const sessionAge = config.sessionAge;
|
|
36
|
+
if (sessionAge !== undefined &&
|
|
37
|
+
(!Number.isSafeInteger(sessionAge) || sessionAge <= 0)) {
|
|
38
|
+
throw new WardenError("INVALID_CONFIG", `sessionAge must be a positive whole number of seconds, got ${String(sessionAge)}`);
|
|
39
|
+
}
|
|
32
40
|
this.#config = config;
|
|
33
41
|
this.#sessionKey = config.sessionKey ?? "auth_user_id";
|
|
34
42
|
}
|
|
@@ -136,6 +144,12 @@ export class SessionStrategy {
|
|
|
136
144
|
return { authenticated: false, error: "No session user" };
|
|
137
145
|
if (typeof userId !== "string" && typeof userId !== "number")
|
|
138
146
|
return { authenticated: false, error: "Invalid session data" };
|
|
147
|
+
if (await this.#revoked(context.session)) {
|
|
148
|
+
// Forgotten, not just refused: a cookie session re-sent as it came in
|
|
149
|
+
// would carry the revoked sign-in on, and outlive its listing.
|
|
150
|
+
this.#unseat(context.session);
|
|
151
|
+
return { authenticated: false, error: "Session revoked" };
|
|
152
|
+
}
|
|
139
153
|
const user = await this.#config.findUser(userId);
|
|
140
154
|
if (!user)
|
|
141
155
|
return { authenticated: false, error: "User not found" };
|
|
@@ -165,8 +179,18 @@ export class SessionStrategy {
|
|
|
165
179
|
* exists to report.
|
|
166
180
|
*/
|
|
167
181
|
seatSession(user, session) {
|
|
182
|
+
if (session.revocable === false && !this.#config.blacklist) {
|
|
183
|
+
// Refused rather than signed in: on this store a logout could never
|
|
184
|
+
// hold — a copy of the cookie, or one re-sent by a request running
|
|
185
|
+
// across the logout, would stay signed in until it expired.
|
|
186
|
+
throw new WardenError("INVALID_CONFIG", "This session store keeps the session in the browser and cannot revoke a sign-in. Give the session guard a `blacklist`, or use a server-side session store (database, redis).", {
|
|
187
|
+
hint: "new SessionStrategy({ findUser, blacklist: new TokenBlacklist(new RedisBlacklistDriver(client)) })",
|
|
188
|
+
});
|
|
189
|
+
}
|
|
168
190
|
session.regenerate();
|
|
169
191
|
session.put(this.#sessionKey, user.id);
|
|
192
|
+
// What a logout revokes: one sign-in, not the user's every device.
|
|
193
|
+
session.put(this.#signInKey(), randomUUID());
|
|
170
194
|
// A new sign-in has not stepped up yet, whatever the session held before.
|
|
171
195
|
session.forget(this.#mfaKey());
|
|
172
196
|
}
|
|
@@ -182,6 +206,30 @@ export class SessionStrategy {
|
|
|
182
206
|
#mfaKey() {
|
|
183
207
|
return `${this.#sessionKey}_mfa`;
|
|
184
208
|
}
|
|
209
|
+
/** The session key of this sign-in's id, which a logout revokes. */
|
|
210
|
+
#signInKey() {
|
|
211
|
+
return `${this.#sessionKey}_sid`;
|
|
212
|
+
}
|
|
213
|
+
/** Drop every key a sign-in wrote. */
|
|
214
|
+
#unseat(session) {
|
|
215
|
+
session.forget(this.#sessionKey);
|
|
216
|
+
session.forget(this.#mfaKey());
|
|
217
|
+
session.forget(this.#signInKey());
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Whether the blacklist refuses this session's sign-in. A session with no
|
|
221
|
+
* sign-in id is refused too, as `JwtStrategy` refuses a token with no `jti`:
|
|
222
|
+
* it could never be revoked, so letting it through would keep the hole open.
|
|
223
|
+
*/
|
|
224
|
+
async #revoked(session) {
|
|
225
|
+
const blacklist = this.#config.blacklist;
|
|
226
|
+
if (!blacklist)
|
|
227
|
+
return false;
|
|
228
|
+
const signIn = session.get(this.#signInKey());
|
|
229
|
+
if (typeof signIn !== "string" || signIn.length === 0)
|
|
230
|
+
return true;
|
|
231
|
+
return blacklist.isRevoked(signIn);
|
|
232
|
+
}
|
|
185
233
|
async login(user, session, state) {
|
|
186
234
|
this.seatSession(user, session);
|
|
187
235
|
if (state) {
|
|
@@ -201,17 +249,35 @@ export class SessionStrategy {
|
|
|
201
249
|
* the guard's own logic rather than by the test knowing where the id lives.
|
|
202
250
|
*/
|
|
203
251
|
authenticateAsClient(user) {
|
|
204
|
-
return {
|
|
252
|
+
return {
|
|
253
|
+
session: {
|
|
254
|
+
[this.#sessionKey]: user.id,
|
|
255
|
+
[this.#signInKey()]: randomUUID(),
|
|
256
|
+
},
|
|
257
|
+
};
|
|
205
258
|
}
|
|
206
259
|
/**
|
|
207
|
-
* Logout — remove the user id from the session.
|
|
260
|
+
* Logout — remove the user id from the session, and rotate its id.
|
|
261
|
+
*
|
|
262
|
+
* Rotating is the named deviation (upstream only forgets the key): the old
|
|
263
|
+
* id is what a request still running holds, and with the old entry gone it
|
|
264
|
+
* has nothing to write its signed-in copy back to. A copy of the old id
|
|
265
|
+
* points at nothing either. With a `blacklist`, the sign-in is also listed,
|
|
266
|
+
* which is what holds under the cookie driver.
|
|
208
267
|
*
|
|
209
268
|
* The remember-me token is revoked separately through
|
|
210
269
|
* {@link revokeRememberMeToken}, because only the caller holds the cookie.
|
|
211
270
|
*/
|
|
212
271
|
async logout(session, state) {
|
|
213
|
-
session.
|
|
214
|
-
|
|
272
|
+
const signIn = session.get(this.#signInKey());
|
|
273
|
+
if (this.#config.blacklist && typeof signIn === "string") {
|
|
274
|
+
const age = session.config?.ttl ??
|
|
275
|
+
this.#config.sessionAge ??
|
|
276
|
+
DEFAULT_SESSION_AGE_SECONDS;
|
|
277
|
+
await this.#config.blacklist.revoke(signIn, Date.now() + age * 2000);
|
|
278
|
+
}
|
|
279
|
+
this.#unseat(session);
|
|
280
|
+
session.regenerate();
|
|
215
281
|
if (state) {
|
|
216
282
|
state.viaRemember = false;
|
|
217
283
|
state.attemptedViaRemember = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionStrategy.js","sourceRoot":"","sources":["../../src/strategies/SessionStrategy.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"SessionStrategy.js","sourceRoot":"","sources":["../../src/strategies/SessionStrategy.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAOzC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EACN,gBAAgB,EAChB,mBAAmB,EAEnB,+BAA+B,GAC/B,MAAM,uBAAuB,CAAC;AAmC/B,kDAAkD;AAClD,MAAM,2BAA2B,GAAG,IAAI,CAAC;AAgEzC,wDAAwD;AACxD,MAAM,4BAA4B,GAAG,UAAU,CAAC;AAwBhD,mDAAmD;AACnD,MAAM,UAAU,uBAAuB;IACtC,OAAO;QACN,WAAW,EAAE,KAAK;QAClB,oBAAoB,EAAE,KAAK;QAC3B,WAAW,EAAE,KAAK;KAClB,CAAC;AACH,CAAC;AAED,MAAM,OAAO,eAAe;IAC3B,IAAI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ary file
|
package/index.linux-x64-gnu.node
CHANGED
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c9up/warden",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Warden — Authentication & authorization for the Ream framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"@c9up/quasar": "^0.1.0 || ^0.2.0",
|
|
54
|
-
"@c9up/ream": "^0.2.
|
|
54
|
+
"@c9up/ream": "^0.2.28"
|
|
55
55
|
},
|
|
56
56
|
"peerDependenciesMeta": {
|
|
57
57
|
"@c9up/ream": {
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* @implements MISS-7
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
import { randomUUID } from "node:crypto";
|
|
10
11
|
import type {
|
|
11
12
|
AuthClientResponse,
|
|
12
13
|
AuthResult,
|
|
@@ -20,6 +21,7 @@ import {
|
|
|
20
21
|
type RememberMeTokenDriver,
|
|
21
22
|
verifyAndRecycleRememberMeToken,
|
|
22
23
|
} from "../RememberMeToken.js";
|
|
24
|
+
import type { TokenBlacklist } from "../TokenBlacklist.js";
|
|
23
25
|
|
|
24
26
|
export interface SessionStore {
|
|
25
27
|
get(key: string): unknown;
|
|
@@ -39,8 +41,23 @@ export interface SessionStore {
|
|
|
39
41
|
* directly so this is wired automatically.
|
|
40
42
|
*/
|
|
41
43
|
regenerate(): void;
|
|
44
|
+
/**
|
|
45
|
+
* The session's lifetime in seconds, which a revocation has to outlast.
|
|
46
|
+
* Ream's `Session` carries it; another store may leave it out and set
|
|
47
|
+
* `sessionAge` instead.
|
|
48
|
+
*/
|
|
49
|
+
readonly config?: { readonly ttl: number };
|
|
50
|
+
/**
|
|
51
|
+
* Whether ending the session on the server ends every copy of it. Ream's
|
|
52
|
+
* `Session` answers `false` under the cookie store; a store that leaves it
|
|
53
|
+
* out is taken to keep its sessions on the server.
|
|
54
|
+
*/
|
|
55
|
+
readonly revocable?: boolean;
|
|
42
56
|
}
|
|
43
57
|
|
|
58
|
+
/** Ream's default session lifetime, two hours. */
|
|
59
|
+
const DEFAULT_SESSION_AGE_SECONDS = 7200;
|
|
60
|
+
|
|
44
61
|
export interface SessionStrategyConfig {
|
|
45
62
|
sessionKey?: string;
|
|
46
63
|
findUser: (id: string | number) => Promise<UserPayload | null>;
|
|
@@ -67,6 +84,32 @@ export interface SessionStrategyConfig {
|
|
|
67
84
|
* rides a cross-site POST unless the app says so here.
|
|
68
85
|
*/
|
|
69
86
|
rememberMeCookie?: RememberMeCookieAttributes;
|
|
87
|
+
/**
|
|
88
|
+
* Revoke each sign-in at logout, as `JwtStrategy`'s `blacklist` revokes a
|
|
89
|
+
* token: every login gets an id, logout lists it until every copy of the
|
|
90
|
+
* session has expired, and a session carrying a listed id is signed out.
|
|
91
|
+
*
|
|
92
|
+
* What makes a logout hold under the COOKIE session driver, where the
|
|
93
|
+
* session lives in the browser and nothing on the server can delete it — a
|
|
94
|
+
* copy taken before the logout, or a request that was running across it and
|
|
95
|
+
* re-sent the signed-in cookie after, would otherwise be signed in still.
|
|
96
|
+
* The server-side drivers do not need it: logout rotates the session id and
|
|
97
|
+
* a request still in flight cannot write the old entry back.
|
|
98
|
+
*
|
|
99
|
+
* NAMED DEVIATION: upstream's session guard has no revocation; its cookie
|
|
100
|
+
* store has both holes.
|
|
101
|
+
*/
|
|
102
|
+
blacklist?: TokenBlacklist;
|
|
103
|
+
/**
|
|
104
|
+
* Session lifetime in SECONDS, when the session does not carry it (Ream's
|
|
105
|
+
* does). A revocation is kept for twice this, so it outlives the cookie a
|
|
106
|
+
* request running across the logout re-issued: Ream's cookie store dates
|
|
107
|
+
* that cookie from when the request read the session, so it ends within one
|
|
108
|
+
* lifetime of the logout, however long the request ran. A store that dated
|
|
109
|
+
* it from the response would need a listing kept as long as its slowest
|
|
110
|
+
* request.
|
|
111
|
+
*/
|
|
112
|
+
sessionAge?: number;
|
|
70
113
|
}
|
|
71
114
|
|
|
72
115
|
/** What an app may set on the remember-me cookie. */
|
|
@@ -126,6 +169,16 @@ export class SessionStrategy implements AuthStrategy {
|
|
|
126
169
|
`rememberMeAge must be a positive whole number of seconds, got ${String(age)}`,
|
|
127
170
|
);
|
|
128
171
|
}
|
|
172
|
+
const sessionAge = config.sessionAge;
|
|
173
|
+
if (
|
|
174
|
+
sessionAge !== undefined &&
|
|
175
|
+
(!Number.isSafeInteger(sessionAge) || sessionAge <= 0)
|
|
176
|
+
) {
|
|
177
|
+
throw new WardenError(
|
|
178
|
+
"INVALID_CONFIG",
|
|
179
|
+
`sessionAge must be a positive whole number of seconds, got ${String(sessionAge)}`,
|
|
180
|
+
);
|
|
181
|
+
}
|
|
129
182
|
this.#config = config;
|
|
130
183
|
this.#sessionKey = config.sessionKey ?? "auth_user_id";
|
|
131
184
|
}
|
|
@@ -257,6 +310,12 @@ export class SessionStrategy implements AuthStrategy {
|
|
|
257
310
|
if (!userId) return { authenticated: false, error: "No session user" };
|
|
258
311
|
if (typeof userId !== "string" && typeof userId !== "number")
|
|
259
312
|
return { authenticated: false, error: "Invalid session data" };
|
|
313
|
+
if (await this.#revoked(context.session)) {
|
|
314
|
+
// Forgotten, not just refused: a cookie session re-sent as it came in
|
|
315
|
+
// would carry the revoked sign-in on, and outlive its listing.
|
|
316
|
+
this.#unseat(context.session);
|
|
317
|
+
return { authenticated: false, error: "Session revoked" };
|
|
318
|
+
}
|
|
260
319
|
const user = await this.#config.findUser(userId);
|
|
261
320
|
if (!user) return { authenticated: false, error: "User not found" };
|
|
262
321
|
// `mfa` is this SESSION's step-up, whatever `findUser` said (see
|
|
@@ -286,8 +345,22 @@ export class SessionStrategy implements AuthStrategy {
|
|
|
286
345
|
* exists to report.
|
|
287
346
|
*/
|
|
288
347
|
seatSession(user: UserPayload, session: SessionStore): void {
|
|
348
|
+
if (session.revocable === false && !this.#config.blacklist) {
|
|
349
|
+
// Refused rather than signed in: on this store a logout could never
|
|
350
|
+
// hold — a copy of the cookie, or one re-sent by a request running
|
|
351
|
+
// across the logout, would stay signed in until it expired.
|
|
352
|
+
throw new WardenError(
|
|
353
|
+
"INVALID_CONFIG",
|
|
354
|
+
"This session store keeps the session in the browser and cannot revoke a sign-in. Give the session guard a `blacklist`, or use a server-side session store (database, redis).",
|
|
355
|
+
{
|
|
356
|
+
hint: "new SessionStrategy({ findUser, blacklist: new TokenBlacklist(new RedisBlacklistDriver(client)) })",
|
|
357
|
+
},
|
|
358
|
+
);
|
|
359
|
+
}
|
|
289
360
|
session.regenerate();
|
|
290
361
|
session.put(this.#sessionKey, user.id);
|
|
362
|
+
// What a logout revokes: one sign-in, not the user's every device.
|
|
363
|
+
session.put(this.#signInKey(), randomUUID());
|
|
291
364
|
// A new sign-in has not stepped up yet, whatever the session held before.
|
|
292
365
|
session.forget(this.#mfaKey());
|
|
293
366
|
}
|
|
@@ -306,6 +379,31 @@ export class SessionStrategy implements AuthStrategy {
|
|
|
306
379
|
return `${this.#sessionKey}_mfa`;
|
|
307
380
|
}
|
|
308
381
|
|
|
382
|
+
/** The session key of this sign-in's id, which a logout revokes. */
|
|
383
|
+
#signInKey(): string {
|
|
384
|
+
return `${this.#sessionKey}_sid`;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/** Drop every key a sign-in wrote. */
|
|
388
|
+
#unseat(session: SessionStore): void {
|
|
389
|
+
session.forget(this.#sessionKey);
|
|
390
|
+
session.forget(this.#mfaKey());
|
|
391
|
+
session.forget(this.#signInKey());
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Whether the blacklist refuses this session's sign-in. A session with no
|
|
396
|
+
* sign-in id is refused too, as `JwtStrategy` refuses a token with no `jti`:
|
|
397
|
+
* it could never be revoked, so letting it through would keep the hole open.
|
|
398
|
+
*/
|
|
399
|
+
async #revoked(session: SessionStore): Promise<boolean> {
|
|
400
|
+
const blacklist = this.#config.blacklist;
|
|
401
|
+
if (!blacklist) return false;
|
|
402
|
+
const signIn = session.get(this.#signInKey());
|
|
403
|
+
if (typeof signIn !== "string" || signIn.length === 0) return true;
|
|
404
|
+
return blacklist.isRevoked(signIn);
|
|
405
|
+
}
|
|
406
|
+
|
|
309
407
|
async login(
|
|
310
408
|
user: UserPayload,
|
|
311
409
|
session: SessionStore,
|
|
@@ -330,11 +428,22 @@ export class SessionStrategy implements AuthStrategy {
|
|
|
330
428
|
* the guard's own logic rather than by the test knowing where the id lives.
|
|
331
429
|
*/
|
|
332
430
|
authenticateAsClient(user: UserPayload): AuthClientResponse {
|
|
333
|
-
return {
|
|
431
|
+
return {
|
|
432
|
+
session: {
|
|
433
|
+
[this.#sessionKey]: user.id,
|
|
434
|
+
[this.#signInKey()]: randomUUID(),
|
|
435
|
+
},
|
|
436
|
+
};
|
|
334
437
|
}
|
|
335
438
|
|
|
336
439
|
/**
|
|
337
|
-
* Logout — remove the user id from the session.
|
|
440
|
+
* Logout — remove the user id from the session, and rotate its id.
|
|
441
|
+
*
|
|
442
|
+
* Rotating is the named deviation (upstream only forgets the key): the old
|
|
443
|
+
* id is what a request still running holds, and with the old entry gone it
|
|
444
|
+
* has nothing to write its signed-in copy back to. A copy of the old id
|
|
445
|
+
* points at nothing either. With a `blacklist`, the sign-in is also listed,
|
|
446
|
+
* which is what holds under the cookie driver.
|
|
338
447
|
*
|
|
339
448
|
* The remember-me token is revoked separately through
|
|
340
449
|
* {@link revokeRememberMeToken}, because only the caller holds the cookie.
|
|
@@ -343,8 +452,16 @@ export class SessionStrategy implements AuthStrategy {
|
|
|
343
452
|
session: SessionStore,
|
|
344
453
|
state?: SessionGuardState,
|
|
345
454
|
): Promise<void> {
|
|
346
|
-
session.
|
|
347
|
-
|
|
455
|
+
const signIn = session.get(this.#signInKey());
|
|
456
|
+
if (this.#config.blacklist && typeof signIn === "string") {
|
|
457
|
+
const age =
|
|
458
|
+
session.config?.ttl ??
|
|
459
|
+
this.#config.sessionAge ??
|
|
460
|
+
DEFAULT_SESSION_AGE_SECONDS;
|
|
461
|
+
await this.#config.blacklist.revoke(signIn, Date.now() + age * 2000);
|
|
462
|
+
}
|
|
463
|
+
this.#unseat(session);
|
|
464
|
+
session.regenerate();
|
|
348
465
|
if (state) {
|
|
349
466
|
state.viaRemember = false;
|
|
350
467
|
state.attemptedViaRemember = false;
|