keycloak-api-manager 2.0.7 → 2.0.9
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 +1 -1
- package/index.js +25 -13
- package/package.json +1 -1
package/.idea/workspace.xml
CHANGED
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
<option name="presentableId" value="Default" />
|
|
80
80
|
<updated>1759849149064</updated>
|
|
81
81
|
<workItem from="1759849150239" duration="1214000" />
|
|
82
|
-
<workItem from="1759917554117" duration="
|
|
82
|
+
<workItem from="1759917554117" duration="66482000" />
|
|
83
83
|
</task>
|
|
84
84
|
<servers />
|
|
85
85
|
</component>
|
package/index.js
CHANGED
|
@@ -39,11 +39,15 @@ let configAdminclient=null;
|
|
|
39
39
|
*/
|
|
40
40
|
exports.configure=async function(adminClientCredentials){
|
|
41
41
|
configAdminclient={
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
baseUrl:adminClientCredentials.baseUrl,
|
|
43
|
+
realmName:adminClientCredentials.realmName
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
kcAdminClient= new keycloakAdminClient(configAdminclient);
|
|
47
|
+
configAdminclient.clientId=adminClientCredentials.clientId;
|
|
48
|
+
configAdminclient.clientSecret=adminClientCredentials.clientSecret;
|
|
49
|
+
|
|
50
|
+
|
|
47
51
|
let tokenLifeSpan= (adminClientCredentials.tokenLifeSpan *1000)/2;
|
|
48
52
|
delete adminClientCredentials.baseUrl;
|
|
49
53
|
delete adminClientCredentials.realmName;
|
|
@@ -102,21 +106,29 @@ exports.getToken=function(configToOverride){
|
|
|
102
106
|
//TODO: Remove da documentare
|
|
103
107
|
//permette ad un utente o un client di autenticarsi su keycloack ed oottenere un token
|
|
104
108
|
exports.auth=async function(credentials){
|
|
109
|
+
credentials.client_id=configAdminclient.clientId;
|
|
110
|
+
credentials.client_secret=configAdminclient.clientSecret;
|
|
105
111
|
let options={
|
|
106
|
-
url: `${configAdminclient.baseUrl}
|
|
107
|
-
headers: {'
|
|
108
|
-
|
|
109
|
-
body: credentials
|
|
112
|
+
url: `${configAdminclient.baseUrl}realms/${configAdminclient.realmName}/protocol/openid-connect/token` ,
|
|
113
|
+
headers: {'content-type': 'application/www-form-urlencoded', 'Authorization': "Bearer " + kcAdminClient.accessToken },
|
|
114
|
+
form: credentials
|
|
110
115
|
}
|
|
111
116
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
console.log(options);
|
|
118
|
+
|
|
119
|
+
return new Promise((resolve, reject) => {
|
|
120
|
+
request.post(options, function (error, response, body) {
|
|
121
|
+
if (error) {
|
|
122
|
+
console.error("Internal Server Error:", error);
|
|
123
|
+
reject(error);
|
|
124
|
+
} else {
|
|
125
|
+
resolve(JSON.parse(body)); // ✅ restituisce il valore al chiamante
|
|
126
|
+
}
|
|
127
|
+
});
|
|
118
128
|
});
|
|
119
|
-
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
|
|
120
132
|
|
|
121
133
|
|
|
122
134
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keycloak-api-manager",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.9",
|
|
4
4
|
"description": "Keycloak-api-manager is a lightweight Node.js wrapper for the Keycloak Admin REST API. It provides an easy-to-use functional methods and functions to manage realms, users, roles, clients, groups, and permissions directly from your application code — just like you would from the Keycloak admin console.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|