keycloak-api-manager 6.0.0 → 6.0.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.
- package/OIDC_MIGRATION_PLAN.md +120 -40
- package/README.md +2 -0
- package/docs/api/configuration.md +33 -3
- package/docs/guides/PKCE-Login-Flow.md +159 -0
- package/package.json +1 -1
- package/test-output.log +0 -72
package/OIDC_MIGRATION_PLAN.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# OIDC Methods Migration Plan - keycloak-api-manager
|
|
2
2
|
|
|
3
|
+
## 🚀 Current Status: v6.0.0 - MIGRATION RELEASED
|
|
4
|
+
|
|
5
|
+
✅ **OIDC Methods Deprecated:** All OIDC authentication methods are now marked `@deprecated` in v6.0.0.
|
|
6
|
+
|
|
7
|
+
✅ **keycloak-express-middleware v6.1.0 Released:** OIDC methods now available in middleware package with full test coverage.
|
|
8
|
+
|
|
9
|
+
📅 **Removal Timeline:**
|
|
10
|
+
- **v6.0.0** (NOW) - Methods work but marked @deprecated
|
|
11
|
+
- **v7.0.0** (FUTURE) - Methods will be permanently removed
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
3
15
|
## Overview
|
|
4
16
|
|
|
5
17
|
L'architettura prevede una **migrazione pianificata** dei metodi OIDC (`auth()`, `login()`, `loginPKCE()`) da `keycloak-api-manager` a `keycloak-express-middleware`.
|
|
@@ -12,6 +24,22 @@ L'architettura prevede una **migrazione pianificata** dei metodi OIDC (`auth()`,
|
|
|
12
24
|
- ✅ `generateAuthorizationUrl(options)` - PKCE URL generator
|
|
13
25
|
- ✅ `loginPKCE(credentials)` - PKCE token exchange
|
|
14
26
|
|
|
27
|
+
## Current State (v6.0.0) - NOW
|
|
28
|
+
|
|
29
|
+
**Status Changes in keycloak-api-manager:**
|
|
30
|
+
- ⚠️ `auth(credentials)` - Marked @deprecated
|
|
31
|
+
- ⚠️ `login(credentials)` - Marked @deprecated
|
|
32
|
+
- ⚠️ `generateAuthorizationUrl(options)` - Marked @deprecated
|
|
33
|
+
- ⚠️ `loginPKCE(credentials)` - Marked @deprecated
|
|
34
|
+
|
|
35
|
+
✅ Methods **still work** but show deprecation warnings in JSDoc and IDE.
|
|
36
|
+
|
|
37
|
+
**Status in keycloak-express-middleware v6.1.0:**
|
|
38
|
+
- ✅ `generateAuthorizationUrl(options)` - Fully implemented & tested
|
|
39
|
+
- ✅ `login(credentials)` - Fully implemented & tested
|
|
40
|
+
- ✅ `loginPKCE(credentials)` - Fully implemented & tested
|
|
41
|
+
- ✅ All 21 tests passing
|
|
42
|
+
|
|
15
43
|
## Why This Migration?
|
|
16
44
|
|
|
17
45
|
### Separation of Concerns
|
|
@@ -45,49 +73,80 @@ keycloak-express-middleware (User Authentication)
|
|
|
45
73
|
- [x] Write comprehensive tests (21 tests, all passing)
|
|
46
74
|
- [x] Document integration guide
|
|
47
75
|
- [x] Commit to middleware repo
|
|
76
|
+
- [x] Integrate OIDC methods into keycloak-express-middleware v6.1.0
|
|
77
|
+
- [x] Release keycloak-express-middleware v6.1.0 to npm
|
|
78
|
+
|
|
79
|
+
**Status:** ✅ COMPLETE & RELEASED
|
|
80
|
+
|
|
81
|
+
### Phase 2: ✅ DONE (Done)
|
|
82
|
+
- [x] Mark methods as @deprecated in keycloak-api-manager index.js
|
|
83
|
+
- [x] Update README with deprecation notices
|
|
84
|
+
- [x] Update API documentation with deprecation notices
|
|
85
|
+
- [x] Add migration guide in PKCE-Login-Flow docs
|
|
86
|
+
- [x] Release keycloak-api-manager v6.0.0
|
|
87
|
+
|
|
88
|
+
**Status:** ✅ COMPLETE - v6.0.0 released with @deprecated warnings
|
|
89
|
+
|
|
90
|
+
### Phase 3: TODO (Future - v7.0.0)
|
|
91
|
+
- [ ] Remove OIDC methods from keycloak-api-manager
|
|
92
|
+
- [ ] Release keycloak-api-manager v7.0.0 (breaking change)
|
|
93
|
+
- [ ] Update all documentation to reference keycloak-express-middleware only
|
|
94
|
+
|
|
95
|
+
**Timeline:** TBD based on user feedback and adoption
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## What You Need to Know
|
|
100
|
+
|
|
101
|
+
### For Current Users (v5.0.8 or earlier)
|
|
102
|
+
|
|
103
|
+
**Action Required:** Migrate to keycloak-express-middleware before v7.0.0.
|
|
104
|
+
|
|
105
|
+
**Timeline:** v6.0.0 is deprecated (warnings only), v7.0.0 will remove methods entirely.
|
|
106
|
+
|
|
107
|
+
**Steps:**
|
|
108
|
+
1. Install keycloak-express-middleware v6.1.0+
|
|
109
|
+
2. Replace method calls (see examples below)
|
|
110
|
+
3. Test thoroughly
|
|
111
|
+
4. Deploy before v7.0.0 is released
|
|
112
|
+
|
|
113
|
+
### For New Projects
|
|
48
114
|
|
|
49
|
-
**
|
|
115
|
+
**Action Required:** Do NOT use OIDC methods from keycloak-api-manager.
|
|
50
116
|
|
|
51
|
-
|
|
52
|
-
- [ ] Integrate `oidc-methods.js` into middleware `index.js`
|
|
53
|
-
- [ ] Run tests to verify
|
|
54
|
-
- [ ] Release `keycloak-express-middleware v6.1.0`
|
|
117
|
+
**Recommendation:** Use keycloak-express-middleware v6.1.0+ for all user authentication.
|
|
55
118
|
|
|
56
|
-
|
|
119
|
+
---
|
|
57
120
|
|
|
58
|
-
|
|
121
|
+
## NPM Packages
|
|
59
122
|
|
|
60
|
-
|
|
123
|
+
### keycloak-api-manager
|
|
61
124
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
'See: https://...');
|
|
68
|
-
return requestOidcToken(credentials);
|
|
69
|
-
};
|
|
70
|
-
```
|
|
125
|
+
| Version | OIDC Methods | Status |
|
|
126
|
+
|---------|------------|--------|
|
|
127
|
+
| v5.0.8 | Supported | Legacy (should migrate) |
|
|
128
|
+
| v6.0.0 | Deprecated | Current (shows warnings) |
|
|
129
|
+
| v7.0.0 | Removed | Future (no OIDC methods) |
|
|
71
130
|
|
|
72
|
-
|
|
73
|
-
- Add migration guide in README
|
|
74
|
-
- Mark OIDC methods as deprecated in API docs
|
|
75
|
-
- Link to middleware documentation
|
|
131
|
+
**NPM:** https://www.npmjs.com/package/keycloak-api-manager
|
|
76
132
|
|
|
77
|
-
|
|
78
|
-
- Update package.json version
|
|
79
|
-
- Add breaking change notice
|
|
80
|
-
- Include migration guide in release notes
|
|
133
|
+
### keycloak-express-middleware
|
|
81
134
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
135
|
+
| Version | OIDC Methods | Status |
|
|
136
|
+
|---------|------------|--------|
|
|
137
|
+
| < 6.1.0 | Not available | Legacy |
|
|
138
|
+
| v6.1.0+ | Available | Current - RECOMMENDED |
|
|
85
139
|
|
|
86
|
-
|
|
140
|
+
**NPM:** https://www.npmjs.com/package/keycloak-express-middleware
|
|
141
|
+
|
|
142
|
+
**GitHub:** https://github.com/smartenv-crs4/keycloak-express-middleware
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
### `auth(credentials)` - Generic OIDC Token Grant (DEPRECATED)
|
|
87
147
|
|
|
88
|
-
### `auth(credentials)` - Generic OIDC Token Grant
|
|
89
148
|
```javascript
|
|
90
|
-
//
|
|
149
|
+
// ⚠️ DEPRECATED - Don't use in new code
|
|
91
150
|
const token = await KeycloakManager.auth({
|
|
92
151
|
grant_type: 'password',
|
|
93
152
|
username: 'user',
|
|
@@ -97,7 +156,7 @@ const token = await KeycloakManager.auth({
|
|
|
97
156
|
|
|
98
157
|
**Migration Path:**
|
|
99
158
|
```javascript
|
|
100
|
-
//
|
|
159
|
+
// ✅ NEW - Use keycloak-express-middleware instead
|
|
101
160
|
const token = await keycloakMiddleware.login({
|
|
102
161
|
grant_type: 'password',
|
|
103
162
|
username: 'user',
|
|
@@ -105,9 +164,12 @@ const token = await keycloakMiddleware.login({
|
|
|
105
164
|
});
|
|
106
165
|
```
|
|
107
166
|
|
|
108
|
-
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
### `login(credentials)` - Preferred Alias (DEPRECATED)
|
|
170
|
+
|
|
109
171
|
```javascript
|
|
110
|
-
//
|
|
172
|
+
// ⚠️ DEPRECATED - Don't use in new code
|
|
111
173
|
const token = await KeycloakManager.login({
|
|
112
174
|
grant_type: 'client_credentials'
|
|
113
175
|
});
|
|
@@ -115,15 +177,18 @@ const token = await KeycloakManager.login({
|
|
|
115
177
|
|
|
116
178
|
**Migration Path:**
|
|
117
179
|
```javascript
|
|
118
|
-
//
|
|
180
|
+
// ✅ NEW - Use keycloak-express-middleware instead
|
|
119
181
|
const token = await keycloakMiddleware.login({
|
|
120
182
|
grant_type: 'client_credentials'
|
|
121
183
|
});
|
|
122
184
|
```
|
|
123
185
|
|
|
124
|
-
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
### `generateAuthorizationUrl(options)` - PKCE URL Generator (DEPRECATED)
|
|
189
|
+
|
|
125
190
|
```javascript
|
|
126
|
-
//
|
|
191
|
+
// ⚠️ DEPRECATED - Don't use in new code
|
|
127
192
|
const pkceFlow = KeycloakManager.generateAuthorizationUrl({
|
|
128
193
|
redirect_uri: 'https://app/callback'
|
|
129
194
|
});
|
|
@@ -131,15 +196,18 @@ const pkceFlow = KeycloakManager.generateAuthorizationUrl({
|
|
|
131
196
|
|
|
132
197
|
**Migration Path:**
|
|
133
198
|
```javascript
|
|
134
|
-
//
|
|
199
|
+
// ✅ NEW - Use keycloak-express-middleware instead
|
|
135
200
|
const pkceFlow = keycloakMiddleware.generateAuthorizationUrl({
|
|
136
201
|
redirect_uri: 'https://app/callback'
|
|
137
202
|
});
|
|
138
203
|
```
|
|
139
204
|
|
|
140
|
-
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
### `loginPKCE(credentials)` - PKCE Token Exchange (DEPRECATED)
|
|
208
|
+
|
|
141
209
|
```javascript
|
|
142
|
-
//
|
|
210
|
+
// ⚠️ DEPRECATED - Don't use in new code
|
|
143
211
|
const token = await KeycloakManager.loginPKCE({
|
|
144
212
|
code: req.query.code,
|
|
145
213
|
redirect_uri: 'https://app/callback',
|
|
@@ -147,6 +215,16 @@ const token = await KeycloakManager.loginPKCE({
|
|
|
147
215
|
});
|
|
148
216
|
```
|
|
149
217
|
|
|
218
|
+
**Migration Path:**
|
|
219
|
+
```javascript
|
|
220
|
+
// ✅ NEW - Use keycloak-express-middleware instead
|
|
221
|
+
const token = await keycloakMiddleware.loginPKCE({
|
|
222
|
+
code: req.query.code,
|
|
223
|
+
redirect_uri: 'https://app/callback',
|
|
224
|
+
code_verifier: req.session.verifier
|
|
225
|
+
});
|
|
226
|
+
```
|
|
227
|
+
|
|
150
228
|
**Migration Path:**
|
|
151
229
|
```javascript
|
|
152
230
|
// Move to middleware
|
|
@@ -157,6 +235,8 @@ const token = await keycloakMiddleware.loginPKCE({
|
|
|
157
235
|
});
|
|
158
236
|
```
|
|
159
237
|
|
|
238
|
+
---
|
|
239
|
+
|
|
160
240
|
## What Stays in keycloak-api-manager
|
|
161
241
|
|
|
162
242
|
✅ **These remain unchanged forever:**
|
package/README.md
CHANGED
|
@@ -54,6 +54,8 @@ console.log(users.length);
|
|
|
54
54
|
KeycloakManager.stop();
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
+
> **💡 Tip:** For user authentication (login with credentials, PKCE flow, token exchange), use [`keycloak-express-middleware`](https://github.com/smartenv-crs4/keycloak-express-middleware) instead. See [PKCE Login Flow Guide](docs/guides/PKCE-Login-Flow.md#-migration-to-keycloak-express-middleware-recommended) for migration examples.
|
|
58
|
+
|
|
57
59
|
## Keycloak Feature Flags
|
|
58
60
|
|
|
59
61
|
For full API coverage in this package (especially Organizations, Client Policies, User Profile, Group permissions), run Keycloak with:
|
|
@@ -239,9 +239,15 @@ const response = await axios.get('https://keycloak.example.com/admin/realms/mast
|
|
|
239
239
|
|
|
240
240
|
## auth()
|
|
241
241
|
|
|
242
|
-
|
|
242
|
+
⚠️ **DEPRECATED (v6.0.0)** - Use [`keycloak-express-middleware.login()`](https://github.com/smartenv-crs4/keycloak-express-middleware) instead.
|
|
243
243
|
|
|
244
|
-
|
|
244
|
+
This method will be removed in v7.0.0. For user authentication flows, use `keycloak-express-middleware` v6.1.0+.
|
|
245
|
+
|
|
246
|
+
See: [Migration Guide](../guides/PKCE-Login-Flow.md#-migration-to-keycloak-express-middleware-recommended)
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
**Legacy Note:** Backward-compatible alias of `login()`. Use `login()` instead (also deprecated).
|
|
245
251
|
|
|
246
252
|
**Syntax:**
|
|
247
253
|
```javascript
|
|
@@ -256,6 +262,14 @@ await KeycloakManager.auth(credentials)
|
|
|
256
262
|
|
|
257
263
|
## login()
|
|
258
264
|
|
|
265
|
+
⚠️ **DEPRECATED (v6.0.0)** - Use [`keycloak-express-middleware.login()`](https://github.com/smartenv-crs4/keycloak-express-middleware) instead.
|
|
266
|
+
|
|
267
|
+
This method will be removed in v7.0.0. For user authentication flows, use `keycloak-express-middleware` v6.1.0+.
|
|
268
|
+
|
|
269
|
+
See: [Migration Guide](../guides/PKCE-Login-Flow.md#-migration-to-keycloak-express-middleware-recommended)
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
259
273
|
Request tokens from Keycloak via the OIDC token endpoint.
|
|
260
274
|
|
|
261
275
|
This method is intended for application-level login/token flows (for users, service clients, or third-party integrations) using this package as a wrapper.
|
|
@@ -351,6 +365,14 @@ console.log(refreshed.access_token);
|
|
|
351
365
|
|
|
352
366
|
## generateAuthorizationUrl()
|
|
353
367
|
|
|
368
|
+
⚠️ **DEPRECATED (v6.0.0)** - Use [`keycloak-express-middleware.generateAuthorizationUrl()`](https://github.com/smartenv-crs4/keycloak-express-middleware) instead.
|
|
369
|
+
|
|
370
|
+
This method will be removed in v7.0.0. For PKCE authentication flows, use `keycloak-express-middleware` v6.1.0+.
|
|
371
|
+
|
|
372
|
+
See: [Migration Guide](../guides/PKCE-Login-Flow.md#-migration-to-keycloak-express-middleware-recommended)
|
|
373
|
+
|
|
374
|
+
---
|
|
375
|
+
|
|
354
376
|
Generate OAuth2 Authorization Code + PKCE flow initialization. Returns a ready-to-use authorization URL and PKCE pair for server-side session storage.
|
|
355
377
|
|
|
356
378
|
This helper simplifies the first step of PKCE login: generating the authorization URL with PKCE challenge and state parameter.
|
|
@@ -440,11 +462,19 @@ app.get('/auth/callback', async (req, res) => {
|
|
|
440
462
|
|
|
441
463
|
## loginPKCE()
|
|
442
464
|
|
|
465
|
+
⚠️ **DEPRECATED (v6.0.0)** - Use [`keycloak-express-middleware.loginPKCE()`](https://github.com/smartenv-crs4/keycloak-express-middleware) instead.
|
|
466
|
+
|
|
467
|
+
This method will be removed in v7.0.0. For PKCE authentication flows, use `keycloak-express-middleware` v6.1.0+.
|
|
468
|
+
|
|
469
|
+
See: [Migration Guide](../guides/PKCE-Login-Flow.md#-migration-to-keycloak-express-middleware-recommended)
|
|
470
|
+
|
|
471
|
+
---
|
|
472
|
+
|
|
443
473
|
Perform Authorization Code + PKCE token exchange.
|
|
444
474
|
|
|
445
475
|
This helper is intended for the callback step after user login on Keycloak, where your backend receives an authorization `code` and exchanges it with `code_verifier`.
|
|
446
476
|
|
|
447
|
-
> **📖 For a complete step-by-step guide on implementing PKCE flow in your application, see [PKCE Login Flow Guide](../guides/PKCE-Login-Flow.md)**
|
|
477
|
+
> **📖 For a complete step-by-step guide on implementing PKCE flow in your application, see [PKCE Login Flow Guide](../guides/PKCE-Login-Flow.md#-migration-to-keycloak-express-middleware-recommended)**
|
|
448
478
|
|
|
449
479
|
**Syntax:**
|
|
450
480
|
```javascript
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# PKCE Login Flow Guide
|
|
2
2
|
|
|
3
|
+
⚠️ **DEPRECATION NOTICE (v6.0.0):** This guide describes PKCE implementation using **deprecated methods** in keycloak-api-manager.
|
|
4
|
+
|
|
5
|
+
**👉 NEW APPROACH (Recommended):** For user authentication flows, use [`keycloak-express-middleware v6.1.0+`](https://github.com/smartenv-crs4/keycloak-express-middleware) instead. The middleware package provides a more integrated and Express-native implementation of PKCE flows.
|
|
6
|
+
|
|
7
|
+
**See:** Migration instructions at the end of this guide.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
3
11
|
This guide walks you through implementing OAuth2 Authorization Code + PKCE flow in your application using Keycloak and the keycloak-api-manager library.
|
|
4
12
|
|
|
5
13
|
## Overview
|
|
@@ -506,3 +514,154 @@ function verifyToken(token) {
|
|
|
506
514
|
- [login() API Reference](../api/configuration.md#login)
|
|
507
515
|
- [OAuth2 PKCE Specification](https://tools.ietf.org/html/rfc7636)
|
|
508
516
|
- [Keycloak Authorization Code Flow](https://www.keycloak.org/docs/latest/server_admin/#_oidc)
|
|
517
|
+
|
|
518
|
+
---
|
|
519
|
+
|
|
520
|
+
## 🚀 Migration to keycloak-express-middleware (Recommended)
|
|
521
|
+
|
|
522
|
+
The methods described in this guide (`generateAuthorizationUrl()`, `loginPKCE()`, `login()`) are **deprecated in v6.0.0** and will be removed in v7.0.0.
|
|
523
|
+
|
|
524
|
+
### Why Migrate?
|
|
525
|
+
|
|
526
|
+
`keycloak-express-middleware` provides:
|
|
527
|
+
- ✅ Native Express integration (sessions, cookies, redirects)
|
|
528
|
+
- ✅ Cleaner PKCE implementation focused on user authentication
|
|
529
|
+
- ✅ Better separation of concerns (admin API vs user auth)
|
|
530
|
+
- ✅ Tighter integration with Express middleware patterns
|
|
531
|
+
|
|
532
|
+
### Migration Example
|
|
533
|
+
|
|
534
|
+
**Old Code (keycloak-api-manager, DEPRECATED):**
|
|
535
|
+
```javascript
|
|
536
|
+
const KeycloakManager = require('keycloak-api-manager');
|
|
537
|
+
|
|
538
|
+
// Configure admin API
|
|
539
|
+
await KeycloakManager.configure({
|
|
540
|
+
baseUrl: 'https://keycloak:8443',
|
|
541
|
+
realmName: 'master',
|
|
542
|
+
clientId: 'admin-cli',
|
|
543
|
+
username: 'admin',
|
|
544
|
+
password: 'admin'
|
|
545
|
+
});
|
|
546
|
+
|
|
547
|
+
// Use OIDC methods (deprecated)
|
|
548
|
+
const pkceFlow = KeycloakManager.generateAuthorizationUrl({
|
|
549
|
+
redirect_uri: 'http://localhost:3000/callback'
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
const tokens = await KeycloakManager.loginPKCE({
|
|
553
|
+
code: req.query.code,
|
|
554
|
+
redirect_uri: 'http://localhost:3000/callback',
|
|
555
|
+
code_verifier: req.session.pkce_verifier
|
|
556
|
+
});
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
**New Code (keycloak-express-middleware, RECOMMENDED):**
|
|
560
|
+
```javascript
|
|
561
|
+
const KeycloakMiddleware = require('keycloak-express-middleware');
|
|
562
|
+
|
|
563
|
+
// Configure middleware for user authentication
|
|
564
|
+
const keycloakMiddleware = new KeycloakMiddleware({
|
|
565
|
+
baseUrl: 'https://keycloak:8443',
|
|
566
|
+
realmName: 'my-realm',
|
|
567
|
+
clientId: 'my-app',
|
|
568
|
+
clientSecret: 'my-app-secret'
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
// Use OIDC methods from middleware
|
|
572
|
+
const pkceFlow = keycloakMiddleware.generateAuthorizationUrl({
|
|
573
|
+
redirect_uri: 'http://localhost:3000/callback'
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
const tokens = await keycloakMiddleware.loginPKCE({
|
|
577
|
+
code: req.query.code,
|
|
578
|
+
redirect_uri: 'http://localhost:3000/callback',
|
|
579
|
+
code_verifier: req.session.pkce_verifier
|
|
580
|
+
});
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
### Step-by-Step Migration
|
|
584
|
+
|
|
585
|
+
**1. Install keycloak-express-middleware:**
|
|
586
|
+
```bash
|
|
587
|
+
npm install keycloak-express-middleware@6.1.0
|
|
588
|
+
npm uninstall keycloak-api-manager # if no longer needed for admin operations
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
**2. Initialize middleware instead of manager:**
|
|
592
|
+
```javascript
|
|
593
|
+
// Replace this:
|
|
594
|
+
// const KeycloakManager = require('keycloak-api-manager');
|
|
595
|
+
// await KeycloakManager.configure({...});
|
|
596
|
+
|
|
597
|
+
// With this:
|
|
598
|
+
const KeycloakMiddleware = require('keycloak-express-middleware');
|
|
599
|
+
const keycloakMiddleware = new KeycloakMiddleware({
|
|
600
|
+
baseUrl: process.env.KEYCLOAK_URL,
|
|
601
|
+
realmName: process.env.KEYCLOAK_REALM,
|
|
602
|
+
clientId: process.env.KEYCLOAK_CLIENT_ID,
|
|
603
|
+
clientSecret: process.env.KEYCLOAK_CLIENT_SECRET
|
|
604
|
+
});
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
**3. Replace method calls:**
|
|
608
|
+
```javascript
|
|
609
|
+
// Old (keycloak-api-manager)
|
|
610
|
+
const pkceFlow = KeycloakManager.generateAuthorizationUrl({...});
|
|
611
|
+
const tokens = await KeycloakManager.loginPKCE({...});
|
|
612
|
+
const newTokens = await KeycloakManager.login({...});
|
|
613
|
+
|
|
614
|
+
// New (keycloak-express-middleware)
|
|
615
|
+
const pkceFlow = keycloakMiddleware.generateAuthorizationUrl({...});
|
|
616
|
+
const tokens = await keycloakMiddleware.loginPKCE({...});
|
|
617
|
+
const newTokens = await keycloakMiddleware.login({...});
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
**4. Keep using keycloak-api-manager for admin operations (unchanged):**
|
|
621
|
+
```javascript
|
|
622
|
+
const KeycloakManager = require('keycloak-api-manager');
|
|
623
|
+
|
|
624
|
+
await KeycloakManager.configure({
|
|
625
|
+
baseUrl: 'https://keycloak:8443',
|
|
626
|
+
realmName: 'master',
|
|
627
|
+
clientId: 'admin-cli',
|
|
628
|
+
username: 'admin',
|
|
629
|
+
password: 'admin'
|
|
630
|
+
});
|
|
631
|
+
|
|
632
|
+
// Admin operations still work the same
|
|
633
|
+
const users = await KeycloakManager.users.find();
|
|
634
|
+
const realms = await KeycloakManager.realms.find();
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
### API Comparison
|
|
638
|
+
|
|
639
|
+
| Operation | keycloak-api-manager (Deprecated) | keycloak-express-middleware (Recommended) |
|
|
640
|
+
|-----------|-----------------------------------|------------------------------------------|
|
|
641
|
+
| Generate PKCE URL | `KeycloakManager.generateAuthorizationUrl()` | `middleware.generateAuthorizationUrl()` |
|
|
642
|
+
| Login PKCE | `KeycloakManager.loginPKCE()` | `middleware.loginPKCE()` |
|
|
643
|
+
| Token Grant | `KeycloakManager.login()` | `middleware.login()` |
|
|
644
|
+
| Deprecated Alias | `KeycloakManager.auth()` | *(Use login()*) |
|
|
645
|
+
|
|
646
|
+
### Additional Resources
|
|
647
|
+
|
|
648
|
+
- **Middleware Documentation:** https://github.com/smartenv-crs4/keycloak-express-middleware
|
|
649
|
+
- **Migration Guide:** https://github.com/smartenv-crs4/keycloak-api-manager/blob/main/OIDC_MIGRATION_PLAN.md
|
|
650
|
+
- **Middleware Integration Report:** See keycloak-express-middleware/DETAILED_INTEGRATION_REPORT.md
|
|
651
|
+
|
|
652
|
+
### Deprecation Timeline
|
|
653
|
+
|
|
654
|
+
| Version | Status | Notes |
|
|
655
|
+
|---------|--------|-------|
|
|
656
|
+
| v5.0.8 | Supported | Last version with working OIDC methods |
|
|
657
|
+
| v6.0.0 | Deprecated | Methods work but marked @deprecated |
|
|
658
|
+
| v7.0.0 | Removed | OIDC methods will be permanently removed |
|
|
659
|
+
|
|
660
|
+
**Action Required:** Migrate to keycloak-express-middleware before v7.0.0 is released.
|
|
661
|
+
|
|
662
|
+
## Related Documentation
|
|
663
|
+
|
|
664
|
+
- [loginPKCE() API Reference](../api/configuration.md#loginpkce)
|
|
665
|
+
- [login() API Reference](../api/configuration.md#login)
|
|
666
|
+
- [OAuth2 PKCE Specification](https://tools.ietf.org/html/rfc7636)
|
|
667
|
+
- [Keycloak Authorization Code Flow](https://www.keycloak.org/docs/latest/server_admin/#_oidc)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keycloak-api-manager",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.1",
|
|
4
4
|
"description": "Enhanced Node.js wrapper for Keycloak Admin REST API. Professional alternative to @keycloak/keycloak-admin-client with advanced features, bug fixes, automatic token refresh, Organizations API support, fine-grained permissions, and comprehensive resource management. Battle-tested with 113+ integration tests.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
package/test-output.log
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> keycloak-api-manager@4.1.0 test
|
|
3
|
-
> npm --prefix test install && npm --prefix test test
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
up to date, audited 260 packages in 2s
|
|
7
|
-
|
|
8
|
-
48 packages are looking for funding
|
|
9
|
-
run `npm fund` for details
|
|
10
|
-
|
|
11
|
-
12 vulnerabilities (3 low, 3 moderate, 4 high, 2 critical)
|
|
12
|
-
|
|
13
|
-
To address all issues possible (including breaking changes), run:
|
|
14
|
-
npm audit fix --force
|
|
15
|
-
|
|
16
|
-
Some issues need review, and may require choosing
|
|
17
|
-
a different dependency.
|
|
18
|
-
|
|
19
|
-
Run `npm audit` for details.
|
|
20
|
-
|
|
21
|
-
> keycloak-api-manager-tests@1.0.0 test
|
|
22
|
-
> NODE_ENV=test NODE_PATH=./node_modules mocha --exit
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Exception during run: /Users/Alessandro/Src/WorkSpace/WorkspaceDemo/Idealia/Keyclock/keycloak-api-manager/Handlers/userProfileHandler.js:79
|
|
26
|
-
body: JSON.strasync function(filter) {
|
|
27
|
-
^^^^^^^^
|
|
28
|
-
|
|
29
|
-
SyntaxError: Unexpected token 'function'
|
|
30
|
-
at wrapSafe (node:internal/modules/cjs/loader:1515:18)
|
|
31
|
-
at Module._compile (node:internal/modules/cjs/loader:1537:20)
|
|
32
|
-
at Object..js (node:internal/modules/cjs/loader:1708:10)
|
|
33
|
-
at Module.load (node:internal/modules/cjs/loader:1318:32)
|
|
34
|
-
at Function._load (node:internal/modules/cjs/loader:1128:12)
|
|
35
|
-
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
|
|
36
|
-
at wrapModuleLoad (node:internal/modules/cjs/loader:219:24)
|
|
37
|
-
at Module.require (node:internal/modules/cjs/loader:1340:12)
|
|
38
|
-
at require (node:internal/modules/helpers:138:16)
|
|
39
|
-
at Object.<anonymous> (/Users/Alessandro/Src/WorkSpace/WorkspaceDemo/Idealia/Keyclock/keycloak-api-manager/index.js:15:24)
|
|
40
|
-
at Module._compile (node:internal/modules/cjs/loader:1565:14)
|
|
41
|
-
at Object..js (node:internal/modules/cjs/loader:1708:10)
|
|
42
|
-
at Module.load (node:internal/modules/cjs/loader:1318:32)
|
|
43
|
-
at Function._load (node:internal/modules/cjs/loader:1128:12)
|
|
44
|
-
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
|
|
45
|
-
at wrapModuleLoad (node:internal/modules/cjs/loader:219:24)
|
|
46
|
-
at Module.require (node:internal/modules/cjs/loader:1340:12)
|
|
47
|
-
at require (node:internal/modules/helpers:138:16)
|
|
48
|
-
at Object.<anonymous> (/Users/Alessandro/Src/WorkSpace/WorkspaceDemo/Idealia/Keyclock/keycloak-api-manager/test/enableServerFeatures.js:47:25)
|
|
49
|
-
at Module._compile (node:internal/modules/cjs/loader:1565:14)
|
|
50
|
-
at Object..js (node:internal/modules/cjs/loader:1708:10)
|
|
51
|
-
at Module.load (node:internal/modules/cjs/loader:1318:32)
|
|
52
|
-
at Function._load (node:internal/modules/cjs/loader:1128:12)
|
|
53
|
-
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
|
|
54
|
-
at wrapModuleLoad (node:internal/modules/cjs/loader:219:24)
|
|
55
|
-
at Module.require (node:internal/modules/cjs/loader:1340:12)
|
|
56
|
-
at require (node:internal/modules/helpers:138:16)
|
|
57
|
-
at Object.<anonymous> (/Users/Alessandro/Src/WorkSpace/WorkspaceDemo/Idealia/Keyclock/keycloak-api-manager/test/setup.js:29:30)
|
|
58
|
-
at Module._compile (node:internal/modules/cjs/loader:1565:14)
|
|
59
|
-
at Object..js (node:internal/modules/cjs/loader:1708:10)
|
|
60
|
-
at Module.load (node:internal/modules/cjs/loader:1318:32)
|
|
61
|
-
at Function._load (node:internal/modules/cjs/loader:1128:12)
|
|
62
|
-
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
|
|
63
|
-
at wrapModuleLoad (node:internal/modules/cjs/loader:219:24)
|
|
64
|
-
at cjsLoader (node:internal/modules/esm/translators:263:5)
|
|
65
|
-
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:196:7)
|
|
66
|
-
at ModuleJob.run (node:internal/modules/esm/module_job:271:25)
|
|
67
|
-
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:547:26)
|
|
68
|
-
at async formattedImport (/Users/Alessandro/Src/WorkSpace/WorkspaceDemo/Idealia/Keyclock/keycloak-api-manager/test/node_modules/mocha/lib/nodejs/esm-utils.js:9:14)
|
|
69
|
-
at async exports.requireOrImport (/Users/Alessandro/Src/WorkSpace/WorkspaceDemo/Idealia/Keyclock/keycloak-api-manager/test/node_modules/mocha/lib/nodejs/esm-utils.js:42:28)
|
|
70
|
-
at async exports.loadFilesAsync (/Users/Alessandro/Src/WorkSpace/WorkspaceDemo/Idealia/Keyclock/keycloak-api-manager/test/node_modules/mocha/lib/nodejs/esm-utils.js:100:20)
|
|
71
|
-
at async singleRun (/Users/Alessandro/Src/WorkSpace/WorkspaceDemo/Idealia/Keyclock/keycloak-api-manager/test/node_modules/mocha/lib/cli/run-helpers.js:162:3)
|
|
72
|
-
at async exports.handler (/Users/Alessandro/Src/WorkSpace/WorkspaceDemo/Idealia/Keyclock/keycloak-api-manager/test/node_modules/mocha/lib/cli/run.js:375:5)
|