@adonis-agora/authkit-client 0.18.6 → 0.18.8
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.
|
@@ -19,12 +19,14 @@ export function registerOidcClient(router, options = {}) {
|
|
|
19
19
|
const passthrough = options.passthroughParams ?? ['audience'];
|
|
20
20
|
const pkceKey = 'authkit_pkce';
|
|
21
21
|
// Todo redirect desta função vai para uma URL que a PRÓPRIA lib monta (authorize,
|
|
22
|
-
// /login, destino do app, end-session)
|
|
23
|
-
// request atual
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
//
|
|
22
|
+
// /login, destino do app, end-session), então nenhum deve encaminhar a query da
|
|
23
|
+
// request atual. Isso precisa ser o builder `withQs(false)`, NÃO o segundo
|
|
24
|
+
// argumento de `redirect(path, forwardQueryString)`: quando o app liga
|
|
25
|
+
// `redirect.forwardQueryString` no config/app.ts — que é o caso comum — o
|
|
26
|
+
// positional é ignorado e o Redirect herda a config global, encaminhando mesmo
|
|
27
|
+
// assim. Sem o opt-out explícito o `code`/`state`/`iss` do callback vazam para o
|
|
28
|
+
// destino (o app termina em `/?code=…`) e o `/auth/login` de um callback falho
|
|
29
|
+
// arrasta o code antigo para o authorize seguinte.
|
|
28
30
|
const loginRoute = router.get(`${prefix}/login`, async (ctx) => {
|
|
29
31
|
const manager = await ctx.containerResolver.make('authkit.client');
|
|
30
32
|
const cfg = manager.clientConfig;
|
|
@@ -46,7 +48,7 @@ export function registerOidcClient(router, options = {}) {
|
|
|
46
48
|
codeChallenge: challenge,
|
|
47
49
|
...(Object.keys(extraParams).length ? { extraParams } : {}),
|
|
48
50
|
});
|
|
49
|
-
return ctx.response.redirect(
|
|
51
|
+
return ctx.response.redirect().withQs(false).toPath(url);
|
|
50
52
|
});
|
|
51
53
|
if (options.loginMiddleware)
|
|
52
54
|
loginRoute.use(options.loginMiddleware);
|
|
@@ -60,7 +62,7 @@ export function registerOidcClient(router, options = {}) {
|
|
|
60
62
|
// Callback velho/expirado (state perdido ou code ausente) → recomeça o login.
|
|
61
63
|
if (!pkce || pkce.state !== state || !code) {
|
|
62
64
|
ctx.session?.forget(pkceKey);
|
|
63
|
-
return ctx.response.redirect(`${prefix}/login
|
|
65
|
+
return ctx.response.redirect().withQs(false).toPath(`${prefix}/login`);
|
|
64
66
|
}
|
|
65
67
|
const tokenSet = await exchangeCode({
|
|
66
68
|
issuer: cfg.issuer,
|
|
@@ -79,10 +81,10 @@ export function registerOidcClient(router, options = {}) {
|
|
|
79
81
|
// 1) Hook do app tem prioridade quando retorna uma rota.
|
|
80
82
|
const hook = await options.afterLogin?.(ctx, identity);
|
|
81
83
|
if (typeof hook === 'string')
|
|
82
|
-
return ctx.response.redirect(
|
|
84
|
+
return ctx.response.redirect().withQs(false).toPath(hook);
|
|
83
85
|
// 2) Redirect por role global (do token).
|
|
84
86
|
const dest = resolveDestination(identity, options.redirects);
|
|
85
|
-
return ctx.response.redirect(
|
|
87
|
+
return ctx.response.redirect().withQs(false).toPath(dest);
|
|
86
88
|
})
|
|
87
89
|
.as('auth.callback');
|
|
88
90
|
router
|
|
@@ -102,7 +104,7 @@ export function registerOidcClient(router, options = {}) {
|
|
|
102
104
|
postLogoutRedirectUri,
|
|
103
105
|
clientId: cfg.clientId,
|
|
104
106
|
});
|
|
105
|
-
return ctx.response.redirect(
|
|
107
|
+
return ctx.response.redirect().withQs(false).toPath(endSessionUrl);
|
|
106
108
|
})
|
|
107
109
|
.as('auth.logout');
|
|
108
110
|
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.8",
|
|
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",
|
|
@@ -79,11 +79,11 @@
|
|
|
79
79
|
}
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@adonis-agora/authkit-core": "0.
|
|
82
|
+
"@adonis-agora/authkit-core": "0.9.0",
|
|
83
83
|
"jose": "6.2.12"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@adonis-agora/authkit-server": "0.
|
|
86
|
+
"@adonis-agora/authkit-server": "0.74.0",
|
|
87
87
|
"@adonis-agora/resilience": "0.3.7",
|
|
88
88
|
"@adonisjs/auth": "10.1.0",
|
|
89
89
|
"@adonisjs/core": "7.5.0",
|