@adonis-agora/authkit-server 0.68.3 → 0.68.4
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.
|
@@ -69,26 +69,30 @@ function unsignAdonisCookie(signedRaw, appKey, purpose) {
|
|
|
69
69
|
* verificado com `unsignAdonisCookie`. É a forma real quando o host grava via
|
|
70
70
|
* `ctx.response.cookie` num app com assinatura de cookie ligada.
|
|
71
71
|
* 2. Valor cru (hosts que gravem sem encode e sem assinatura).
|
|
72
|
-
* 3. Valor cru URL-decoded (o jar Koa devolve como está no header; os TABs viram `%09`).
|
|
73
72
|
*/
|
|
74
73
|
function parseActiveOrgCookieValue(raw, appKey) {
|
|
75
74
|
if (typeof raw !== 'string' || !raw)
|
|
76
75
|
return null;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
const direct = decodeActiveOrgCookie(raw);
|
|
84
|
-
if (direct)
|
|
85
|
-
return direct;
|
|
76
|
+
// O jar Koa devolve o valor COMO ESTÁ no header, sem URL-decode — e o browser
|
|
77
|
+
// reenvia o cookie exatamente como o host o escreveu, isto é `s%3A<b64>.<hmac>`
|
|
78
|
+
// quando ele é assinado. Normalizar ANTES de decidir o formato é obrigatório:
|
|
79
|
+
// checar `startsWith('s:')` no valor cru nunca casaria.
|
|
80
|
+
let value = raw;
|
|
86
81
|
try {
|
|
87
|
-
|
|
82
|
+
const decoded = decodeURIComponent(raw);
|
|
83
|
+
if (decoded)
|
|
84
|
+
value = decoded;
|
|
88
85
|
}
|
|
89
86
|
catch {
|
|
90
|
-
|
|
87
|
+
// não era URL-encoded; segue com o cru
|
|
88
|
+
}
|
|
89
|
+
if (value.startsWith('s:')) {
|
|
90
|
+
if (!appKey)
|
|
91
|
+
return null;
|
|
92
|
+
const unsigned = unsignAdonisCookie(value, appKey, ACTIVE_ORG_COOKIE);
|
|
93
|
+
return unsigned ? decodeActiveOrgCookie(unsigned) : null;
|
|
91
94
|
}
|
|
95
|
+
return decodeActiveOrgCookie(value);
|
|
92
96
|
}
|
|
93
97
|
/**
|
|
94
98
|
* Lê a org ativa de um contexto Koa (oidc-provider).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonis-agora/authkit-server",
|
|
3
|
-
"version": "0.68.
|
|
3
|
+
"version": "0.68.4",
|
|
4
4
|
"description": "AdonisJS OIDC/OAuth2 provider (Identity Provider) toolkit: ejectable auth server with sessions, rate-limiting, MFA/TOTP, audit log, federated logout and OpenTelemetry metrics.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "dudousxd",
|