dms-middleware-auth 1.0.6 → 1.0.8
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/dist/auth.middleware.js +10 -0
- package/package.json +1 -1
- package/src/auth.middleware.ts +16 -0
package/dist/auth.middleware.js
CHANGED
|
@@ -90,6 +90,16 @@ 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
|
+
else {
|
|
94
|
+
const apiPermission = JSON.parse(clientAttributes[req.originalUrl]);
|
|
95
|
+
if (apiPermission?.params === "true") {
|
|
96
|
+
const event = req?.body?.event;
|
|
97
|
+
const url = req?.originalUrl + `?action=${event}`;
|
|
98
|
+
if (!clientAttributes[url]) {
|
|
99
|
+
return res.status(403).json({ message: 'Access denied for event' });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
93
103
|
// Cache interface details
|
|
94
104
|
/*const userName = decoded.preferred_username;
|
|
95
105
|
let userAttributes: any = await this.cacheManager.get(userName);
|
package/package.json
CHANGED
package/src/auth.middleware.ts
CHANGED
|
@@ -42,6 +42,8 @@ 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
|
+
|
|
45
47
|
await this.cacheManager.set('client_access_token', clientToken, ttl );
|
|
46
48
|
}
|
|
47
49
|
|
|
@@ -57,9 +59,23 @@ export class AuthMiddleware implements NestMiddleware {
|
|
|
57
59
|
|
|
58
60
|
// Check route access
|
|
59
61
|
clientAttributes = JSON.parse(clientAttributes);
|
|
62
|
+
|
|
60
63
|
if (!clientAttributes[req.originalUrl]) {
|
|
64
|
+
|
|
61
65
|
return res.status(403).json({ message: 'Access denied for this route' });
|
|
62
66
|
}
|
|
67
|
+
else {
|
|
68
|
+
const apiPermission = JSON.parse(clientAttributes[req.originalUrl]);
|
|
69
|
+
if (apiPermission?.params === "true")
|
|
70
|
+
{
|
|
71
|
+
const event = req?.body?.event;
|
|
72
|
+
const url = req?.originalUrl + `?action=${event}`;
|
|
73
|
+
if (!clientAttributes[url]){
|
|
74
|
+
return res.status(403).json({ message: 'Access denied for event' });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
63
79
|
|
|
64
80
|
// Cache interface details
|
|
65
81
|
/*const userName = decoded.preferred_username;
|