ef-keycloak-connect 1.2.1 → 1.2.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/README.md +8 -2
- package/package.json +1 -1
- package/services/keycloakService.js +32 -21
package/README.md
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
# Node JS
|
|
1
|
+
# Node JS adapter for keycloak
|
|
2
2
|
Keycloak is an Open Source Identity and Access Management solution for modern Applications and Services.
|
|
3
3
|
|
|
4
4
|
This repository contains the source code for the Keycloak Node.js adapter. This module makes it simple to implement a Node.js Connect-friendly application that uses Keycloak for its authentication and authorization needs.
|
|
5
5
|
|
|
6
6
|
[Documentation](https://www.keycloak.org/documentation.html)
|
|
7
7
|
|
|
8
|
+
# EF Keycloak Connect
|
|
9
|
+
|
|
10
|
+
**ef-keycloak-connect** extends on the functionality of Keycloak Node JS adapter by using Keycloak APIs to simplify its functionality. This package provides functions to Authencticate a user, get access token with introspect, create and delete resource, create users, roles and assign role to users.
|
|
11
|
+
|
|
12
|
+
**ef-keycloak-connect** also includes the functions to authenticate users from Cisco Finesse for both SSO and Non SSO instances.
|
|
13
|
+
|
|
8
14
|
## Getting started
|
|
9
15
|
|
|
10
16
|
### Installation
|
|
@@ -193,7 +199,7 @@ This function performs 3 functionalities based on arguments/parameters provided.
|
|
|
193
199
|
***Finesse User Auth and Sync with keycloak (SSO)***
|
|
194
200
|
For Finesse User Auth (Non SSO) we use the function as follows
|
|
195
201
|
```
|
|
196
|
-
|
|
202
|
+
authenticateUserViaKeycloak('johndoe', '', `https://${finesse_server_url}:${port}`, ['agent','supervisor'], 'eyJhbGciOiJkaXIiLCJjdHkiOiJKV1QiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0..oPk0ttAA')
|
|
197
203
|
```
|
|
198
204
|
Difference between *Finesse User Auth(SSO)* and *Finesse User Auth(Non SSO)* is that SSO uses finesse_token field while Password field remains ' ', while in Non SSO a Password is sent by user and finesse_token field remains ' '
|
|
199
205
|
|
package/package.json
CHANGED
|
@@ -584,39 +584,50 @@ class KeycloakService extends Keycloak{
|
|
|
584
584
|
let count = 0;
|
|
585
585
|
let flag = true;
|
|
586
586
|
let obj = []; // final object to be returned
|
|
587
|
-
|
|
587
|
+
|
|
588
588
|
for (let i = 0; i < keycloak_roles.length; i++) {
|
|
589
589
|
try {
|
|
590
|
-
|
|
590
|
+
|
|
591
|
+
config.url = keycloakConfig["auth-server-url"] + 'admin/realms/' + keycloakConfig.realm + '/roles/' + keycloak_roles[i] + '/users?max=100000'
|
|
591
592
|
let getUsersfromRoles = await requestController.httpRequest(config, true);
|
|
592
593
|
userObject = getUsersfromRoles.data;
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
594
|
+
|
|
595
|
+
userObject.forEach((user) => {
|
|
596
|
+
|
|
597
|
+
if(count > 0){
|
|
598
|
+
|
|
599
|
+
let userIndex = obj.findIndex(usr => {
|
|
600
|
+
return usr.username == user.username;
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
if(userIndex != -1){
|
|
604
|
+
obj[userIndex].roles.push(keycloak_roles[i]);
|
|
598
605
|
flag = false;
|
|
599
|
-
|
|
606
|
+
}
|
|
600
607
|
}
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
'
|
|
606
|
-
'
|
|
608
|
+
|
|
609
|
+
if(flag == true){
|
|
610
|
+
|
|
611
|
+
obj.push({
|
|
612
|
+
'id': user.id,
|
|
613
|
+
'username': user.username,
|
|
614
|
+
'firstName': ((user.firstName == undefined)? "" : user.firstName),
|
|
615
|
+
'lastName': ((user.lastName == undefined)? "" : user.lastName),
|
|
607
616
|
'roles': [keycloak_roles[i]]
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
obj[count].firstName = "";
|
|
611
|
-
obj[count].lastName = "";
|
|
612
|
-
}
|
|
613
|
-
count = count + 1;
|
|
617
|
+
})
|
|
618
|
+
|
|
614
619
|
}
|
|
615
|
-
|
|
620
|
+
|
|
621
|
+
flag = true;
|
|
622
|
+
|
|
623
|
+
});
|
|
624
|
+
|
|
616
625
|
}
|
|
617
626
|
catch (er) {
|
|
618
627
|
reject(er);
|
|
619
628
|
}
|
|
629
|
+
|
|
630
|
+
count++;
|
|
620
631
|
}
|
|
621
632
|
resolve(obj);
|
|
622
633
|
}
|