dms-middleware-auth 1.0.0 → 1.0.1

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.
@@ -90,20 +90,22 @@ let AuthMiddleware = class AuthMiddleware {
90
90
  if (!clientAttributes[req.originalUrl]) {
91
91
  return res.status(403).json({ message: 'Access denied for this route' });
92
92
  }
93
- // Cache user details
94
- const userName = decoded.preferred_username;
95
- let userAttributes = await this.cacheManager.get(userName);
93
+ // Cache interface details
94
+ /*const userName = decoded.preferred_username;
95
+ let userAttributes: any = await this.cacheManager.get(userName);
96
96
  if (!userAttributes) {
97
- userAttributes = await this.getUserDetails(userName, clientToken);
98
- userAttributes = JSON.stringify(userAttributes.attributes);
99
- await this.cacheManager.set(userName, userAttributes, 0);
97
+ userAttributes = await this.getUserDetails(userName, clientToken);
98
+ userAttributes = JSON.stringify(userAttributes.attributes);
99
+ await this.cacheManager.set(userName, userAttributes, 0);
100
100
  }
101
+
101
102
  // Attach attributes to request
102
- userAttributes = JSON.parse(userAttributes);
103
- req['attributes'] = {
104
- client: clientAttributes[req.originalUrl],
105
- user: userAttributes,
106
- };
103
+ userAttributes = JSON.parse(userAttributes);*/
104
+ req['role'] = role;
105
+ // req['attributes'] = {
106
+ // client: clientAttributes[req.originalUrl],
107
+ // // user: userAttributes,
108
+ // };
107
109
  return next();
108
110
  }
109
111
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dms-middleware-auth",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Reusable middleware for authentication and authorization in NestJS applications.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -42,8 +42,6 @@ export class AuthMiddleware implements NestMiddleware {
42
42
  clientToken = await this.clientLogin();
43
43
  const decodedToken: any = jwt.decode(clientToken);
44
44
  const ttl = (decodedToken.exp - Math.floor(Date.now() / 1000)) * 1000;
45
-
46
-
47
45
  await this.cacheManager.set('client_access_token', clientToken, ttl );
48
46
  }
49
47
 
@@ -63,8 +61,8 @@ export class AuthMiddleware implements NestMiddleware {
63
61
  return res.status(403).json({ message: 'Access denied for this route' });
64
62
  }
65
63
 
66
- // Cache user details
67
- const userName = decoded.preferred_username;
64
+ // Cache interface details
65
+ /*const userName = decoded.preferred_username;
68
66
  let userAttributes: any = await this.cacheManager.get(userName);
69
67
  if (!userAttributes) {
70
68
  userAttributes = await this.getUserDetails(userName, clientToken);
@@ -73,11 +71,12 @@ export class AuthMiddleware implements NestMiddleware {
73
71
  }
74
72
 
75
73
  // Attach attributes to request
76
- userAttributes = JSON.parse(userAttributes);
77
- req['attributes'] = {
78
- client: clientAttributes[req.originalUrl],
79
- user: userAttributes,
80
- };
74
+ userAttributes = JSON.parse(userAttributes);*/
75
+ req['role'] = role;
76
+ // req['attributes'] = {
77
+ // client: clientAttributes[req.originalUrl],
78
+ // // user: userAttributes,
79
+ // };
81
80
 
82
81
  return next();
83
82
  } catch (error:any) {