@arcote.tech/arc-auth 0.8.4 → 0.8.6
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcote.tech/arc-auth",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.6",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Reusable authentication module for Arc framework — aggregate-based auth with factory pattern",
|
|
7
7
|
"main": "./src/index.ts",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"type-check": "tsc --noEmit"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"@arcote.tech/arc": "^0.8.
|
|
14
|
-
"@arcote.tech/platform": "^0.8.
|
|
13
|
+
"@arcote.tech/arc": "^0.8.6",
|
|
14
|
+
"@arcote.tech/platform": "^0.8.6",
|
|
15
15
|
"react": "^18.0.0 || ^19.0.0",
|
|
16
16
|
"typescript": "^5.0.0"
|
|
17
17
|
},
|
|
@@ -2,14 +2,13 @@ import { route } from "@arcote.tech/arc";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Publiczny route wylogowania — wygasza serwerowe cookie sesji `arc_token`
|
|
5
|
-
* (ustawiane przez OAuth callback
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* upgrade'u `/ws`), więc bez tego po wylogowaniu sesja trwała dalej.
|
|
5
|
+
* (scope default; ustawiane przez OAuth callback). Symetryczny do logowania.
|
|
6
|
+
* Scoped-cookie (`arc_token_<scope>`) czyści klient przez `AuthAdapter.clear()`;
|
|
7
|
+
* tu domykamy `arc_token`, którego pierwszy render po redirect mógł użyć.
|
|
9
8
|
*
|
|
10
9
|
* Publiczny (logout nie może wymagać auth). Czyszczenie nieistniejącego cookie
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* jest no-opem. Atrybuty (Path=/) muszą pokrywać się z ustawieniem, żeby
|
|
11
|
+
* przeglądarka dopasowała cookie do usunięcia.
|
|
13
12
|
*/
|
|
14
13
|
export function createLogoutRoute() {
|
|
15
14
|
return route("authLogout")
|
|
@@ -20,7 +19,7 @@ export function createLogoutRoute() {
|
|
|
20
19
|
const headers = new Headers();
|
|
21
20
|
headers.append(
|
|
22
21
|
"Set-Cookie",
|
|
23
|
-
"arc_token=;
|
|
22
|
+
"arc_token=; SameSite=Lax; Path=/; Max-Age=0",
|
|
24
23
|
);
|
|
25
24
|
return new Response(null, { status: 204, headers });
|
|
26
25
|
},
|
|
@@ -302,12 +302,18 @@ export function createOAuthRoutes(data: OAuthRoutesData) {
|
|
|
302
302
|
const targetUrl = new URL(decodedRedirect, baseUrl);
|
|
303
303
|
targetUrl.searchParams.set("token", jwtToken);
|
|
304
304
|
|
|
305
|
-
// Set auth cookie + clear state cookie
|
|
305
|
+
// Set auth cookie + clear state cookie.
|
|
306
|
+
// NIE HttpOnly — od standardu „tokeny w cookie" klient CZYTA token
|
|
307
|
+
// (buduje X-Arc-Tokens/Authorization, WS scope:auth, params scope'a),
|
|
308
|
+
// a serwer czyta cookie przy `GET /` by spersonalizować HTML (manifest
|
|
309
|
+
// + preloady). Ten `arc_token` (scope default) pokrywa pierwszy render
|
|
310
|
+
// zaraz po redirect OAuth; potem klient z `?token=` ustawia własne
|
|
311
|
+
// scoped-cookie przez AuthAdapter. Ta sama ekspozycja XSS co reszta.
|
|
306
312
|
const response = Response.redirect(targetUrl.toString(), 302);
|
|
307
313
|
const headers = new Headers(response.headers);
|
|
308
314
|
headers.append(
|
|
309
315
|
"Set-Cookie",
|
|
310
|
-
`arc_token=${encodeURIComponent(jwtToken)};
|
|
316
|
+
`arc_token=${encodeURIComponent(jwtToken)}; SameSite=Lax; Path=/; Max-Age=604800`,
|
|
311
317
|
);
|
|
312
318
|
headers.append(
|
|
313
319
|
"Set-Cookie",
|