dms-middleware-auth 1.1.4 → 1.1.6
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.d.ts +23 -16
- package/dist/auth.middleware.js +339 -205
- package/package.json +1 -1
- package/src/auth.middleware.ts +421 -220
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NestMiddleware, OnModuleInit } from '@nestjs/common';
|
|
2
2
|
import { Response, NextFunction } from 'express';
|
|
3
|
-
import { Cache } from 'cache-manager';
|
|
3
|
+
import type { Cache } from 'cache-manager';
|
|
4
4
|
interface AuthMiddlewareOptions {
|
|
5
5
|
publicKey: string;
|
|
6
6
|
keycloakUrl: string;
|
|
@@ -9,36 +9,43 @@ interface AuthMiddlewareOptions {
|
|
|
9
9
|
clientSecret: string;
|
|
10
10
|
clientUuid: string;
|
|
11
11
|
bypassURL: string;
|
|
12
|
+
licenceServiceUrl?: string;
|
|
12
13
|
}
|
|
13
14
|
export declare class AuthMiddleware implements NestMiddleware, OnModuleInit {
|
|
14
|
-
private cacheManager;
|
|
15
|
+
private readonly cacheManager;
|
|
15
16
|
private readonly options;
|
|
17
|
+
private readonly logger;
|
|
16
18
|
private static licenceExpired;
|
|
17
|
-
private static shutdownTimer;
|
|
18
|
-
private static licenceExpiryTimer;
|
|
19
19
|
private static licenceValidatedUntilMs;
|
|
20
20
|
private static licenceValidationPromise;
|
|
21
21
|
private static shutdownInitiated;
|
|
22
|
+
private static shutdownTimer;
|
|
23
|
+
private static licenceExpiryInterval;
|
|
22
24
|
private static readonly licenceExpiredMessage;
|
|
23
25
|
private static readonly CLOCK_TOLERANCE_MS;
|
|
24
|
-
private static readonly
|
|
25
|
-
private readonly
|
|
26
|
+
private static readonly LIC_EXPIRY_CHECK_INTERVAL_MS;
|
|
27
|
+
private static readonly MAX_SAFE_TTL_MS;
|
|
28
|
+
private static readonly MAX_SAFE_TTL_SECONDS;
|
|
29
|
+
private static readonly LIC_CACHE_TTL_SECONDS;
|
|
30
|
+
private static readonly CLIENT_TOKEN_TTL_MAX_SECONDS;
|
|
31
|
+
private static readonly CLIENT_TOKEN_TTL_SAFETY_SKEW_SECONDS;
|
|
32
|
+
private static readonly ROLE_ATTRIBUTES_TTL_SECONDS;
|
|
26
33
|
constructor(cacheManager: Cache, options: AuthMiddlewareOptions);
|
|
27
34
|
onModuleInit(): Promise<void>;
|
|
28
35
|
use(req: any, res: Response, next: NextFunction): Promise<void | Response<any, Record<string, any>>>;
|
|
29
|
-
private
|
|
30
|
-
private getUserDetails;
|
|
31
|
-
private getClientRoleAttributes;
|
|
32
|
-
private checkLicenceAndValidate;
|
|
33
|
-
private getLicencingDetails;
|
|
34
|
-
private validateLicence;
|
|
36
|
+
private enforceLicenceExpiry;
|
|
35
37
|
private markLicenceExpired;
|
|
36
|
-
private scheduleLicenceShutdown;
|
|
37
38
|
private stopServer;
|
|
38
|
-
private
|
|
39
|
-
private
|
|
40
|
-
private
|
|
39
|
+
private checkLicenceAndValidate;
|
|
40
|
+
private validateLicence;
|
|
41
|
+
private getLicencingTokenFromService;
|
|
42
|
+
private getOrFetchClientAccessToken;
|
|
43
|
+
private clientLogin;
|
|
44
|
+
private getClientRoleAttributes;
|
|
45
|
+
private verifyLicenceJwt;
|
|
41
46
|
private decodeAccessToken;
|
|
42
47
|
private extractBearerToken;
|
|
48
|
+
private normalizeEpochMs;
|
|
49
|
+
private cacheSetSeconds;
|
|
43
50
|
}
|
|
44
51
|
export {};
|