keycloak-api-manager 6.0.2 → 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/clientScopesHandler.js +9 -9
- package/Handlers/groupsHandler.js +3 -2
- package/Handlers/rolesHandler.js +14 -12
- package/README.md +1 -1
- 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/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/test-configuration.md +19 -1
- package/docs/testing.md +86 -0
- package/package.json +1 -1
- package/test/config/secrets.json.example +1 -1
|
@@ -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) {
|
|
@@ -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,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)
|
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){
|
package/README.md
CHANGED
|
@@ -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)
|