keycloak-express-middleware 4.1.1 → 4.2.0

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.
Files changed (3) hide show
  1. package/README.md +5 -5
  2. package/index.js +12 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -14,7 +14,7 @@ it is based on **'keycloak-connect'**, and **'express-session'**
14
14
  - 👤 User info extraction from token
15
15
  - 🌍 CORS support and integration with frontend apps (SPA or mobile)
16
16
  ---
17
- ## ⚠️ keycloak-express-middleware evolution by Version 4.0.0
17
+ ## ⚠️ keycloak-express-middleware evolution starting from Version 4.0.0
18
18
  The new version of keycloak-express-middleware introduces a substantial evolution in its architecture.
19
19
  It now embraces an object-oriented paradigm, which means each instance of the middleware is self-contained and independent.
20
20
  Concretely, you can instantiate the library multiple times within the same application—each time pointing to a different client in Keycloak
@@ -33,7 +33,7 @@ independent object instances — something that the earlier version did not supp
33
33
 
34
34
  🧩 Old Version (pre–object-oriented)
35
35
  ```js
36
- // OLD VERSION UNTILL 3.0.9
36
+ // OLD VERSION UP TO 3.0.9
37
37
  const express = require('express');
38
38
  const keycloackAdapter = require('keycloak-express-middleware');
39
39
 
@@ -66,7 +66,7 @@ app.get('/privateStaticClientRole', keycloackAdapter.protectMiddleware("admin"),
66
66
  🆕 New Version (Object-Oriented Design) Up to 4.0.0
67
67
 
68
68
  ```js
69
- // NEW VERSION UP TO 4.0.0
69
+ // NEW VERSION STARTING FROM 4.0.0
70
70
  const express = require('express');
71
71
  const { keycloackAdapter } = require('keycloak-express-middleware');
72
72
 
@@ -151,7 +151,7 @@ const express = require('express');
151
151
  const keycloackAdapterClass = require('keycloak-express-middleware'); // import keycloackAdapter from 'keycloak-express-middleware';
152
152
 
153
153
  /*
154
- Old Style until version 3.0.9
154
+ Old Style up to version 3.0.9
155
155
  const keycloackAdapter = require('keycloak-express-middleware'); // import keycloackAdapter from 'keycloak-express-middleware';
156
156
  */
157
157
 
@@ -176,7 +176,7 @@ keycloackAdapter= new keycloackAdapterClass(app,{
176
176
  });
177
177
 
178
178
  /*
179
- OLD STYLE UNTIL VERSION 3.0.9
179
+ OLD STYLE UP TO VERSION 3.0.9
180
180
  // Configure and Initialize Keycloak adapter
181
181
  await keycloackAdapter.configure(app,{
182
182
  "realm": "Realm-Project",
package/index.js CHANGED
@@ -59,6 +59,8 @@ class keycloakExpressMiddleware {
59
59
  this.keycloak = null;
60
60
  this.ready=false;
61
61
  this.readyQueue=[];
62
+ this.realmName=keyCloackConfig.realm || keyCloackOptions.realmName;
63
+ this.authServerUrl=keyCloackConfig['auth-server-url'];
62
64
  if(keyCloackOptions){
63
65
  if (keyCloackOptions.session){
64
66
  const memoryStore = new session.MemoryStore();
@@ -1248,8 +1250,18 @@ class keycloakExpressMiddleware {
1248
1250
  }else res.redirect(redirectTo);
1249
1251
  }
1250
1252
 
1253
+
1254
+ redirectToUserAccountConsole(req,res){
1255
+ let redirectUrL=`${this.authServerUrl}/realms/${this.realmName}/account/`
1256
+ res.redirect(redirectUrL);
1257
+ }
1258
+
1259
+
1260
+
1261
+
1251
1262
  }
1252
1263
 
1264
+
1253
1265
  module.exports = keycloakExpressMiddleware;
1254
1266
 
1255
1267
  /*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keycloak-express-middleware",
3
- "version": "4.1.1",
3
+ "version": "4.2.0",
4
4
  "description": "Adapter API to integrate Node.js (Express) applications with Keycloak. Provides middleware for authentication, authorization, token validation, and route protection via OpenID Connect.",
5
5
  "main": "index.js",
6
6
  "scripts": {