@adonis-agora/authkit-client 0.19.0 → 0.19.1
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.
|
@@ -16,4 +16,10 @@ export async function configure(command) {
|
|
|
16
16
|
AUTHKIT_REDIRECT_URI: `Env.schema.string({ format: 'url', tld: false })`,
|
|
17
17
|
},
|
|
18
18
|
});
|
|
19
|
+
// As rotas não são registradas pelo configure. O caminho é o `registerOidcClient`
|
|
20
|
+
// (startSession/endSession, RP-initiated logout, back-channel); o controller
|
|
21
|
+
// ejetado acima existe só para quem precisa customizar o fluxo.
|
|
22
|
+
command.logger.info('Registre as rotas de sessão em start/routes.ts com registerOidcClient(router) ' +
|
|
23
|
+
"(import { registerOidcClient } from '@adonis-agora/authkit-client'). " +
|
|
24
|
+
'O app/controllers/oidc_session_controller.ts publicado é só para customizar o fluxo.');
|
|
19
25
|
}
|
|
@@ -7,7 +7,7 @@ import { AuthkitClientManager, OidcCallbackError } from '@adonis-agora/authkit-c
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Login, callback and logout written out by hand. If you do not need to customise
|
|
10
|
-
* them,
|
|
10
|
+
* them, registerOidcClient(router) registers the same three routes for you.
|
|
11
11
|
*/
|
|
12
12
|
@inject()
|
|
13
13
|
export default class OidcSessionController {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonis-agora/authkit-client",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.1",
|
|
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.80.
|
|
86
|
+
"@adonis-agora/authkit-server": "0.80.2",
|
|
87
87
|
"@adonis-agora/resilience": "0.3.7",
|
|
88
88
|
"@adonisjs/auth": "10.1.0",
|
|
89
89
|
"@adonisjs/core": "7.5.0",
|
|
@@ -30,8 +30,9 @@ sources:
|
|
|
30
30
|
`@adonis-agora/authkit-client` makes an AdonisJS app consume an OIDC provider (the
|
|
31
31
|
AuthKit IdP or any other) with session-based auth: PKCE authorization-code login,
|
|
32
32
|
locally-validated ID tokens (JWKS), typed `ctx.auth` per request. `configure`
|
|
33
|
-
publishes `config/authkit_client.ts
|
|
34
|
-
|
|
33
|
+
publishes `config/authkit_client.ts` and registers the provider + middleware; the
|
|
34
|
+
login/callback/logout routes come from `registerOidcClient(router)`. (`configure` also
|
|
35
|
+
publishes an `OidcSessionController` stub, only for apps that must customise the flow.)
|
|
35
36
|
|
|
36
37
|
## Setup
|
|
37
38
|
|
|
@@ -58,13 +59,17 @@ export default authkitClientConfig
|
|
|
58
59
|
```ts
|
|
59
60
|
// start/routes.ts
|
|
60
61
|
import router from '@adonisjs/core/services/router'
|
|
61
|
-
import
|
|
62
|
+
import { registerOidcClient } from '@adonis-agora/authkit-client'
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
router
|
|
65
|
-
router.post('/auth/logout', [OidcSessionController, 'logout'])
|
|
64
|
+
// /auth/login, /auth/callback, /auth/logout and /auth/backchannel-logout
|
|
65
|
+
registerOidcClient(router)
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
+
If you wire the scaffolded `OidcSessionController` instead, keep it on the manager:
|
|
69
|
+
`startSession(ctx, tokenSet)` in the callback and `endSession(ctx)` in the logout —
|
|
70
|
+
never a raw `session.put(sessionKey)` / `session.forget(sessionKey)`, which leaves a
|
|
71
|
+
parked impersonation credential alive.
|
|
72
|
+
|
|
68
73
|
Source: `packages/authkit-client/README.md`, `stubs/config/authkit_client.stub`.
|
|
69
74
|
|
|
70
75
|
## Core patterns
|
|
@@ -7,7 +7,7 @@ import { AuthkitClientManager, OidcCallbackError } from '@adonis-agora/authkit-c
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Login, callback and logout written out by hand. If you do not need to customise
|
|
10
|
-
* them,
|
|
10
|
+
* them, registerOidcClient(router) registers the same three routes for you.
|
|
11
11
|
*/
|
|
12
12
|
@inject()
|
|
13
13
|
export default class OidcSessionController {
|