keycloak-api-manager 1.0.0 → 2.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/.idea/workspace.xml +19 -2
- package/Handlers/authenticationManagementHandler.js +602 -0
- package/Handlers/clientScopesHandler.js +567 -0
- package/Handlers/clientsHandler.js +1411 -0
- package/Handlers/componentsHandler.js +130 -0
- package/Handlers/groupsHandler.js +293 -0
- package/Handlers/identityProvidersHandler.js +255 -0
- package/Handlers/realmsHandler.js +575 -0
- package/Handlers/rolesHandler.js +196 -0
- package/Handlers/usersHandler.js +559 -0
- package/README.md +742 -1102
- package/index.js +37 -1181
- package/package.json +1 -1
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **************************************************************************************************
|
|
3
|
+
* **************************************************************************************************
|
|
4
|
+
* The users refers to Keycloak's users management functionality, part of the Admin REST API.
|
|
5
|
+
* It allows you to manage as create, update, inspect, and delete both realm-level and client-level users.
|
|
6
|
+
* **************************************************************************************************
|
|
7
|
+
* **************************************************************************************************
|
|
8
|
+
*/
|
|
9
|
+
let kcAdminClientHandler=null;
|
|
10
|
+
exports.setKcAdminClient=function(kcAdminClient){
|
|
11
|
+
kcAdminClientHandler=kcAdminClient;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* ***************************** - CREATE - *******************************
|
|
17
|
+
* Create is a method used to create a new user in the specified realm.
|
|
18
|
+
* This method accepts a user representation object containing details such as username, email, enabled status,
|
|
19
|
+
* credentials, and other user attributes that can be get by getProfile function.
|
|
20
|
+
* It is typically used when you want to programmatically add new users to your Keycloak realm via the Admin API.
|
|
21
|
+
* @parameters:
|
|
22
|
+
* - userRepresentation: An object containing the user fields to be updated.
|
|
23
|
+
*/
|
|
24
|
+
exports.create=function(userRepresentation){
|
|
25
|
+
return (kcAdminClientHandler.users.create(userRepresentation));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* ***************************** - del - *******************************
|
|
31
|
+
* Deletes a user from the specified realm. Once removed, the user and all associated data (such as credentials,
|
|
32
|
+
* sessions, and group/role memberships) are permanently deleted.
|
|
33
|
+
* @parameters:
|
|
34
|
+
* - id: [Required] the user ID to delete
|
|
35
|
+
* - realm [Optional] the realm name (defaults to current realm)
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
exports.del=function(filter){
|
|
39
|
+
return (kcAdminClientHandler.users.del(filter));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* ***************************** - find - *******************************
|
|
44
|
+
* find method is used to retrieve a list of users in a specific realm.
|
|
45
|
+
* It supports optional filtering parameters such as username, email, first name, last name, and more.
|
|
46
|
+
* Searching by attributes is only available from Keycloak > 15
|
|
47
|
+
* @parameters:
|
|
48
|
+
* - filter: parameter provided as a JSON object that accepts the following filter:
|
|
49
|
+
* - q: A string containing a query filter by custom attributes, such as 'username:admin'.
|
|
50
|
+
* - {builtin attribute}: To find users by builtin attributes such as email, surname... example {email:"admin@admin.com"}
|
|
51
|
+
* - max: A pagination parameter used to define the maximum number of users to return (limit).
|
|
52
|
+
* - first: A pagination parameter used to define the number of users to skip before starting to return results (offset/limit).
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
exports.find=function(filter){
|
|
56
|
+
return (kcAdminClientHandler.users.find(filter));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* ***************************** - findOne - *******************************
|
|
62
|
+
* findOne is method used to retrieve a specific user's details by their unique identifier (id) within a given realm.
|
|
63
|
+
* It returns the full user representation if the user exists.
|
|
64
|
+
* @parameters:
|
|
65
|
+
* - filter is a JSON object that accepts filter parameters id
|
|
66
|
+
* - id: user identifier
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
exports.findOne=function(filter){
|
|
70
|
+
return (kcAdminClientHandler.users.findOne(filter));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* ***************************** - count - *******************************
|
|
76
|
+
* count method returns the total number of users in a given realm.
|
|
77
|
+
* It optionally accepts filtering parameters similar to those in users.find() such
|
|
78
|
+
* as username, email, firstName, lastName and so on to count only users that match specific criteria.
|
|
79
|
+
* Searching by attributes is only available from Keycloak > 15
|
|
80
|
+
* @parameters:
|
|
81
|
+
* - filter is a JSON object that accepts filter parameters, such as { email: 'test@keycloak.org' }
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
exports.count=function(filter){
|
|
85
|
+
return (kcAdminClientHandler.users.count(filter));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* ***************************** - update - *******************************
|
|
91
|
+
* update method is used to update the details of a specific user in a Keycloak realm.
|
|
92
|
+
* It requires at least the user’s ID(searchParams) and the updated data(userRepresentation).
|
|
93
|
+
* You can modify fields like firstName, lastName, email, enabled, and more.
|
|
94
|
+
* @parameters:
|
|
95
|
+
* - searchParams: is a JSON object that accepts filter parameters
|
|
96
|
+
* - id: [Required] the user ID to update
|
|
97
|
+
* - realm [Optional] the realm name (defaults to current realm)
|
|
98
|
+
* - userRepresentation: An object containing the user fields to be updated.
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
exports.update=function(searchParams,userRepresentation){
|
|
102
|
+
return (kcAdminClientHandler.users.update(searchParams,userRepresentation));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* ***************************** - resetPassword - *******************************
|
|
107
|
+
* resetPassword method is used to set a new password for a specific user.
|
|
108
|
+
* This action replaces the user's existing credentials. You can also set whether the user is required to
|
|
109
|
+
* change the password on next login.
|
|
110
|
+
* @parameters:
|
|
111
|
+
* - newCredentialsParameters: is a JSON object that accepts filter parameters
|
|
112
|
+
* - id: [Required] the user ID to update
|
|
113
|
+
* - realm [Optional] the realm name (defaults to current realm)
|
|
114
|
+
* - credential: An object containing the new user credentials
|
|
115
|
+
* - temporary: true or false. Whether the new password is temporary (forces user to reset at next login).
|
|
116
|
+
* - type: a String value set to "password"
|
|
117
|
+
* - value: a String containing new password to be set
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
exports.resetPassword=function(newCredentialsParameters){
|
|
121
|
+
return (kcAdminClientHandler.users.resetPassword(newCredentialsParameters));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* ***************************** - getCredentials - *******************************
|
|
126
|
+
* getCredentials() method retrieves the list of credentials (e.g., passwords, OTPs, WebAuthn, etc.)
|
|
127
|
+
* currently associated with a given user in a specific realm.
|
|
128
|
+
* This is useful for auditing, checking what types of credentials a user has set up,
|
|
129
|
+
* or managing credentials such as password reset, WebAuthn deletion, etc.
|
|
130
|
+
* @parameters:
|
|
131
|
+
* - filter: is a JSON object that accepts filter parameters
|
|
132
|
+
* - id: [Required] the user ID to update
|
|
133
|
+
* - realm [Optional] the realm name (defaults to current realm)
|
|
134
|
+
*/
|
|
135
|
+
|
|
136
|
+
exports.getCredentials=function(filter){
|
|
137
|
+
return (kcAdminClientHandler.users.getCredentials(filter));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* ***************************** - deleteCredential - *******************************
|
|
143
|
+
* deleteCredential method allows you to delete a specific credential (e.g., password, OTP, WebAuthn, etc.) from a user.
|
|
144
|
+
* This is useful when you want to invalidate or remove a credential, forcing the user to reconfigure or reset it.
|
|
145
|
+
* @parameters:
|
|
146
|
+
* - accountInfo: is a JSON object that accepts this parameters
|
|
147
|
+
* - id: [Required] the user ID to update
|
|
148
|
+
* - credentialId [Required] the credentils identifier
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
exports.deleteCredential=function(accountInfo){
|
|
152
|
+
return (kcAdminClientHandler.users.deleteCredential(accountInfo));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* ***************************** - getProfile - *******************************
|
|
157
|
+
* It is a method that retrieves the user profile dictionary information.
|
|
158
|
+
* This includes basic user details such as username, email, first name, last name,
|
|
159
|
+
* and other attributes associated with the user profile in the Keycloak realm.
|
|
160
|
+
*/
|
|
161
|
+
|
|
162
|
+
exports.getProfile=function(){
|
|
163
|
+
return (kcAdminClientHandler.users.getProfile());
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* ***************************** - addToGroup - *******************************
|
|
169
|
+
* Adds a user to a specific group within the realm.
|
|
170
|
+
* @parameters:
|
|
171
|
+
* - parameters: is a JSON object that accepts this parameters
|
|
172
|
+
* - id [required]: The user ID of the user you want to add to the group.
|
|
173
|
+
* - groupId [required]: The group ID of the group the user should be added to.
|
|
174
|
+
*/
|
|
175
|
+
|
|
176
|
+
exports.addToGroup=function(parameters){
|
|
177
|
+
return (kcAdminClientHandler.users.addToGroup(parameters));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* ***************************** - delFromGroup - *******************************
|
|
182
|
+
* Removes a user from a specific group in Keycloak.
|
|
183
|
+
* @parameters:
|
|
184
|
+
* - parameters: is a JSON object that accepts this parameters
|
|
185
|
+
* - id [required]: The user ID of the user you want to remove to the group.
|
|
186
|
+
* - groupId [required]: The group ID of the group the user should be removed to.
|
|
187
|
+
*/
|
|
188
|
+
exports.delFromGroup=function(parameters){
|
|
189
|
+
return (kcAdminClientHandler.users.delFromGroup(parameters));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* ***************************** - countGroups - *******************************
|
|
194
|
+
* Retrieves the number of groups that a given user is a member of.
|
|
195
|
+
* @parameters:
|
|
196
|
+
* - filter is a JSON object that accepts filter parameters, such as { id: '' }
|
|
197
|
+
* - id: [required] The user ID of the user whose group membership count you want to retrieve.
|
|
198
|
+
* - search: [optional] a String containing group name such "cool-group",
|
|
199
|
+
*/
|
|
200
|
+
exports.countGroups=function(filter){
|
|
201
|
+
return (kcAdminClientHandler.users.countGroups(filter));
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* ***************************** - listGroups - *******************************
|
|
207
|
+
* Returns the list of groups that a given user is a member of.
|
|
208
|
+
* @parameters:
|
|
209
|
+
* - filter is a JSON object that accepts filter parameters, such as { id: '' }
|
|
210
|
+
* - id: [required] The user ID of the user whose group membership you want to retrieve.
|
|
211
|
+
* - search: [optional] a String containing group name such "cool-group",
|
|
212
|
+
*/
|
|
213
|
+
exports.listGroups=function(filter){
|
|
214
|
+
return (kcAdminClientHandler.users.listGroups(filter));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* ***************************** - addRealmRoleMappings - *******************************
|
|
219
|
+
* Assigns one or more realm-level roles to a user.
|
|
220
|
+
* Returns a promise that resolves when the roles are successfully assigned. No return value on success.
|
|
221
|
+
*
|
|
222
|
+
* @parameters:
|
|
223
|
+
* - roleMapping is a JSON object that accepts this parameters:
|
|
224
|
+
* - id: [required] The ID of the user to whom the roles will be assigned..
|
|
225
|
+
* - roles: [required] An array of role representations to assign. Each role object should contain at least:
|
|
226
|
+
* - id: [required] The role Id
|
|
227
|
+
* - name: [required] The role Name
|
|
228
|
+
*/
|
|
229
|
+
exports.addRealmRoleMappings=function(roleMapping){
|
|
230
|
+
return (kcAdminClientHandler.users.addRealmRoleMappings(roleMapping));
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* ***************************** - delRealmRoleMappings - *******************************
|
|
236
|
+
* Removes one or more realm-level roles from a specific user.
|
|
237
|
+
* Only roles that were directly assigned to the user can be removed with this method.
|
|
238
|
+
* This method does not affect composite roles. It only removes directly assigned realm roles.
|
|
239
|
+
*
|
|
240
|
+
* @parameters:
|
|
241
|
+
* - roleMapping is a JSON object that accepts this parameters:
|
|
242
|
+
* - id: [required] The ID of the user to whom the roles will be removed..
|
|
243
|
+
* - roles: [required] An array of role representations to remove. Each role object should contain at least:
|
|
244
|
+
* - id: [required] The role Id
|
|
245
|
+
* - name: [required] The role Name
|
|
246
|
+
*/
|
|
247
|
+
exports.delRealmRoleMappings=function(roleMapping){
|
|
248
|
+
return (kcAdminClientHandler.users.delRealmRoleMappings(roleMapping));
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* ***************************** - listAvailableRealmRoleMappings - *******************************
|
|
254
|
+
* Retrieves all available realm-level roles that can still be assigned to a specific user.
|
|
255
|
+
* These are the roles that exist in the realm but have not yet been mapped to the user.
|
|
256
|
+
*
|
|
257
|
+
* @parameters:
|
|
258
|
+
* - filter is a JSON object that accepts this parameters:
|
|
259
|
+
* - id: [required] The ID of the user for whom to list assignable realm roles.
|
|
260
|
+
*/
|
|
261
|
+
exports.listAvailableRealmRoleMappings=function(filter){
|
|
262
|
+
return (kcAdminClientHandler.users.listAvailableRealmRoleMappings(filter));
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* ***************************** - listRoleMappings - *******************************
|
|
268
|
+
* Retrieves all realm-level and client-level roles that are currently assigned to a specific user.
|
|
269
|
+
* @parameters:
|
|
270
|
+
* - filter is a JSON object that accepts this parameters:
|
|
271
|
+
* - id: [required] The user ID for which you want to fetch the assigned role mappings.
|
|
272
|
+
*
|
|
273
|
+
* @return a promise resolving to an object with two main properties:
|
|
274
|
+
* - realmMappings: array of realm-level roles assigned to the user.
|
|
275
|
+
* - clientMappings: object containing client roles grouped by client.
|
|
276
|
+
*/
|
|
277
|
+
exports.listRoleMappings=function(filter){
|
|
278
|
+
return (kcAdminClientHandler.users.listRoleMappings(filter));
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* ***************************** - listRealmRoleMappings - *******************************
|
|
284
|
+
* Retrieves the realm-level roles that are currently assigned to a specific user.
|
|
285
|
+
* Unlike listRoleMappings, this method focuses only on realm roles and excludes client roles.
|
|
286
|
+
*
|
|
287
|
+
* @parameters:
|
|
288
|
+
* - filter is a JSON object that accepts this parameters:
|
|
289
|
+
* - id: [required] The user ID for which you want to fetch the assigned role mappings.
|
|
290
|
+
*
|
|
291
|
+
* @return a promise resolving to an array of role objects (realm roles)
|
|
292
|
+
*/
|
|
293
|
+
exports.listRealmRoleMappings=function(filter){
|
|
294
|
+
return (kcAdminClientHandler.users.listRealmRoleMappings(filter));
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* ***************************** - listCompositeRealmRoleMappings - *******************************
|
|
299
|
+
* Retrieves the list of composite realm-level roles that are effectively assigned to a user.
|
|
300
|
+
* Composite roles include both directly assigned realm roles and any roles inherited through composite role structures.
|
|
301
|
+
* @parameters:
|
|
302
|
+
* - filter is a JSON object that accepts this parameters:
|
|
303
|
+
* - id: [required] The user ID for which you want to fetch the assigned role mappings.
|
|
304
|
+
*
|
|
305
|
+
* @return a promise resolving to an array of role objects (realm roles)
|
|
306
|
+
*/
|
|
307
|
+
exports.listCompositeRealmRoleMappings=function(filter){
|
|
308
|
+
return (kcAdminClientHandler.users.listCompositeRealmRoleMappings(filter));
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* ***************************** - addClientRoleMappings - *******************************
|
|
315
|
+
* Assigns one or more client-level roles to a user.
|
|
316
|
+
* This method adds role mappings from a specific client to the given user,
|
|
317
|
+
* allowing the user to have permissions defined by those client roles.
|
|
318
|
+
*
|
|
319
|
+
* @parameters:
|
|
320
|
+
* - role_mapping is a JSON object that accepts this parameters:
|
|
321
|
+
* - id: [required] The ID of the user to whom roles will be assigned.
|
|
322
|
+
* - clientUniqueId:[required] The internal ID of the client that owns the roles.
|
|
323
|
+
* - roles: [required] Array of role objects representing the client roles to assign, at least id and name should appear:
|
|
324
|
+
* - id:[required]: role identifier
|
|
325
|
+
* - name:[required]: role name
|
|
326
|
+
* - [optional] Other fields
|
|
327
|
+
*/
|
|
328
|
+
exports.addClientRoleMappings=function(role_mapping){
|
|
329
|
+
return (kcAdminClientHandler.users.addClientRoleMappings(role_mapping));
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* ***************************** - listAvailableClientRoleMappings - *******************************
|
|
336
|
+
* Retrieves a list of client roles that are available to be assigned to a specific user,
|
|
337
|
+
* meaning roles defined in a client that the user does not yet have assigned.
|
|
338
|
+
* This is useful for determining which roles can still be mapped to the user.
|
|
339
|
+
*
|
|
340
|
+
* @parameters:
|
|
341
|
+
* - filter is a JSON object that accepts this parameters:
|
|
342
|
+
* - id: [required] The ID of the user
|
|
343
|
+
* - clientUniqueId:[required] The internal ID of the client (not the clientId string)
|
|
344
|
+
*/
|
|
345
|
+
exports.listAvailableClientRoleMappings=function(filter){
|
|
346
|
+
return (kcAdminClientHandler.users.listAvailableClientRoleMappings(filter));
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* ***************************** - listCompositeClientRoleMappings - *******************************
|
|
352
|
+
* Retrieves all composite roles assigned to a specific user for a given client.
|
|
353
|
+
* Composite roles are roles that include other roles.
|
|
354
|
+
* This method returns not only directly assigned roles, but also roles inherited through composite definitions for that client.
|
|
355
|
+
*
|
|
356
|
+
* @parameters:
|
|
357
|
+
* - filter is a JSON object that accepts this parameters:
|
|
358
|
+
* - id: [required] The ID of the user
|
|
359
|
+
* - clientUniqueId:[required] The internal ID of the client (not the clientId string)
|
|
360
|
+
*/
|
|
361
|
+
|
|
362
|
+
exports.listCompositeClientRoleMappings=function(filter){
|
|
363
|
+
return (kcAdminClientHandler.users.listCompositeClientRoleMappings(filter));
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* ***************************** - listClientRoleMappings - *******************************
|
|
369
|
+
* Retrieves all client-level roles directly assigned to a user for a specific client.
|
|
370
|
+
* Unlike composite role mappings, this method only returns the roles that were explicitly
|
|
371
|
+
* assigned to the user from the client, without including roles inherited via composite definitions.
|
|
372
|
+
*
|
|
373
|
+
* @parameters:
|
|
374
|
+
* - filter is a JSON object that accepts this parameters:
|
|
375
|
+
* - id: [required] The ID of the user
|
|
376
|
+
* - clientUniqueId:[required] The internal ID of the client (not the clientId string)
|
|
377
|
+
*/
|
|
378
|
+
exports.listClientRoleMappings=function(filter){
|
|
379
|
+
return (kcAdminClientHandler.users.listClientRoleMappings(filter));
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* ***************************** - delClientRoleMappings - *******************************
|
|
385
|
+
* Removes one or more client-level roles previously assigned to a specific user.
|
|
386
|
+
* This operation unlinks the direct association between the user and the specified roles within the given client.
|
|
387
|
+
*
|
|
388
|
+
* @parameters:
|
|
389
|
+
* - filter is a JSON object that accepts this parameters:
|
|
390
|
+
* - id: [required] The ID of the user to whom roles will be removed.
|
|
391
|
+
* - clientUniqueId:[required] The internal ID of the client that owns the roles.
|
|
392
|
+
* - roles: [required] Array of role objects representing the client roles to assign, at least id and name should appear:
|
|
393
|
+
* - id:[required]: role identifier
|
|
394
|
+
* - name:[required]: role name
|
|
395
|
+
* - [optional] Other fields
|
|
396
|
+
*/
|
|
397
|
+
exports.delClientRoleMappings=function(filter){
|
|
398
|
+
return (kcAdminClientHandler.users.delClientRoleMappings(filter));
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* ***************************** - listSessions - *******************************
|
|
405
|
+
* Retrieves a list of active user sessions for the specified user.
|
|
406
|
+
* Each session represents a login session associated with that user across different clients or devices.
|
|
407
|
+
*
|
|
408
|
+
* @parameters:
|
|
409
|
+
* - filter is a JSON object that accepts this parameters:
|
|
410
|
+
* - id: [required] The ID of the user whose sessions will be listed.
|
|
411
|
+
* - clientId: [optional] The internal ID of the client that owns the roles.
|
|
412
|
+
*/
|
|
413
|
+
exports.listSessions=function(filter){
|
|
414
|
+
return (kcAdminClientHandler.users.listSessions(filter));
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* ***************************** - listOfflineSessions - *******************************
|
|
420
|
+
* Retrieves a list of offline sessions for the specified user.
|
|
421
|
+
* Offline sessions represent long-lived refresh tokens that allow clients to obtain new access tokens
|
|
422
|
+
* without requiring the user to be actively logged in.
|
|
423
|
+
*
|
|
424
|
+
*@parameters:
|
|
425
|
+
* - filter is a JSON object that accepts this parameters:
|
|
426
|
+
* - id: [required] The ID of the user whose sessions will be listed
|
|
427
|
+
* - clientId: [optional] The client ID whose sessions are being checked
|
|
428
|
+
*/
|
|
429
|
+
exports.listOfflineSessions=function(filter){
|
|
430
|
+
return (kcAdminClientHandler.users.listOfflineSessions(filter));
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* ***************************** - logout - *******************************
|
|
436
|
+
* Forces logout of the specified user from all active sessions, both online and offline.
|
|
437
|
+
* This invalidates the user’s active sessions and tokens, effectively logging them out from all clients
|
|
438
|
+
*
|
|
439
|
+
* @parameters:
|
|
440
|
+
* - filter is a JSON object that accepts this parameters:
|
|
441
|
+
* - id: [required] The ID of the user whose sessions will be closed
|
|
442
|
+
*/
|
|
443
|
+
exports.logout=function(filter){
|
|
444
|
+
return (kcAdminClientHandler.users.logout(filter));
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* ***************************** - listConsents - *******************************
|
|
450
|
+
* Retrieves the list of OAuth2 client consents that the specified user has granted.
|
|
451
|
+
* Each consent represents a client application that the user has authorized to access their data with specific scopes.
|
|
452
|
+
*
|
|
453
|
+
* @parameters:
|
|
454
|
+
* - filter is a JSON object that accepts this parameters:
|
|
455
|
+
* - id: [required] The ID of the user whose client consents can be retrieved.
|
|
456
|
+
*/
|
|
457
|
+
exports.listConsents=function(filter){
|
|
458
|
+
return (kcAdminClientHandler.users.listConsents(filter));
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* ***************************** - revokeConsent - *******************************
|
|
464
|
+
* Revokes a previously granted OAuth2 client consent for a specific user.
|
|
465
|
+
* This operation removes the authorization a user has given to a client,
|
|
466
|
+
* effectively disconnecting the client from the user's account and invalidating associated tokens.
|
|
467
|
+
*
|
|
468
|
+
* @parameters:
|
|
469
|
+
* - filter is a JSON object that accepts this parameters:
|
|
470
|
+
* - id: [required] The ID of the user whose consent should be revoked
|
|
471
|
+
* - clientId: [required] TThe client ID for which the consent should be revoked
|
|
472
|
+
*/
|
|
473
|
+
exports.revokeConsent=function(filter){
|
|
474
|
+
return (kcAdminClientHandler.users.revokeConsent(filter));
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* ***************************** - impersonation - *******************************
|
|
480
|
+
* Initiates an impersonation session for a specific user.
|
|
481
|
+
* This allows an administrator to act on behalf of the user, gaining access as if they were logged in as that user.
|
|
482
|
+
* This is typically used for debugging or support purposes.
|
|
483
|
+
* Returns an object containing a redirect URL or token used to impersonate the user.
|
|
484
|
+
*
|
|
485
|
+
* @parameters:
|
|
486
|
+
* - filter is a JSON object that accepts this parameters:
|
|
487
|
+
* - id: [required] The ID of the user to impersonate.
|
|
488
|
+
* - realmName: [optional] the name of the realm
|
|
489
|
+
*/
|
|
490
|
+
exports.impersonation=function(filter){
|
|
491
|
+
return (kcAdminClientHandler.users.impersonation(filter));
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* ***************************** - listFederatedIdentities - *******************************
|
|
496
|
+
* Retrieves a list of federated identities (external identity providers) associated with a specific user.
|
|
497
|
+
* This is useful if the user has linked their account with external providers like Google, Facebook, etc.
|
|
498
|
+
*
|
|
499
|
+
* @parameters:
|
|
500
|
+
*
|
|
501
|
+
* - filter is a JSON object that accepts this parameters:
|
|
502
|
+
* - id: [required] The unique ID of the user for whom you want to fetch the federated identities.
|
|
503
|
+
*/
|
|
504
|
+
exports.listFederatedIdentities=function(filter){
|
|
505
|
+
return (kcAdminClientHandler.users.listFederatedIdentities(filter));
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* ***************************** - addToFederatedIdentity - *******************************
|
|
511
|
+
* Adds (links) an external identity provider to a specific Keycloak user.
|
|
512
|
+
* This is typically used to associate a federated identity (such as a Google or Facebook account) with an existing Keycloak user.
|
|
513
|
+
*
|
|
514
|
+
* @parameters:
|
|
515
|
+
* - options is a JSON object that accepts this parameters:
|
|
516
|
+
* - id: [required] The ID of the Keycloak user to whom the federated identity should be added.
|
|
517
|
+
* - federatedIdentityId: [required] The alias of the identity provider (e.g., "google" or "facebook").
|
|
518
|
+
* - federatedIdentity [required] An object with the following fields:
|
|
519
|
+
* - identityProvider:[required] The alias of the identity provider.
|
|
520
|
+
* - userId: [required] The ID of the user in the external identity provider.
|
|
521
|
+
* - userName: [required] The username in the external identity provider.
|
|
522
|
+
*/
|
|
523
|
+
exports.addToFederatedIdentity=function(options){
|
|
524
|
+
return (kcAdminClientHandler.users.addToFederatedIdentity(options));
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* ***************************** - delFromFederatedIdentity - *******************************
|
|
531
|
+
* Removes (unlinks) a federated identity provider from a specific Keycloak user.
|
|
532
|
+
* This operation dissociates the external identity (e.g., a Google or Facebook account) previously linked to the user.
|
|
533
|
+
*
|
|
534
|
+
* @parameters:
|
|
535
|
+
* - options is a JSON object that accepts this parameters:
|
|
536
|
+
* - id: [required] The ID of the Keycloak user from whom the federated identity should be removed.
|
|
537
|
+
* - federatedIdentityId: [required] The alias of the identity provider (e.g., "google" or "facebook").
|
|
538
|
+
*/
|
|
539
|
+
exports.delFromFederatedIdentity=function(options){
|
|
540
|
+
return (kcAdminClientHandler.users.delFromFederatedIdentity(options));
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* ***************************** - getUserStorageCredentialTypes - *******************************
|
|
545
|
+
* For more details, see the keycloak-admin-client package in the Keycloak GitHub repository.
|
|
546
|
+
*/
|
|
547
|
+
exports.getUserStorageCredentialTypes=function(){
|
|
548
|
+
return (kcAdminClientHandler.users.getUserStorageCredentialTypes());
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* ***************************** - CREATE - *******************************
|
|
553
|
+
* For more details, see the keycloak-admin-client package in the Keycloak GitHub repository.
|
|
554
|
+
*/
|
|
555
|
+
exports.updateCredentialLabel=function(){
|
|
556
|
+
return (kcAdminClientHandler.users.updateCredentialLabel());
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
|