keycloak-api-manager 6.0.1 → 6.0.3
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/attackDetectionHandler.js +12 -8
- package/Handlers/clientPoliciesHandler.js +4 -2
- package/Handlers/clientScopesHandler.js +9 -9
- package/Handlers/clientsHandler.js +1 -13
- package/Handlers/groupsHandler.js +3 -2
- package/Handlers/organizationsHandler.js +2 -1
- package/Handlers/realmsHandler.js +0 -1
- package/Handlers/rolesHandler.js +14 -12
- package/Handlers/userProfileHandler.js +2 -2
- package/OIDC_MIGRATION_PLAN.md +5 -15
- package/README.md +4 -4
- package/docs/api/attack-detection.md +82 -16
- package/docs/api/authentication-management.md +356 -70
- package/docs/api/client-policies.md +103 -16
- package/docs/api/client-scopes.md +52 -4
- package/docs/api/components.md +107 -19
- package/docs/api/configuration.md +39 -386
- package/docs/api/groups.md +46 -5
- package/docs/api/identity-providers.md +50 -5
- package/docs/api/roles.md +37 -7
- package/docs/api/server-info.md +42 -17
- package/docs/api/user-profile.md +55 -10
- package/docs/api-reference.md +7 -7
- package/docs/guides/PKCE-Login-Flow.md +13 -659
- package/docs/test-configuration.md +19 -1
- package/docs/testing.md +86 -0
- package/index.js +131 -0
- package/package.json +1 -1
- package/test/config/secrets.json.example +1 -1
- package/test/helpers/config.js +15 -9
|
@@ -15,10 +15,11 @@ exports.setKcAdminClient = function(kcAdminClient) {
|
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* ***************************** - getBruteForceStatus - *******************************
|
|
18
|
-
* Get brute force detection status
|
|
18
|
+
* Get brute force detection status in the current realm context.
|
|
19
19
|
*
|
|
20
20
|
* @parameters:
|
|
21
|
-
* -
|
|
21
|
+
* - filter: (object, optional) request filter object.
|
|
22
|
+
* - realm: (string, optional) Realm override for this call.
|
|
22
23
|
* @returns: Array of user brute force status objects
|
|
23
24
|
*/
|
|
24
25
|
exports.getBruteForceStatus = function(filter) {
|
|
@@ -27,11 +28,12 @@ exports.getBruteForceStatus = function(filter) {
|
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* ***************************** - getUserBruteForceStatus - *******************************
|
|
30
|
-
* Get brute force detection status for
|
|
31
|
+
* Get brute force detection status for one user.
|
|
31
32
|
*
|
|
32
33
|
* @parameters:
|
|
33
|
-
* -
|
|
34
|
-
*
|
|
34
|
+
* - filter: (object, required) request filter object.
|
|
35
|
+
* - id: (string, required) User ID.
|
|
36
|
+
* - realm: (string, optional) Realm override for this call.
|
|
35
37
|
* @returns: User brute force status object
|
|
36
38
|
*/
|
|
37
39
|
exports.getUserBruteForceStatus = function(filter) {
|
|
@@ -43,8 +45,9 @@ exports.getUserBruteForceStatus = function(filter) {
|
|
|
43
45
|
* Clear all login failures for a specific user
|
|
44
46
|
*
|
|
45
47
|
* @parameters:
|
|
46
|
-
* -
|
|
47
|
-
*
|
|
48
|
+
* - filter: (object, required) request filter object.
|
|
49
|
+
* - id: (string, required) User ID.
|
|
50
|
+
* - realm: (string, optional) Realm override for this call.
|
|
48
51
|
* @returns: Promise
|
|
49
52
|
*/
|
|
50
53
|
exports.clearUserLoginFailures = function(filter) {
|
|
@@ -56,7 +59,8 @@ exports.clearUserLoginFailures = function(filter) {
|
|
|
56
59
|
* Clear all login failures for all users in a realm
|
|
57
60
|
*
|
|
58
61
|
* @parameters:
|
|
59
|
-
* -
|
|
62
|
+
* - filter: (object, optional) request filter object.
|
|
63
|
+
* - realm: (string, optional) Realm override for this call.
|
|
60
64
|
* @returns: Promise
|
|
61
65
|
*/
|
|
62
66
|
exports.clearAllLoginFailures = function(filter) {
|
|
@@ -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;
|
|
@@ -389,7 +389,7 @@ exports.listScopeMappings=function(filter){
|
|
|
389
389
|
* @parameters:
|
|
390
390
|
* - filter: parameter provided as a JSON object that accepts the following filter:
|
|
391
391
|
* - id: [required] The ID of the client scope to list available scope mapping.
|
|
392
|
-
* -
|
|
392
|
+
* - clientUniqueId: [required] The client UUID from which to list available roles.
|
|
393
393
|
* - realm: [optional] The realm where the client scope is defined
|
|
394
394
|
*/
|
|
395
395
|
exports.listAvailableClientScopeMappings=function(filter){
|
|
@@ -405,9 +405,9 @@ exports.listAvailableClientScopeMappings=function(filter){
|
|
|
405
405
|
* @parameters:
|
|
406
406
|
* - filter: parameter provided as a JSON object that accepts the following filter:
|
|
407
407
|
* - id: [required] ID of the client scope.
|
|
408
|
-
* -
|
|
408
|
+
* - clientUniqueId: [required] The client UUID whose roles are being mapped.
|
|
409
409
|
* - realm : [optional] The realm where the client scope is defined.
|
|
410
|
-
* -
|
|
410
|
+
* - roleRepresentation: An array of role definitions to add. Each RoleRepresentation typically includes(or at least their id and/or name):
|
|
411
411
|
* - id : [optional] The role ID.
|
|
412
412
|
* - name : [optional] The role name.
|
|
413
413
|
* - description: [optional] A description of the role.
|
|
@@ -428,7 +428,7 @@ exports.addClientScopeMappings=function(filter,roleRepresentation){
|
|
|
428
428
|
* @parameters:
|
|
429
429
|
* - filter: parameter provided as a JSON object that accepts the following filter:
|
|
430
430
|
* - id: [required] ID of the client scope.
|
|
431
|
-
* -
|
|
431
|
+
* - clientUniqueId: [required] The client UUID from which the roles are being removed.
|
|
432
432
|
* - realm : [optional] The realm where the client scope is defined.
|
|
433
433
|
* - roleRepresentation: An array of role objects (or at least their id and/or name) to be removed from the client scope.
|
|
434
434
|
* - id : [optional] The role ID
|
|
@@ -451,7 +451,7 @@ exports.delClientScopeMappings=function(filter,roleRepresentation){
|
|
|
451
451
|
* @parameters:
|
|
452
452
|
* - filter: parameter provided as a JSON object that accepts the following filter:
|
|
453
453
|
* - id: [required] The ID of the client scope
|
|
454
|
-
* -
|
|
454
|
+
* - clientUniqueId: [required] The client UUID whose mapped roles you want to list.
|
|
455
455
|
* - realm: [optional] The realm where the client scope is defined
|
|
456
456
|
*/
|
|
457
457
|
exports.listClientScopeMappings=function(filter){
|
|
@@ -467,7 +467,7 @@ exports.listClientScopeMappings=function(filter){
|
|
|
467
467
|
* @parameters:
|
|
468
468
|
* - filter: parameter provided as a JSON object that accepts the following filter:
|
|
469
469
|
* - id: [required] The ID of the client scope.
|
|
470
|
-
* -
|
|
470
|
+
* - clientUniqueId: [required] The client UUID whose mapped roles you want to list.
|
|
471
471
|
* - realm: [optional] The realm where the client scope is defined.
|
|
472
472
|
*/
|
|
473
473
|
exports.listCompositeClientScopeMappings=function(filter){
|
|
@@ -522,15 +522,15 @@ exports.addRealmScopeMappings=function(filter,roleRepresentation){
|
|
|
522
522
|
* - filter: parameter provided as a JSON object that accepts the following filter:
|
|
523
523
|
* - id: [required] The ID of the client scope.
|
|
524
524
|
* - realm: [optional] The realm where the client scope is defined.
|
|
525
|
-
* -
|
|
525
|
+
* - roleRepresentation: Each role should include at least its id and/or name
|
|
526
526
|
* - id: [required] The role ID.
|
|
527
527
|
* - name: [required] The role name.
|
|
528
528
|
* - description: [optional] Description of the role.
|
|
529
529
|
* - clientRole: [optional] Should be false for realm roles.
|
|
530
530
|
* - containerId: [optional] The ID of the realm containing the role.
|
|
531
531
|
*/
|
|
532
|
-
exports.delRealmScopeMappings=function(filter,
|
|
533
|
-
return (kcAdminClientHandler.clientScopes.delRealmScopeMappings(filter,
|
|
532
|
+
exports.delRealmScopeMappings=function(filter,roleRepresentation){
|
|
533
|
+
return (kcAdminClientHandler.clientScopes.delRealmScopeMappings(filter,roleRepresentation));
|
|
534
534
|
}
|
|
535
535
|
|
|
536
536
|
|
|
@@ -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.
|
|
@@ -14,10 +14,11 @@ exports.setKcAdminClient=function(kcAdminClient){
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* ***************************** - CREATE - *******************************
|
|
17
|
-
* Create a new group in the current
|
|
17
|
+
* Create a new group in the current realm.
|
|
18
18
|
* @parameters:
|
|
19
19
|
* - groupRepresentation:An object representing the new state of the group. You can update properties such as:
|
|
20
|
-
* - name: [
|
|
20
|
+
* - name: [required] Group name.
|
|
21
|
+
* - parentId: [optional] Parent group id. If provided, the group is created as a child group.
|
|
21
22
|
* - attributes: [optional] Custom attributes up field
|
|
22
23
|
* - path: [optional] full path of the group
|
|
23
24
|
* - subGroups: [optional] List of child groups (can also be updated separately)
|
|
@@ -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;
|
package/Handlers/rolesHandler.js
CHANGED
|
@@ -55,7 +55,7 @@ exports.createComposite=function(filters,roles){
|
|
|
55
55
|
* - realm (string, optional: if set globally in the client): The realm from which to retrieve roles.
|
|
56
56
|
* - first (number, optional): Index of the first result to return (used for pagination).
|
|
57
57
|
* - max (number, optional): Maximum number of results to return.
|
|
58
|
-
* -
|
|
58
|
+
* - search (string, optional): Search string to filter roles by name.
|
|
59
59
|
*/
|
|
60
60
|
exports.find=function(filters){
|
|
61
61
|
return (kcAdminClientHandler.roles.find(filters));
|
|
@@ -81,7 +81,7 @@ exports.findOneByName=function(filters){
|
|
|
81
81
|
* Get a role by its Id
|
|
82
82
|
* @parameters:
|
|
83
83
|
* - filters: parameter provided as a JSON object that accepts the following parameters:
|
|
84
|
-
* -
|
|
84
|
+
* - id (string, required) — The Id of the role to retrieve.
|
|
85
85
|
* - realm (string, optional if set globally) — The realm where the role is defined.
|
|
86
86
|
*/
|
|
87
87
|
exports.findOneById=function(filters){
|
|
@@ -94,7 +94,7 @@ exports.findOneById=function(filters){
|
|
|
94
94
|
* Update a role by its name
|
|
95
95
|
* @parameters:
|
|
96
96
|
* - filters: parameter provided as a JSON object that accepts the following parameters:
|
|
97
|
-
* - name (string, required) — The exact name of the role to
|
|
97
|
+
* - name (string, required) — The exact name of the role to update.
|
|
98
98
|
* - realm (string, optional if set globally) — The realm where the role is defined.
|
|
99
99
|
* - role_dictionary: A JSON object representing a role dictionary as defined in Keycloak
|
|
100
100
|
*/
|
|
@@ -109,7 +109,7 @@ exports.updateByName=function(filters,role_dictionary){
|
|
|
109
109
|
* Update a role by its Id
|
|
110
110
|
* @parameters:
|
|
111
111
|
* - filters: parameter provided as a JSON object that accepts the following parameters:
|
|
112
|
-
* -
|
|
112
|
+
* - id (string, required) — The Id of the role to update.
|
|
113
113
|
* - realm (string, optional if set globally) — The realm where the role is defined.
|
|
114
114
|
* - role_dictionary: A JSON object representing a role dictionary as defined in Keycloak
|
|
115
115
|
*/
|
|
@@ -134,8 +134,8 @@ exports.delByName=function(filters){
|
|
|
134
134
|
* ***************************** - findUsersWithRole - *******************************
|
|
135
135
|
* Find all users associated with a specific role
|
|
136
136
|
* - filters: parameter provided as a JSON object that accepts the following parameters:
|
|
137
|
-
* - name: (string,
|
|
138
|
-
* - id: (string, optional) —
|
|
137
|
+
* - name: (string, required) — The exact name of the role.
|
|
138
|
+
* - id: (string, optional) — Optional role id depending on endpoint support.
|
|
139
139
|
* - realm: (string, optional if set globally) — The realm where the role is defined.
|
|
140
140
|
*/
|
|
141
141
|
exports.findUsersWithRole=function(filters){
|
|
@@ -148,8 +148,8 @@ exports.findUsersWithRole=function(filters){
|
|
|
148
148
|
* ***************************** - getCompositeRoles - *******************************
|
|
149
149
|
* Find all composite roles associated with a specific role.
|
|
150
150
|
* - filters: parameter provided as a JSON object that accepts the following parameters:
|
|
151
|
-
* -
|
|
152
|
-
* -
|
|
151
|
+
* - id: (string, required) — The Id of the role to retrieve.
|
|
152
|
+
* - realm: (string, optional) — Realm override.
|
|
153
153
|
*/
|
|
154
154
|
exports.getCompositeRoles=function(filters){
|
|
155
155
|
return (kcAdminClientHandler.roles.getCompositeRoles(filters));
|
|
@@ -161,13 +161,14 @@ exports.getCompositeRoles=function(filters){
|
|
|
161
161
|
* associated with a given composite role.
|
|
162
162
|
* When a role is defined as composite, it can include other roles either from the same
|
|
163
163
|
* realm or from different clients. This specific method returns only the realm-level roles
|
|
164
|
-
* that have been added to the composite role. It requires the
|
|
164
|
+
* that have been added to the composite role. It requires the id of the target role as a
|
|
165
165
|
* parameter and returns an array of RoleRepresentation objects. If the role is not composite
|
|
166
166
|
* or has no associated realm roles, the result will be an empty array. This method is useful
|
|
167
167
|
* for understanding and managing hierarchical role structures within a realm in Keycloak.
|
|
168
168
|
* @parameters:
|
|
169
169
|
* - filters: parameter provided as a JSON object that accepts the following parameters:
|
|
170
|
-
* -
|
|
170
|
+
* - id: (string, required) — The Id of the role to retrieve.
|
|
171
|
+
* - realm: (string, optional) — Realm override.
|
|
171
172
|
*/
|
|
172
173
|
exports.getCompositeRolesForRealm=function(filters){
|
|
173
174
|
return (kcAdminClientHandler.roles.getCompositeRolesForRealm(filters));
|
|
@@ -180,14 +181,15 @@ exports.getCompositeRolesForRealm=function(filters){
|
|
|
180
181
|
* associated with a given composite role.
|
|
181
182
|
* Composite roles in Keycloak can include roles from different clients,
|
|
182
183
|
* and this method specifically returns the roles belonging to a specified client that
|
|
183
|
-
* are part of the composite role. It requires the
|
|
184
|
+
* are part of the composite role. It requires the id of the composite role
|
|
184
185
|
* and the clientId of the client whose roles you want to retrieve. The function returns an array of
|
|
185
186
|
* RoleRepresentation objects representing the client roles included in the composite.
|
|
186
187
|
* This helps manage and inspect client-specific role hierarchies within the composite role structure in Keycloak.
|
|
187
188
|
* @parameters:
|
|
188
189
|
* - filters: parameter provided as a JSON object that accepts the following parameters:
|
|
189
|
-
* -
|
|
190
|
+
* - id: (string, required) — The Id of the role to retrieve.
|
|
190
191
|
* - clientId: (string, required) — The Id of the client to search for composite roles
|
|
192
|
+
* - realm: (string, optional) — Realm override.
|
|
191
193
|
*
|
|
192
194
|
*/
|
|
193
195
|
exports.getCompositeRolesForClient=function(filters){
|
|
@@ -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,8 @@
|
|
|
1
1
|
# OIDC Methods Migration Plan - keycloak-api-manager
|
|
2
2
|
|
|
3
|
-
## 🚀 Current Status: v6.0.
|
|
3
|
+
## 🚀 Current Status: v6.0.1 - Migration Released
|
|
4
4
|
|
|
5
|
-
✅ **OIDC Methods Deprecated:** All OIDC authentication methods are
|
|
5
|
+
✅ **OIDC Methods Deprecated:** All OIDC authentication methods are marked `@deprecated` since v6.0.0.
|
|
6
6
|
|
|
7
7
|
✅ **keycloak-express-middleware v6.1.0 Released:** OIDC methods now available in middleware package with full test coverage.
|
|
8
8
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
## Overview
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
This architecture follows a **planned migration** of OIDC methods (`auth()`, `login()`, `loginPKCE()`) from `keycloak-api-manager` to `keycloak-express-middleware`.
|
|
18
18
|
|
|
19
19
|
## Current State (v5.0.8)
|
|
20
20
|
|
|
@@ -24,7 +24,7 @@ L'architettura prevede una **migrazione pianificata** dei metodi OIDC (`auth()`,
|
|
|
24
24
|
- ✅ `generateAuthorizationUrl(options)` - PKCE URL generator
|
|
25
25
|
- ✅ `loginPKCE(credentials)` - PKCE token exchange
|
|
26
26
|
|
|
27
|
-
## Current State (v6.0.
|
|
27
|
+
## Current State (v6.0.1) - NOW
|
|
28
28
|
|
|
29
29
|
**Status Changes in keycloak-api-manager:**
|
|
30
30
|
- ⚠️ `auth(credentials)` - Marked @deprecated
|
|
@@ -125,7 +125,7 @@ keycloak-express-middleware (User Authentication)
|
|
|
125
125
|
| Version | OIDC Methods | Status |
|
|
126
126
|
|---------|------------|--------|
|
|
127
127
|
| v5.0.8 | Supported | Legacy (should migrate) |
|
|
128
|
-
| v6.0.
|
|
128
|
+
| v6.0.1 | Deprecated | Current (shows warnings) |
|
|
129
129
|
| v7.0.0 | Removed | Future (no OIDC methods) |
|
|
130
130
|
|
|
131
131
|
**NPM:** https://www.npmjs.com/package/keycloak-api-manager
|
|
@@ -225,16 +225,6 @@ const token = await keycloakMiddleware.loginPKCE({
|
|
|
225
225
|
});
|
|
226
226
|
```
|
|
227
227
|
|
|
228
|
-
**Migration Path:**
|
|
229
|
-
```javascript
|
|
230
|
-
// Move to middleware
|
|
231
|
-
const token = await keycloakMiddleware.loginPKCE({
|
|
232
|
-
code: req.query.code,
|
|
233
|
-
redirect_uri: 'https://app/callback',
|
|
234
|
-
code_verifier: req.session.verifier
|
|
235
|
-
});
|
|
236
|
-
```
|
|
237
|
-
|
|
238
228
|
---
|
|
239
229
|
|
|
240
230
|
## What Stays in keycloak-api-manager
|
package/README.md
CHANGED
|
@@ -54,7 +54,7 @@ console.log(users.length);
|
|
|
54
54
|
KeycloakManager.stop();
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
> **💡 Tip:** For user authentication (
|
|
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
58
|
|
|
59
59
|
## Keycloak Feature Flags
|
|
60
60
|
|
|
@@ -102,9 +102,9 @@ Configured handler namespaces:
|
|
|
102
102
|
|
|
103
103
|
All documentation is centralized under `docs/`.
|
|
104
104
|
|
|
105
|
-
### Guides
|
|
105
|
+
### Guides
|
|
106
106
|
|
|
107
|
-
- [
|
|
107
|
+
- [OIDC Migration Plan](OIDC_MIGRATION_PLAN.md) - Deprecation status and migration notes to keycloak-express-middleware
|
|
108
108
|
|
|
109
109
|
### API Reference
|
|
110
110
|
|
|
@@ -163,7 +163,7 @@ docs/ # Centralized documentation
|
|
|
163
163
|
|
|
164
164
|
## Versioning and Compatibility
|
|
165
165
|
|
|
166
|
-
- Package version: `6.0.
|
|
166
|
+
- Package version: `6.0.2`
|
|
167
167
|
- Keycloak Admin client dependency: `@keycloak/keycloak-admin-client`
|
|
168
168
|
- Main compatibility target: Keycloak 25/26
|
|
169
169
|
|
|
@@ -2,41 +2,107 @@
|
|
|
2
2
|
|
|
3
3
|
Brute-force and login-failure management endpoints.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Namespace: KeycloakManager.attackDetection
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
This handler wraps Keycloak Attack Detection endpoints used to:
|
|
10
|
+
|
|
11
|
+
- Inspect lock/failure status.
|
|
12
|
+
- Clear failures for one user.
|
|
13
|
+
- Clear failures for the entire realm.
|
|
14
|
+
|
|
15
|
+
These operations are usually used by support/admin tooling and automated account recovery flows.
|
|
6
16
|
|
|
7
17
|
## Methods
|
|
8
18
|
|
|
9
19
|
### getBruteForceStatus(filter)
|
|
10
|
-
Get brute-force status for all users or query context depending on endpoint wrapper.
|
|
11
20
|
|
|
12
|
-
-
|
|
13
|
-
|
|
21
|
+
Read global brute-force status context from the configured realm.
|
|
22
|
+
|
|
23
|
+
Parameters:
|
|
24
|
+
|
|
25
|
+
- filter (object, optional):
|
|
26
|
+
- realm (string, optional): override target realm for this call.
|
|
27
|
+
|
|
28
|
+
Returns:
|
|
29
|
+
|
|
30
|
+
- Promise<object>: realm brute-force status payload returned by Keycloak.
|
|
31
|
+
|
|
32
|
+
Example:
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
const status = await KeycloakManager.attackDetection.getBruteForceStatus();
|
|
36
|
+
console.log(status);
|
|
37
|
+
```
|
|
14
38
|
|
|
15
39
|
### getUserBruteForceStatus(filter)
|
|
16
|
-
Get brute-force status for one user.
|
|
17
40
|
|
|
18
|
-
-
|
|
19
|
-
|
|
41
|
+
Read brute-force status for one user.
|
|
42
|
+
|
|
43
|
+
Parameters:
|
|
44
|
+
|
|
45
|
+
- filter (object, required):
|
|
46
|
+
- id (string, required): user id.
|
|
47
|
+
- realm (string, optional): override target realm.
|
|
48
|
+
|
|
49
|
+
Returns:
|
|
50
|
+
|
|
51
|
+
- Promise<object>: user brute-force state (for example temporary lock status, failures metadata).
|
|
52
|
+
|
|
53
|
+
Example:
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
const userStatus = await KeycloakManager.attackDetection.getUserBruteForceStatus({
|
|
57
|
+
id: userId,
|
|
58
|
+
});
|
|
59
|
+
```
|
|
20
60
|
|
|
21
61
|
### clearUserLoginFailures(filter)
|
|
22
|
-
Clear failed login attempts for one user.
|
|
23
62
|
|
|
24
|
-
-
|
|
25
|
-
|
|
63
|
+
Clear failed-login counters for one user.
|
|
64
|
+
|
|
65
|
+
Parameters:
|
|
66
|
+
|
|
67
|
+
- filter (object, required):
|
|
68
|
+
- id (string, required): user id.
|
|
69
|
+
- realm (string, optional): override target realm.
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
|
|
73
|
+
- Promise<void>
|
|
74
|
+
|
|
75
|
+
Example:
|
|
76
|
+
|
|
77
|
+
```js
|
|
78
|
+
await KeycloakManager.attackDetection.clearUserLoginFailures({ id: userId });
|
|
79
|
+
```
|
|
26
80
|
|
|
27
81
|
### clearAllLoginFailures(filter)
|
|
28
|
-
Clear failed login attempts for all users in realm.
|
|
29
82
|
|
|
30
|
-
-
|
|
31
|
-
|
|
83
|
+
Clear failed-login counters for all users in the realm.
|
|
84
|
+
|
|
85
|
+
Parameters:
|
|
86
|
+
|
|
87
|
+
- filter (object, optional):
|
|
88
|
+
- realm (string, optional): override target realm.
|
|
89
|
+
|
|
90
|
+
Returns:
|
|
32
91
|
|
|
33
|
-
|
|
92
|
+
- Promise<void>
|
|
93
|
+
|
|
94
|
+
Example:
|
|
34
95
|
|
|
35
96
|
```js
|
|
36
|
-
|
|
37
|
-
await KeycloakManager.attackDetection.clearUserLoginFailures({ userId });
|
|
97
|
+
await KeycloakManager.attackDetection.clearAllLoginFailures();
|
|
38
98
|
```
|
|
39
99
|
|
|
100
|
+
## Error Notes
|
|
101
|
+
|
|
102
|
+
- Some Keycloak distributions/versions may not expose attack-detection endpoints in the same way.
|
|
103
|
+
- If endpoint support is missing, Keycloak may return 404.
|
|
104
|
+
|
|
40
105
|
## See Also
|
|
106
|
+
|
|
41
107
|
- [API Reference](../api-reference.md)
|
|
42
108
|
- [Users](users.md)
|