@nathapp/nestjs-microservices 4.2.0 → 4.2.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.
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { JwtAuthGuard } from "@nathapp/nestjs-auth";
|
|
1
2
|
import { ExecutionContext } from "@nestjs/common";
|
|
2
3
|
import { Reflector } from "@nestjs/core";
|
|
3
|
-
declare
|
|
4
|
-
|
|
5
|
-
private
|
|
6
|
-
|
|
7
|
-
constructor(reflector: Reflector);
|
|
4
|
+
export declare class JwtMsAuthGuard extends JwtAuthGuard {
|
|
5
|
+
private readonly msReflector;
|
|
6
|
+
private readonly msLogger;
|
|
7
|
+
constructor(msReflector: Reflector);
|
|
8
8
|
canActivate(context: ExecutionContext): boolean | Promise<boolean> | import("rxjs").Observable<boolean>;
|
|
9
|
-
handleRequest(err: Error | null, user: any, info: any, context
|
|
9
|
+
handleRequest(err: Error | null, user: any, info: any, context?: ExecutionContext): any;
|
|
10
10
|
}
|
|
11
|
-
export {};
|
|
@@ -12,51 +12,36 @@ var JwtMsAuthGuard_1;
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.JwtMsAuthGuard = void 0;
|
|
14
14
|
const nestjs_auth_1 = require("@nathapp/nestjs-auth");
|
|
15
|
-
const nestjs_common_1 = require("@nathapp/nestjs-common");
|
|
16
15
|
const common_1 = require("@nestjs/common");
|
|
17
16
|
const core_1 = require("@nestjs/core");
|
|
18
|
-
const passport_1 = require("@nestjs/passport");
|
|
19
17
|
const decorator_1 = require("../decorator");
|
|
20
|
-
let JwtMsAuthGuard = JwtMsAuthGuard_1 = class JwtMsAuthGuard extends
|
|
21
|
-
constructor(
|
|
22
|
-
super();
|
|
23
|
-
this.
|
|
24
|
-
this.
|
|
18
|
+
let JwtMsAuthGuard = JwtMsAuthGuard_1 = class JwtMsAuthGuard extends nestjs_auth_1.JwtAuthGuard {
|
|
19
|
+
constructor(msReflector) {
|
|
20
|
+
super(msReflector);
|
|
21
|
+
this.msReflector = msReflector;
|
|
22
|
+
this.msLogger = new common_1.Logger(JwtMsAuthGuard_1.name);
|
|
25
23
|
}
|
|
26
24
|
canActivate(context) {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
handler,
|
|
31
|
-
clazz,
|
|
25
|
+
const msProtected = this.msReflector.getAllAndOverride(decorator_1.MICRO_SERVICES_KEY, [
|
|
26
|
+
context.getHandler(),
|
|
27
|
+
context.getClass(),
|
|
32
28
|
]);
|
|
33
|
-
|
|
34
|
-
handler,
|
|
35
|
-
clazz,
|
|
36
|
-
]);
|
|
37
|
-
if (isPublic) {
|
|
38
|
-
this.logger.verbose(`has isPublic decorator, class: ${clazz.name}, method: ${handler.name}`);
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
if (IsMicroServiceProtected) {
|
|
42
|
-
this.logger.verbose(`has MsProtected decorator, class: ${clazz.name}, method: ${handler.name}`);
|
|
29
|
+
if (msProtected) {
|
|
43
30
|
return true;
|
|
44
31
|
}
|
|
45
32
|
return super.canActivate(context);
|
|
46
33
|
}
|
|
47
34
|
handleRequest(err, user, info, context) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
if (user && user.sub === 'service' && user.iss) {
|
|
35
|
+
const authed = super.handleRequest(err, user, info);
|
|
36
|
+
if (context && authed && authed.sub === 'service' && authed.iss) {
|
|
52
37
|
const request = context.switchToHttp().getRequest();
|
|
53
38
|
request.serviceIdentity = {
|
|
54
|
-
serviceId:
|
|
55
|
-
audience:
|
|
39
|
+
serviceId: authed.iss,
|
|
40
|
+
audience: authed.aud,
|
|
56
41
|
};
|
|
57
|
-
this.
|
|
42
|
+
this.msLogger.verbose(`Service identity attached: ${authed.iss}`);
|
|
58
43
|
}
|
|
59
|
-
return
|
|
44
|
+
return authed;
|
|
60
45
|
}
|
|
61
46
|
};
|
|
62
47
|
exports.JwtMsAuthGuard = JwtMsAuthGuard;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt-ms-auth.guard.js","sourceRoot":"","sources":["../../lib/guard/jwt-ms-auth.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"jwt-ms-auth.guard.js","sourceRoot":"","sources":["../../lib/guard/jwt-ms-auth.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,sDAAoD;AACpD,2CAAsE;AACtE,uCAAyC;AACzC,4CAAkD;AAU3C,IAAM,cAAc,sBAApB,MAAM,cAAe,SAAQ,0BAAY;IAI9C,YAA6B,WAAsB;QACjD,KAAK,CAAC,WAAW,CAAC,CAAC;QADQ,gBAAW,GAAX,WAAW,CAAW;QAFlC,aAAQ,GAAG,IAAI,eAAM,CAAC,gBAAc,CAAC,IAAI,CAAC,CAAC;IAI5D,CAAC;IAGD,WAAW,CAAC,OAAyB;QACnC,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAU,8BAAkB,EAAE;YAClF,OAAO,CAAC,UAAU,EAAE;YACpB,OAAO,CAAC,QAAQ,EAAE;SACnB,CAAC,CAAC;QAEH,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,IAAI,CAAC;QACd,CAAC;QAID,OAAO,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAUD,aAAa,CAAC,GAAiB,EAAE,IAAS,EAAE,IAAS,EAAE,OAA0B;QAC/E,MAAM,MAAM,GAAG,KAAK,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAEpD,IAAI,OAAO,IAAI,MAAM,IAAI,MAAM,CAAC,GAAG,KAAK,SAAS,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC;YAChE,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;YACpD,OAAO,CAAC,eAAe,GAAG;gBACxB,SAAS,EAAE,MAAM,CAAC,GAAG;gBACrB,QAAQ,EAAE,MAAM,CAAC,GAAG;aACrB,CAAC;YACF,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,8BAA8B,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;QACpE,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAA;AA9CY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;qCAK+B,gBAAS;GAJxC,cAAc,CA8C1B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nathapp/nestjs-microservices",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.1",
|
|
4
4
|
"description": "nestjs-microservices",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rimraf dist/ .turbo/",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@nathapp/common": "^0.1.14",
|
|
46
|
-
"@nathapp/nestjs-auth": "^4.2.
|
|
47
|
-
"@nathapp/nestjs-common": "^4.2.
|
|
46
|
+
"@nathapp/nestjs-auth": "^4.2.1",
|
|
47
|
+
"@nathapp/nestjs-common": "^4.2.1",
|
|
48
48
|
"@nestjs/common": "^10.0.0 || ^11.0.0 || ^12.0.0",
|
|
49
49
|
"@nestjs/config": "^3.0.0 || ^4.0.0 || ^12.0.0",
|
|
50
50
|
"@nestjs/core": "^10.0.0 || ^11.0.0 || ^12.0.0",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"@grpc/grpc-js": "*",
|
|
60
60
|
"@nathapp/auth": "^1.0.2",
|
|
61
|
-
"@nathapp/nestjs-auth": "^4.
|
|
61
|
+
"@nathapp/nestjs-auth": "^4.2.0",
|
|
62
62
|
"@nathapp/nestjs-common": "^4.0.0-rc.0",
|
|
63
63
|
"@nestjs/microservices": "^10.0.0 || ^11.0.0 || ^12.0.0",
|
|
64
64
|
"@nestjs/passport": "^10.0.0 || ^11.0.0 || ^12.0.0",
|