keycloak-api-manager 6.0.0 → 6.0.2
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/Handlers/clientPoliciesHandler.js +4 -2
- package/Handlers/clientsHandler.js +1 -13
- package/Handlers/organizationsHandler.js +2 -1
- package/Handlers/realmsHandler.js +0 -1
- package/Handlers/userProfileHandler.js +2 -2
- package/OIDC_MIGRATION_PLAN.md +112 -42
- package/README.md +5 -3
- package/docs/api/configuration.md +39 -356
- package/docs/api-reference.md +7 -7
- package/docs/guides/PKCE-Login-Flow.md +13 -500
- package/index.js +131 -0
- package/package.json +1 -1
- package/test/helpers/config.js +15 -9
- package/test-output.log +0 -72
|
@@ -42,7 +42,8 @@ exports.getPolicies = function(filter) {
|
|
|
42
42
|
* - profiles: (array) - Profiles to apply when policy matches
|
|
43
43
|
*/
|
|
44
44
|
exports.updatePolicies = async function(filter, policiesRepresentation) {
|
|
45
|
-
// Direct API call
|
|
45
|
+
// Direct API call: admin-client support for client-policies update endpoints
|
|
46
|
+
// is incomplete/inconsistent across versions.
|
|
46
47
|
const realm = filter?.realm || kcAdminClientHandler.realmName;
|
|
47
48
|
const baseUrl = kcAdminClientHandler.baseUrl;
|
|
48
49
|
const token = kcAdminClientHandler.accessToken;
|
|
@@ -95,7 +96,8 @@ exports.getProfiles = function(filter) {
|
|
|
95
96
|
* - configuration: (object) - Executor-specific configuration
|
|
96
97
|
*/
|
|
97
98
|
exports.updateProfiles = async function(filter, profilesRepresentation) {
|
|
98
|
-
// Direct API call
|
|
99
|
+
// Direct API call: admin-client support for client-policies update endpoints
|
|
100
|
+
// is incomplete/inconsistent across versions.
|
|
99
101
|
const realm = filter?.realm || kcAdminClientHandler.realmName;
|
|
100
102
|
const baseUrl = kcAdminClientHandler.baseUrl;
|
|
101
103
|
const token = kcAdminClientHandler.accessToken;
|
|
@@ -14,6 +14,7 @@ exports.setKcAdminClient=function(kcAdminClient){
|
|
|
14
14
|
/**
|
|
15
15
|
* Helper function to make direct HTTP calls to Keycloak Admin API.
|
|
16
16
|
* Used when @keycloak/keycloak-admin-client has bugs or inconsistencies.
|
|
17
|
+
* This keeps behavior aligned with server endpoints even when upstream wrappers lag behind.
|
|
17
18
|
*
|
|
18
19
|
* @param {string} path - API path relative to baseUrl (e.g., '/admin/realms/...')
|
|
19
20
|
* @param {string} method - HTTP method (GET, POST, PUT, DELETE)
|
|
@@ -551,19 +552,6 @@ exports.listAvailableRealmScopeMappings=function(filter){
|
|
|
551
552
|
}
|
|
552
553
|
|
|
553
554
|
|
|
554
|
-
/**
|
|
555
|
-
* ***************************** - listAvailableRealmScopeMappings - *******************************
|
|
556
|
-
* The method is used to retrieve all realm-level roles that are available to be assigned to a specific client.
|
|
557
|
-
* These are roles defined at the realm level that the client does not yet have mapped, allowing you to see what can be added.
|
|
558
|
-
* @parameters:
|
|
559
|
-
* - filter: JSON structure that defines the filter parameters:
|
|
560
|
-
* - id: [required] The ID of the client for which you want to list available realm-level role mappings.
|
|
561
|
-
*/
|
|
562
|
-
exports.listAvailableRealmScopeMappings=function(filter){
|
|
563
|
-
return (kcAdminClientHandler.clients.listAvailableRealmScopeMappings(filter));
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
|
|
567
555
|
/**
|
|
568
556
|
* ***************************** - listRealmScopeMappings - *******************************
|
|
569
557
|
* The method retrieves the realm-level roles currently assigned to a client as part of its scope mappings.
|
|
@@ -17,7 +17,8 @@ exports.setKcAdminClient = function(kcAdminClient) {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* Helper
|
|
20
|
+
* Helper to perform direct Admin REST calls for Organizations endpoints.
|
|
21
|
+
* This bypasses admin-client gaps for some Keycloak versions/features.
|
|
21
22
|
*/
|
|
22
23
|
async function makeDirectApiCall(method, endpoint, body = null) {
|
|
23
24
|
const baseUrl = kcAdminClientHandler.baseUrl;
|
|
@@ -23,7 +23,7 @@ exports.setKcAdminClient = function(kcAdminClient) {
|
|
|
23
23
|
* @returns: User profile configuration object with attributes, groups, etc.
|
|
24
24
|
*/
|
|
25
25
|
exports.getConfiguration = async function(filter) {
|
|
26
|
-
// Direct API call
|
|
26
|
+
// Direct API call: this endpoint is not consistently exposed across admin-client versions.
|
|
27
27
|
const realm = filter?.realm || kcAdminClientHandler.realmName;
|
|
28
28
|
const baseUrl = kcAdminClientHandler.baseUrl;
|
|
29
29
|
const token = kcAdminClientHandler.accessToken;
|
|
@@ -63,7 +63,7 @@ exports.getConfiguration = async function(filter) {
|
|
|
63
63
|
* - unmanagedAttributePolicy: (string) - Policy for unmanaged attributes
|
|
64
64
|
*/
|
|
65
65
|
exports.updateConfiguration = async function(filter, userProfileConfig) {
|
|
66
|
-
// Direct API call
|
|
66
|
+
// Direct API call: this endpoint is not consistently exposed across admin-client versions.
|
|
67
67
|
const realm = filter?.realm || kcAdminClientHandler.realmName;
|
|
68
68
|
const baseUrl = kcAdminClientHandler.baseUrl;
|
|
69
69
|
const token = kcAdminClientHandler.accessToken;
|
package/OIDC_MIGRATION_PLAN.md
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
# OIDC Methods Migration Plan - keycloak-api-manager
|
|
2
2
|
|
|
3
|
+
## 🚀 Current Status: v6.0.1 - Migration Released
|
|
4
|
+
|
|
5
|
+
✅ **OIDC Methods Deprecated:** All OIDC authentication methods are marked `@deprecated` since 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
|
+
This architecture follows a **planned migration** of OIDC methods (`auth()`, `login()`, `loginPKCE()`) from `keycloak-api-manager` to `keycloak-express-middleware`.
|
|
6
18
|
|
|
7
19
|
## Current State (v5.0.8)
|
|
8
20
|
|
|
@@ -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.1) - 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
|
|
48
100
|
|
|
49
|
-
|
|
101
|
+
### For Current Users (v5.0.8 or earlier)
|
|
50
102
|
|
|
51
|
-
|
|
52
|
-
- [ ] Integrate `oidc-methods.js` into middleware `index.js`
|
|
53
|
-
- [ ] Run tests to verify
|
|
54
|
-
- [ ] Release `keycloak-express-middleware v6.1.0`
|
|
103
|
+
**Action Required:** Migrate to keycloak-express-middleware before v7.0.0.
|
|
55
104
|
|
|
56
|
-
**
|
|
105
|
+
**Timeline:** v6.0.0 is deprecated (warnings only), v7.0.0 will remove methods entirely.
|
|
57
106
|
|
|
58
|
-
|
|
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
|
|
59
112
|
|
|
60
|
-
|
|
113
|
+
### For New Projects
|
|
61
114
|
|
|
62
|
-
|
|
63
|
-
```javascript
|
|
64
|
-
exports.auth = async function auth(credentials = {}) {
|
|
65
|
-
console.warn('⚠️ DEPRECATED: auth() is deprecated in v6.0. ' +
|
|
66
|
-
'Use keycloak-express-middleware.login() instead. ' +
|
|
67
|
-
'See: https://...');
|
|
68
|
-
return requestOidcToken(credentials);
|
|
69
|
-
};
|
|
70
|
-
```
|
|
115
|
+
**Action Required:** Do NOT use OIDC methods from keycloak-api-manager.
|
|
71
116
|
|
|
72
|
-
|
|
73
|
-
- Add migration guide in README
|
|
74
|
-
- Mark OIDC methods as deprecated in API docs
|
|
75
|
-
- Link to middleware documentation
|
|
117
|
+
**Recommendation:** Use keycloak-express-middleware v6.1.0+ for all user authentication.
|
|
76
118
|
|
|
77
|
-
|
|
78
|
-
- Update package.json version
|
|
79
|
-
- Add breaking change notice
|
|
80
|
-
- Include migration guide in release notes
|
|
119
|
+
---
|
|
81
120
|
|
|
82
|
-
|
|
83
|
-
- Optionally remove these methods entirely
|
|
84
|
-
- Keep at least 1 major version for migration
|
|
121
|
+
## NPM Packages
|
|
85
122
|
|
|
86
|
-
|
|
123
|
+
### keycloak-api-manager
|
|
124
|
+
|
|
125
|
+
| Version | OIDC Methods | Status |
|
|
126
|
+
|---------|------------|--------|
|
|
127
|
+
| v5.0.8 | Supported | Legacy (should migrate) |
|
|
128
|
+
| v6.0.1 | Deprecated | Current (shows warnings) |
|
|
129
|
+
| v7.0.0 | Removed | Future (no OIDC methods) |
|
|
130
|
+
|
|
131
|
+
**NPM:** https://www.npmjs.com/package/keycloak-api-manager
|
|
132
|
+
|
|
133
|
+
### keycloak-express-middleware
|
|
134
|
+
|
|
135
|
+
| Version | OIDC Methods | Status |
|
|
136
|
+
|---------|------------|--------|
|
|
137
|
+
| < 6.1.0 | Not available | Legacy |
|
|
138
|
+
| v6.1.0+ | Available | Current - RECOMMENDED |
|
|
139
|
+
|
|
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',
|
|
@@ -149,7 +217,7 @@ const token = await KeycloakManager.loginPKCE({
|
|
|
149
217
|
|
|
150
218
|
**Migration Path:**
|
|
151
219
|
```javascript
|
|
152
|
-
//
|
|
220
|
+
// ✅ NEW - Use keycloak-express-middleware instead
|
|
153
221
|
const token = await keycloakMiddleware.loginPKCE({
|
|
154
222
|
code: req.query.code,
|
|
155
223
|
redirect_uri: 'https://app/callback',
|
|
@@ -157,6 +225,8 @@ const token = await keycloakMiddleware.loginPKCE({
|
|
|
157
225
|
});
|
|
158
226
|
```
|
|
159
227
|
|
|
228
|
+
---
|
|
229
|
+
|
|
160
230
|
## What Stays in keycloak-api-manager
|
|
161
231
|
|
|
162
232
|
✅ **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 (including Authorization Code + PKCE), use [`keycloak-express-middleware`](https://github.com/smartenv-crs4/keycloak-express-middleware). OIDC methods in this package are deprecated and kept only for backward compatibility.
|
|
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:
|
|
@@ -100,9 +102,9 @@ Configured handler namespaces:
|
|
|
100
102
|
|
|
101
103
|
All documentation is centralized under `docs/`.
|
|
102
104
|
|
|
103
|
-
### Guides
|
|
105
|
+
### Guides
|
|
104
106
|
|
|
105
|
-
- [
|
|
107
|
+
- [OIDC Migration Plan](OIDC_MIGRATION_PLAN.md) - Deprecation status and migration notes to keycloak-express-middleware
|
|
106
108
|
|
|
107
109
|
### API Reference
|
|
108
110
|
|
|
@@ -161,7 +163,7 @@ docs/ # Centralized documentation
|
|
|
161
163
|
|
|
162
164
|
## Versioning and Compatibility
|
|
163
165
|
|
|
164
|
-
- Package version: `6.0.
|
|
166
|
+
- Package version: `6.0.1`
|
|
165
167
|
- Keycloak Admin client dependency: `@keycloak/keycloak-admin-client`
|
|
166
168
|
- Main compatibility target: Keycloak 25/26
|
|
167
169
|
|