@adonis-agora/authkit-client 0.18.5 → 0.18.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.
|
@@ -18,6 +18,13 @@ export function registerOidcClient(router, options = {}) {
|
|
|
18
18
|
const prefix = options.prefix ?? '/auth';
|
|
19
19
|
const passthrough = options.passthroughParams ?? ['audience'];
|
|
20
20
|
const pkceKey = 'authkit_pkce';
|
|
21
|
+
// Todo redirect desta função vai para uma URL que a PRÓPRIA lib monta (authorize,
|
|
22
|
+
// /login, destino do app, end-session). O Adonis encaminha a query string da
|
|
23
|
+
// request atual por padrão (`redirect.forwardQueryString`), então `redirect(dest)`
|
|
24
|
+
// sem o `false` explícito arrasta o `code`/`state`/`iss` do callback para o
|
|
25
|
+
// destino — o app terminava em `/?code=…&state=…&iss=…` depois do login, e o
|
|
26
|
+
// `/auth/login` de um callback falho carregava o code antigo para o authorize
|
|
27
|
+
// seguinte. Nenhum desses redirects deve encaminhar query: o destino já a tem.
|
|
21
28
|
const loginRoute = router.get(`${prefix}/login`, async (ctx) => {
|
|
22
29
|
const manager = await ctx.containerResolver.make('authkit.client');
|
|
23
30
|
const cfg = manager.clientConfig;
|
|
@@ -39,7 +46,7 @@ export function registerOidcClient(router, options = {}) {
|
|
|
39
46
|
codeChallenge: challenge,
|
|
40
47
|
...(Object.keys(extraParams).length ? { extraParams } : {}),
|
|
41
48
|
});
|
|
42
|
-
return ctx.response.redirect(url);
|
|
49
|
+
return ctx.response.redirect(url, false);
|
|
43
50
|
});
|
|
44
51
|
if (options.loginMiddleware)
|
|
45
52
|
loginRoute.use(options.loginMiddleware);
|
|
@@ -53,7 +60,7 @@ export function registerOidcClient(router, options = {}) {
|
|
|
53
60
|
// Callback velho/expirado (state perdido ou code ausente) → recomeça o login.
|
|
54
61
|
if (!pkce || pkce.state !== state || !code) {
|
|
55
62
|
ctx.session?.forget(pkceKey);
|
|
56
|
-
return ctx.response.redirect(`${prefix}/login
|
|
63
|
+
return ctx.response.redirect(`${prefix}/login`, false);
|
|
57
64
|
}
|
|
58
65
|
const tokenSet = await exchangeCode({
|
|
59
66
|
issuer: cfg.issuer,
|
|
@@ -72,10 +79,10 @@ export function registerOidcClient(router, options = {}) {
|
|
|
72
79
|
// 1) Hook do app tem prioridade quando retorna uma rota.
|
|
73
80
|
const hook = await options.afterLogin?.(ctx, identity);
|
|
74
81
|
if (typeof hook === 'string')
|
|
75
|
-
return ctx.response.redirect(hook);
|
|
82
|
+
return ctx.response.redirect(hook, false);
|
|
76
83
|
// 2) Redirect por role global (do token).
|
|
77
84
|
const dest = resolveDestination(identity, options.redirects);
|
|
78
|
-
return ctx.response.redirect(dest);
|
|
85
|
+
return ctx.response.redirect(dest, false);
|
|
79
86
|
})
|
|
80
87
|
.as('auth.callback');
|
|
81
88
|
router
|
|
@@ -95,7 +102,7 @@ export function registerOidcClient(router, options = {}) {
|
|
|
95
102
|
postLogoutRedirectUri,
|
|
96
103
|
clientId: cfg.clientId,
|
|
97
104
|
});
|
|
98
|
-
return ctx.response.redirect(endSessionUrl);
|
|
105
|
+
return ctx.response.redirect(endSessionUrl, false);
|
|
99
106
|
})
|
|
100
107
|
.as('auth.logout');
|
|
101
108
|
if (options.backchannelLogout !== false) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonis-agora/authkit-client",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.6",
|
|
4
4
|
"description": "AdonisJS OIDC/OAuth2 relying-party (client) toolkit: session-based authentication against an OpenID Connect identity provider, with JWT/PAT user resolvers and OpenTelemetry metrics.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "dudousxd",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"jose": "6.2.12"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@adonis-agora/authkit-server": "0.68.
|
|
86
|
+
"@adonis-agora/authkit-server": "0.68.2",
|
|
87
87
|
"@adonis-agora/resilience": "0.3.7",
|
|
88
88
|
"@adonisjs/auth": "10.1.0",
|
|
89
89
|
"@adonisjs/core": "7.5.0",
|