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 CHANGED
@@ -1,10 +1,16 @@
1
- # Node JS module for keycloak
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
- authenticateFinesse('johndoe', '', `https://${finesse_server_url}:${port}`, ['agent','supervisor'], 'eyJhbGciOiJkaXIiLCJjdHkiOiJKV1QiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0..oPk0ttAA')
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ef-keycloak-connect",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "Node JS keycloak adapter for authentication and authorization.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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
- let rolesCount = 0;
587
+
588
588
  for (let i = 0; i < keycloak_roles.length; i++) {
589
589
  try {
590
- config.url = keycloakConfig["auth-server-url"] + 'admin/realms/' + keycloakConfig.realm + '/roles/' + keycloak_roles[i] + '/users'
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
- for (let check = 0; check < userObject.length; check++) {
594
- let tobecheckedID = userObject[check].id;
595
- for (let org = 0; org < count; org++) {
596
- if (tobecheckedID === obj[org].id) {
597
- obj[org].roles[++rolesCount] = keycloak_roles[i];
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
- if (flag == true) {
602
- obj[count] = {
603
- 'id': userObject[check].id,
604
- 'username': userObject[check].username,
605
- 'firstName': userObject[check].firstName,
606
- 'lastName': userObject[check].lastName,
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
- if (obj[count].firstName == undefined) {
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
  }