keycloak-api-manager 2.0.3 → 2.0.4

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.
@@ -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="53158000" />
82
+ <workItem from="1759917554117" duration="56530000" />
83
83
  </task>
84
84
  <servers />
85
85
  </component>
package/README.md CHANGED
@@ -100,6 +100,7 @@ await KeycloakManager.configure({
100
100
  username: 'admin', // Admin username
101
101
  password: 'admin', // Admin password
102
102
  grantType: 'password', // Type of authentication
103
+ tokenLifeSpan: 120 // access_token Lifetime in seconds
103
104
  });
104
105
 
105
106
 
@@ -169,6 +170,7 @@ await KeycloakManager.configure({
169
170
  username: 'admin', // Admin username
170
171
  password: 'admin', // Admin password
171
172
  grantType: 'password', // Type of authentication
173
+ tokenLifeSpan: 120 // access_token Lifetime in seconds
172
174
  });
173
175
  ```
174
176
 
@@ -185,6 +187,7 @@ Parameters:
185
187
  Main supported options:
186
188
  - grantType: [required] The OAuth2 grant type used for authentication. example "password". Possible values: 'password', 'client_credentials', 'refresh_token', etc.
187
189
  - clientId: [required] string containing the client ID configured in Keycloak. Required for all grant types.
190
+ - tokenLifeSpan: [required] Lifetime of an access token expressed in seconds. It indicates how often the access token should be renewed. If set incorrectly and the Keycloak token expires before the renewal interval defined by this parameter, errors and exceptions may occur
188
191
  - username: [optional] string username. Required when using the password grant type.
189
192
  - password: [optional] string password. Required when using the password grant type.
190
193
  - baseUrl: [Optional] Keycloak base Url
package/index.js CHANGED
@@ -36,6 +36,7 @@ var authenticationManagementHandler=require('./Handlers/authenticationManagement
36
36
  * - password: [Optional] string password. Required when using the password grant type.
37
37
  * - grantType: The OAuth2 grant type used for authentication.
38
38
  * Possible values: 'password', 'client_credentials', 'refresh_token', etc.
39
+ * - tokenLifeSpan: Lifetime of an access token expressed in seconds.
39
40
  * - clientId: string containing the client ID configured in Keycloak. Required for all grant types.
40
41
  * - clientSecret: [Optional] string containing the client secret of the client. Required for client_credentials or confidential clients.
41
42
  * - totp: string for Time-based One-Time Password (TOTP) for multi-factor authentication (MFA), if enabled for the user.
@@ -52,6 +53,10 @@ exports.configure=async function(adminClientCredentials){
52
53
  delete adminClientCredentials.realmName;
53
54
  await kcAdminClient.auth(adminClientCredentials);
54
55
 
56
+ setInterval(async ()=>{
57
+ await kcAdminClient.auth(adminClientCredentials);
58
+ },adminClientCredentials.tokenLifeSpan*1000);
59
+
55
60
  realmHandler.setKcAdminClient(kcAdminClient);
56
61
  exports.realms=realmHandler;
57
62
 
@@ -85,11 +90,11 @@ exports.configure=async function(adminClientCredentials){
85
90
 
86
91
 
87
92
  //TODO: Remove da documentare
88
- exports.setConfig=async function(configToOverride){
93
+ exports.setConfig=function(configToOverride){
89
94
  return(kcAdminClient.setConfig(configToOverride));
90
95
  }
91
96
  //TODO: Remove da documentare
92
- exports.getToken=async function(configToOverride){
97
+ exports.getToken=function(configToOverride){
93
98
  return({
94
99
  accessToken:kcAdminClient.accessToken,
95
100
  refreshToken:kcAdminClient.refreshToken,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keycloak-api-manager",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
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": {