@checkstack/auth-backend 0.4.18 → 0.4.19
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/CHANGELOG.md +13 -0
- package/package.json +3 -3
- package/src/router.test.ts +7 -4
- package/src/router.ts +7 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @checkstack/auth-backend
|
|
2
2
|
|
|
3
|
+
## 0.4.19
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 889dd8c: Fix session loss for LDAP and SAML authentication strategies
|
|
8
|
+
|
|
9
|
+
The auth bridge was joining multiple `Set-Cookie` headers into a single comma-separated string, which corrupted cookie attributes. This caused the `session_token` cookie to inherit the 5-minute `maxAge` from the `session_data` cache cookie instead of the intended 7-day expiry. After the cookie expired from the browser, `get-session` returned `null` and all API calls failed with 401.
|
|
10
|
+
|
|
11
|
+
Changed the `createSession` RPC contract to return `setCookies: string[]` (array) instead of `setCookie: string`, and updated LDAP/SAML consumers to use `Headers.append("Set-Cookie", ...)` to set each cookie as a separate header.
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [889dd8c]
|
|
14
|
+
- @checkstack/auth-common@0.6.2
|
|
15
|
+
|
|
3
16
|
## 0.4.18
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@checkstack/auth-backend",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.19",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"checkstack": {
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@checkstack/auth-common": "0.6.1",
|
|
18
|
-
"@checkstack/backend-api": "0.
|
|
18
|
+
"@checkstack/backend-api": "0.12.0",
|
|
19
19
|
"@checkstack/notification-common": "0.2.8",
|
|
20
|
-
"@checkstack/command-backend": "0.1.
|
|
20
|
+
"@checkstack/command-backend": "0.1.19",
|
|
21
21
|
"better-auth": "^1.4.7",
|
|
22
22
|
"drizzle-orm": "^0.45.0",
|
|
23
23
|
"hono": "^4.12.14",
|
package/src/router.test.ts
CHANGED
|
@@ -359,11 +359,12 @@ describe("Auth Router", () => {
|
|
|
359
359
|
|
|
360
360
|
const mockResponse = { sessionId: "session-123" };
|
|
361
361
|
const mockHandler = mock(async (_req: Request) => {
|
|
362
|
+
const headers = new Headers();
|
|
363
|
+
headers.append("Set-Cookie", "better-auth.session_token=test-token; Path=/; HttpOnly; Max-Age=604800");
|
|
364
|
+
headers.append("Set-Cookie", "better-auth.session_data=test-data; Path=/; HttpOnly; Max-Age=300");
|
|
362
365
|
return new Response(JSON.stringify(mockResponse), {
|
|
363
366
|
status: 200,
|
|
364
|
-
headers
|
|
365
|
-
"Set-Cookie": "better-auth.session_token=test-token; Path=/; HttpOnly",
|
|
366
|
-
},
|
|
367
|
+
headers,
|
|
367
368
|
});
|
|
368
369
|
});
|
|
369
370
|
|
|
@@ -386,7 +387,9 @@ describe("Auth Router", () => {
|
|
|
386
387
|
);
|
|
387
388
|
|
|
388
389
|
expect(result.sessionId).toBe("session-123");
|
|
389
|
-
expect(result.
|
|
390
|
+
expect(result.setCookies).toBeArrayOfSize(2);
|
|
391
|
+
expect(result.setCookies[0]).toContain("better-auth.session_token=test-token");
|
|
392
|
+
expect(result.setCookies[1]).toContain("better-auth.session_data=test-data");
|
|
390
393
|
expect(mockHandler).toHaveBeenCalled();
|
|
391
394
|
|
|
392
395
|
// Verify the virtual request headers
|
package/src/router.ts
CHANGED
|
@@ -1106,14 +1106,12 @@ export const createAuthRouter = (
|
|
|
1106
1106
|
});
|
|
1107
1107
|
}
|
|
1108
1108
|
|
|
1109
|
-
// Extract Set-Cookie
|
|
1110
|
-
//
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
if (!setCookie) {
|
|
1109
|
+
// Extract Set-Cookie headers as individual strings (one per cookie)
|
|
1110
|
+
// Using getSetCookie() preserves each cookie separately — joining with commas
|
|
1111
|
+
// corrupts cookie attributes that contain commas (e.g. Expires dates)
|
|
1112
|
+
const setCookies = res.headers.getSetCookie();
|
|
1113
|
+
|
|
1114
|
+
if (setCookies.length === 0) {
|
|
1117
1115
|
const headers: Record<string, string> = {};
|
|
1118
1116
|
// eslint-disable-next-line unicorn/no-array-for-each
|
|
1119
1117
|
res.headers.forEach((value, key) => {
|
|
@@ -1133,7 +1131,7 @@ export const createAuthRouter = (
|
|
|
1133
1131
|
|
|
1134
1132
|
return {
|
|
1135
1133
|
sessionId: body.sessionId,
|
|
1136
|
-
|
|
1134
|
+
setCookies,
|
|
1137
1135
|
};
|
|
1138
1136
|
});
|
|
1139
1137
|
|