keycloak-express-middleware 4.2.1 → 4.4.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.
- package/index.js +9 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -323,7 +323,15 @@ class keycloakExpressMiddleware {
|
|
|
323
323
|
*/
|
|
324
324
|
|
|
325
325
|
protectMiddleware(conditions){
|
|
326
|
-
return(this.keycloak.protect(conditions));
|
|
326
|
+
//return(this.keycloak.protect(conditions));
|
|
327
|
+
|
|
328
|
+
const self = this;
|
|
329
|
+
return function(req, res, next){
|
|
330
|
+
conditions = Array.isArray(conditions) ? conditions : [conditions];
|
|
331
|
+
return self.keycloak.protect((token) => {
|
|
332
|
+
return conditions.some((role) => typeof role === 'string' && token.hasRole(role));
|
|
333
|
+
})(req, res, next);
|
|
334
|
+
}
|
|
327
335
|
}
|
|
328
336
|
|
|
329
337
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keycloak-express-middleware",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.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": {
|