@nathapp/nestjs-auth 3.2.2 → 4.0.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/AGENTS.md +61 -0
- package/CLAUDE.md +18 -0
- package/GEMINI.md +59 -0
- package/codex.md +59 -0
- package/dist/auth-provider.d.ts +1 -1
- package/dist/casl/casl-ability-factory.d.ts +1 -1
- package/dist/decorator/permission.decorator.d.ts +2 -2
- package/dist/permission/index.d.ts +2 -1
- package/dist/permission/index.js +2 -1
- package/dist/permission/index.js.map +1 -1
- package/dist/permission/permission.provider.d.ts +3 -26
- package/dist/permission/permission.provider.js +4 -32
- package/dist/permission/permission.provider.js.map +1 -1
- package/dist/permission/permission.types.d.ts +26 -0
- package/dist/permission/permission.types.js +12 -0
- package/dist/permission/permission.types.js.map +1 -0
- package/dist/strategy/base-jwt-strategy-provider.js +5 -2
- package/dist/strategy/base-jwt-strategy-provider.js.map +1 -1
- package/dist/utils/execution-context.utils.d.ts +3 -0
- package/dist/utils/execution-context.utils.js +17 -0
- package/dist/utils/execution-context.utils.js.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +3 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/utils.d.ts +1 -1
- package/dist/utils/utils.js +2 -2
- package/dist/utils/utils.js.map +1 -1
- package/package.json +10 -5
package/AGENTS.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Agent Instructions
|
|
2
|
+
|
|
3
|
+
This file is auto-generated from `.nax/context.md`.
|
|
4
|
+
DO NOT EDIT MANUALLY — run `nax generate` to regenerate.
|
|
5
|
+
|
|
6
|
+
These instructions apply to all AI coding agents in this project.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Project Metadata
|
|
11
|
+
|
|
12
|
+
> Auto-injected by `nax generate`
|
|
13
|
+
|
|
14
|
+
**Project:** `@nathapp/nestjs-auth`
|
|
15
|
+
|
|
16
|
+
**Language:** TypeScript
|
|
17
|
+
|
|
18
|
+
**Key dependencies:** @nathapp/typescript-config, typescript
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
# @nathapp/nestjs-auth
|
|
22
|
+
|
|
23
|
+
JWT authentication + CASL authorization library for NestJS.
|
|
24
|
+
|
|
25
|
+
## Commands
|
|
26
|
+
- Test: `npx jest --config test/jest-test.json --no-coverage`
|
|
27
|
+
- Build: `npx tsc`
|
|
28
|
+
|
|
29
|
+
## Module Structure
|
|
30
|
+
- `AuthModule` — combined AuthN+AuthZ (one-stop import for consumers)
|
|
31
|
+
- `AuthenticationModule` — AuthN only (JWT guards, strategies)
|
|
32
|
+
- `AuthorizationModule` — AuthZ only (CASL permissions)
|
|
33
|
+
- `AuthModule.forRoot()` splits options internally to `AuthenticationModule` + `AuthorizationModule`
|
|
34
|
+
|
|
35
|
+
## Key Files
|
|
36
|
+
- `lib/auth.module.ts` — combined module, complex async option splitting logic
|
|
37
|
+
- `lib/authentication/auth.module.ts` — AuthN module with strategy/guard providers
|
|
38
|
+
- `lib/authorization/authorization.module.ts` — AuthZ module with CASL wiring
|
|
39
|
+
- `lib/permission/permission.provider.ts` — `DefaultPermissionProvider` with `@Inject()` + `@Optional()`
|
|
40
|
+
|
|
41
|
+
## Gotchas
|
|
42
|
+
- `createPermissionProvider()` uses `useFactory` with explicit `inject: [CASL_ABILITY_FACTORY]` — NOT `useClass`. Required because `emitDecoratorMetadata` is unreliable across ts-jest configs.
|
|
43
|
+
- `AuthModule.forRootAsync` with `useClass`: instantiates factory directly (`new FactoryClass()`) to avoid cross-module DI resolution issues.
|
|
44
|
+
- `@RefreshToken()` does NOT bypass guards. Use `@Public()` + `@UseGuards(JwtRefreshGuard)` for refresh endpoints.
|
|
45
|
+
- Guards (`JwtAuthGuard`, `PermissionAuthGuard`) are registered by `nestjs-app`, not self-registered.
|
|
46
|
+
|
|
47
|
+
## JWKS Mode
|
|
48
|
+
|
|
49
|
+
- Enabled by setting `JwtNestJsOptions.jwks.jwksUri`.
|
|
50
|
+
- Uses `jwks-rsa` (optional peer dep — install separately).
|
|
51
|
+
- `BaseJwtStrategyProvider` emits `secretOrKeyProvider` instead of `secretOrKey` when `jwks` is set.
|
|
52
|
+
- `JwksJwtStrategyProvider` is the verify-only convenience class.
|
|
53
|
+
- Security invariants enforced at construction by `validateJwksOptions`:
|
|
54
|
+
- `issuer` is required (prevents accepting any token from any key the URI serves)
|
|
55
|
+
- `algorithms` defaults to `['RS256']`; HMAC and `none` are rejected (key-confusion attack)
|
|
56
|
+
- `jwksUri` must be https unless `jwks.allowInsecure=true`
|
|
57
|
+
- `sign()` and `verify()` throw in JWKS mode — strategies are verify-only.
|
|
58
|
+
|
|
59
|
+
## IMPORTANT
|
|
60
|
+
- Security-critical package — extra scrutiny on all changes.
|
|
61
|
+
- `BaseJwtStrategyProvider` is the extension point for custom JWT strategies.
|
package/CLAUDE.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
# Project Context
|
|
2
|
+
|
|
3
|
+
This file is auto-generated from `.nax/context.md`.
|
|
4
|
+
DO NOT EDIT MANUALLY — run `nax generate` to regenerate.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Project Metadata
|
|
9
|
+
|
|
10
|
+
> Auto-injected by `nax generate`
|
|
11
|
+
|
|
12
|
+
**Project:** `@nathapp/nestjs-auth`
|
|
13
|
+
|
|
14
|
+
**Language:** TypeScript
|
|
15
|
+
|
|
16
|
+
**Key dependencies:** @nathapp/typescript-config, typescript
|
|
17
|
+
|
|
18
|
+
---
|
|
1
19
|
# @nathapp/nestjs-auth
|
|
2
20
|
|
|
3
21
|
JWT authentication + CASL authorization library for NestJS.
|
package/GEMINI.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Gemini CLI Context
|
|
2
|
+
|
|
3
|
+
This file is auto-generated from `.nax/context.md`.
|
|
4
|
+
DO NOT EDIT MANUALLY — run `nax generate` to regenerate.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Project Metadata
|
|
9
|
+
|
|
10
|
+
> Auto-injected by `nax generate`
|
|
11
|
+
|
|
12
|
+
**Project:** `@nathapp/nestjs-auth`
|
|
13
|
+
|
|
14
|
+
**Language:** TypeScript
|
|
15
|
+
|
|
16
|
+
**Key dependencies:** @nathapp/typescript-config, typescript
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
# @nathapp/nestjs-auth
|
|
20
|
+
|
|
21
|
+
JWT authentication + CASL authorization library for NestJS.
|
|
22
|
+
|
|
23
|
+
## Commands
|
|
24
|
+
- Test: `npx jest --config test/jest-test.json --no-coverage`
|
|
25
|
+
- Build: `npx tsc`
|
|
26
|
+
|
|
27
|
+
## Module Structure
|
|
28
|
+
- `AuthModule` — combined AuthN+AuthZ (one-stop import for consumers)
|
|
29
|
+
- `AuthenticationModule` — AuthN only (JWT guards, strategies)
|
|
30
|
+
- `AuthorizationModule` — AuthZ only (CASL permissions)
|
|
31
|
+
- `AuthModule.forRoot()` splits options internally to `AuthenticationModule` + `AuthorizationModule`
|
|
32
|
+
|
|
33
|
+
## Key Files
|
|
34
|
+
- `lib/auth.module.ts` — combined module, complex async option splitting logic
|
|
35
|
+
- `lib/authentication/auth.module.ts` — AuthN module with strategy/guard providers
|
|
36
|
+
- `lib/authorization/authorization.module.ts` — AuthZ module with CASL wiring
|
|
37
|
+
- `lib/permission/permission.provider.ts` — `DefaultPermissionProvider` with `@Inject()` + `@Optional()`
|
|
38
|
+
|
|
39
|
+
## Gotchas
|
|
40
|
+
- `createPermissionProvider()` uses `useFactory` with explicit `inject: [CASL_ABILITY_FACTORY]` — NOT `useClass`. Required because `emitDecoratorMetadata` is unreliable across ts-jest configs.
|
|
41
|
+
- `AuthModule.forRootAsync` with `useClass`: instantiates factory directly (`new FactoryClass()`) to avoid cross-module DI resolution issues.
|
|
42
|
+
- `@RefreshToken()` does NOT bypass guards. Use `@Public()` + `@UseGuards(JwtRefreshGuard)` for refresh endpoints.
|
|
43
|
+
- Guards (`JwtAuthGuard`, `PermissionAuthGuard`) are registered by `nestjs-app`, not self-registered.
|
|
44
|
+
|
|
45
|
+
## JWKS Mode
|
|
46
|
+
|
|
47
|
+
- Enabled by setting `JwtNestJsOptions.jwks.jwksUri`.
|
|
48
|
+
- Uses `jwks-rsa` (optional peer dep — install separately).
|
|
49
|
+
- `BaseJwtStrategyProvider` emits `secretOrKeyProvider` instead of `secretOrKey` when `jwks` is set.
|
|
50
|
+
- `JwksJwtStrategyProvider` is the verify-only convenience class.
|
|
51
|
+
- Security invariants enforced at construction by `validateJwksOptions`:
|
|
52
|
+
- `issuer` is required (prevents accepting any token from any key the URI serves)
|
|
53
|
+
- `algorithms` defaults to `['RS256']`; HMAC and `none` are rejected (key-confusion attack)
|
|
54
|
+
- `jwksUri` must be https unless `jwks.allowInsecure=true`
|
|
55
|
+
- `sign()` and `verify()` throw in JWKS mode — strategies are verify-only.
|
|
56
|
+
|
|
57
|
+
## IMPORTANT
|
|
58
|
+
- Security-critical package — extra scrutiny on all changes.
|
|
59
|
+
- `BaseJwtStrategyProvider` is the extension point for custom JWT strategies.
|
package/codex.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Codex Instructions
|
|
2
|
+
|
|
3
|
+
This file is auto-generated from `.nax/context.md`.
|
|
4
|
+
DO NOT EDIT MANUALLY — run `nax generate` to regenerate.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Project Metadata
|
|
9
|
+
|
|
10
|
+
> Auto-injected by `nax generate`
|
|
11
|
+
|
|
12
|
+
**Project:** `@nathapp/nestjs-auth`
|
|
13
|
+
|
|
14
|
+
**Language:** TypeScript
|
|
15
|
+
|
|
16
|
+
**Key dependencies:** @nathapp/typescript-config, typescript
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
# @nathapp/nestjs-auth
|
|
20
|
+
|
|
21
|
+
JWT authentication + CASL authorization library for NestJS.
|
|
22
|
+
|
|
23
|
+
## Commands
|
|
24
|
+
- Test: `npx jest --config test/jest-test.json --no-coverage`
|
|
25
|
+
- Build: `npx tsc`
|
|
26
|
+
|
|
27
|
+
## Module Structure
|
|
28
|
+
- `AuthModule` — combined AuthN+AuthZ (one-stop import for consumers)
|
|
29
|
+
- `AuthenticationModule` — AuthN only (JWT guards, strategies)
|
|
30
|
+
- `AuthorizationModule` — AuthZ only (CASL permissions)
|
|
31
|
+
- `AuthModule.forRoot()` splits options internally to `AuthenticationModule` + `AuthorizationModule`
|
|
32
|
+
|
|
33
|
+
## Key Files
|
|
34
|
+
- `lib/auth.module.ts` — combined module, complex async option splitting logic
|
|
35
|
+
- `lib/authentication/auth.module.ts` — AuthN module with strategy/guard providers
|
|
36
|
+
- `lib/authorization/authorization.module.ts` — AuthZ module with CASL wiring
|
|
37
|
+
- `lib/permission/permission.provider.ts` — `DefaultPermissionProvider` with `@Inject()` + `@Optional()`
|
|
38
|
+
|
|
39
|
+
## Gotchas
|
|
40
|
+
- `createPermissionProvider()` uses `useFactory` with explicit `inject: [CASL_ABILITY_FACTORY]` — NOT `useClass`. Required because `emitDecoratorMetadata` is unreliable across ts-jest configs.
|
|
41
|
+
- `AuthModule.forRootAsync` with `useClass`: instantiates factory directly (`new FactoryClass()`) to avoid cross-module DI resolution issues.
|
|
42
|
+
- `@RefreshToken()` does NOT bypass guards. Use `@Public()` + `@UseGuards(JwtRefreshGuard)` for refresh endpoints.
|
|
43
|
+
- Guards (`JwtAuthGuard`, `PermissionAuthGuard`) are registered by `nestjs-app`, not self-registered.
|
|
44
|
+
|
|
45
|
+
## JWKS Mode
|
|
46
|
+
|
|
47
|
+
- Enabled by setting `JwtNestJsOptions.jwks.jwksUri`.
|
|
48
|
+
- Uses `jwks-rsa` (optional peer dep — install separately).
|
|
49
|
+
- `BaseJwtStrategyProvider` emits `secretOrKeyProvider` instead of `secretOrKey` when `jwks` is set.
|
|
50
|
+
- `JwksJwtStrategyProvider` is the verify-only convenience class.
|
|
51
|
+
- Security invariants enforced at construction by `validateJwksOptions`:
|
|
52
|
+
- `issuer` is required (prevents accepting any token from any key the URI serves)
|
|
53
|
+
- `algorithms` defaults to `['RS256']`; HMAC and `none` are rejected (key-confusion attack)
|
|
54
|
+
- `jwksUri` must be https unless `jwks.allowInsecure=true`
|
|
55
|
+
- `sign()` and `verify()` throw in JWKS mode — strategies are verify-only.
|
|
56
|
+
|
|
57
|
+
## IMPORTANT
|
|
58
|
+
- Security-critical package — extra scrutiny on all changes.
|
|
59
|
+
- `BaseJwtStrategyProvider` is the extension point for custom JWT strategies.
|
package/dist/auth-provider.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IPrincipal } from '../auth-provider';
|
|
2
|
-
import { AppAbility, CaslPermission } from '../permission';
|
|
2
|
+
import { AppAbility, CaslPermission } from '../permission/permission.types';
|
|
3
3
|
export declare abstract class CaslAbilityFactory {
|
|
4
4
|
abstract createForUser(user: IPrincipal): Promise<AppAbility>;
|
|
5
5
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CustomDecorator } from "@nestjs/common";
|
|
2
|
-
import {
|
|
3
|
-
export type RequiredCaslPermission
|
|
2
|
+
import { PermissionType } from "../permission/permission.types";
|
|
3
|
+
export type { RequiredCaslPermission } from "../permission/permission.types";
|
|
4
4
|
export declare const PERMISSION_KEY = "PERMISSION";
|
|
5
5
|
export declare const RequiredPermission: (...permissions: PermissionType[]) => CustomDecorator<string>;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DefaultPermissionProvider, IPermissionProvider, PermissionProvider, SimplePermissionProvider } from "./permission.provider";
|
|
2
|
+
import { AppAbility, Authority, CaslPermission, CaslPermissionAction, CaslPermissionCondition, CaslPermissionSubject, Permissionable, PermissionType } from "./permission.types";
|
|
2
3
|
export { Authority, Permissionable, IPermissionProvider, PermissionProvider, SimplePermissionProvider, DefaultPermissionProvider, CaslPermission, CaslPermissionAction, CaslPermissionSubject, AppAbility, CaslPermissionCondition, PermissionType, };
|
package/dist/permission/index.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CaslPermissionAction = exports.DefaultPermissionProvider = exports.SimplePermissionProvider = exports.PermissionProvider = void 0;
|
|
4
4
|
const permission_provider_1 = require("./permission.provider");
|
|
5
|
-
Object.defineProperty(exports, "CaslPermissionAction", { enumerable: true, get: function () { return permission_provider_1.CaslPermissionAction; } });
|
|
6
5
|
Object.defineProperty(exports, "DefaultPermissionProvider", { enumerable: true, get: function () { return permission_provider_1.DefaultPermissionProvider; } });
|
|
7
6
|
Object.defineProperty(exports, "PermissionProvider", { enumerable: true, get: function () { return permission_provider_1.PermissionProvider; } });
|
|
8
7
|
Object.defineProperty(exports, "SimplePermissionProvider", { enumerable: true, get: function () { return permission_provider_1.SimplePermissionProvider; } });
|
|
8
|
+
const permission_types_1 = require("./permission.types");
|
|
9
|
+
Object.defineProperty(exports, "CaslPermissionAction", { enumerable: true, get: function () { return permission_types_1.CaslPermissionAction; } });
|
|
9
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/permission/index.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/permission/index.ts"],"names":[],"mappings":";;;AAAA,+DAAqI;AAKrF,0GALvC,+CAAyB,OAKuC;AAAvE,mGALuD,wCAAkB,OAKvD;AAAE,yGALuD,8CAAwB,OAKvD;AAJ9C,yDAAiL;AAK/J,qGAL8B,uCAAoB,OAK9B"}
|
|
@@ -1,32 +1,9 @@
|
|
|
1
1
|
import { ExecutionContext } from "@nestjs/common";
|
|
2
2
|
import { Observable } from "rxjs";
|
|
3
|
-
import { MongoAbility } from '@casl/ability';
|
|
4
3
|
import { CaslAbilityFactory } from "../casl";
|
|
5
|
-
import {
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
READ = "read",
|
|
9
|
-
UPDATE = "update",
|
|
10
|
-
DELETE = "delete",
|
|
11
|
-
MANAGE = "manage"
|
|
12
|
-
}
|
|
13
|
-
export type CaslPermissionSubject = any;
|
|
14
|
-
export type AppAbility = MongoAbility<[CaslPermissionAction, CaslPermissionSubject]>;
|
|
15
|
-
export interface CaslPermission {
|
|
16
|
-
action: CaslPermissionAction;
|
|
17
|
-
subject: string;
|
|
18
|
-
conditions?: CaslPermissionCondition;
|
|
19
|
-
}
|
|
20
|
-
export interface CaslPermissionCondition {
|
|
21
|
-
}
|
|
22
|
-
export interface Authority {
|
|
23
|
-
id: string | number;
|
|
24
|
-
name: string;
|
|
25
|
-
}
|
|
26
|
-
export interface Permissionable {
|
|
27
|
-
authorities: string[] | Authority[] | CaslPermission[];
|
|
28
|
-
}
|
|
29
|
-
export type PermissionType = string | RequiredCaslPermission | RequiredCaslPermission[];
|
|
4
|
+
import { Permissionable, PermissionType } from "./permission.types";
|
|
5
|
+
export { CaslPermissionAction } from "./permission.types";
|
|
6
|
+
export type { AppAbility, Authority, CaslPermission, CaslPermissionCondition, CaslPermissionSubject, Permissionable, PermissionType, } from "./permission.types";
|
|
30
7
|
export interface IPermissionProvider {
|
|
31
8
|
checkPermission(context: ExecutionContext, permission: PermissionType): boolean | Promise<boolean> | Observable<boolean>;
|
|
32
9
|
}
|
|
@@ -17,14 +17,8 @@ exports.SimplePermissionProvider = exports.DefaultPermissionProvider = exports.P
|
|
|
17
17
|
const common_1 = require("@nestjs/common");
|
|
18
18
|
const utils_1 = require("../utils");
|
|
19
19
|
const casl_1 = require("../casl");
|
|
20
|
-
var
|
|
21
|
-
(function (
|
|
22
|
-
CaslPermissionAction["CREATE"] = "create";
|
|
23
|
-
CaslPermissionAction["READ"] = "read";
|
|
24
|
-
CaslPermissionAction["UPDATE"] = "update";
|
|
25
|
-
CaslPermissionAction["DELETE"] = "delete";
|
|
26
|
-
CaslPermissionAction["MANAGE"] = "manage";
|
|
27
|
-
})(CaslPermissionAction || (exports.CaslPermissionAction = CaslPermissionAction = {}));
|
|
20
|
+
var permission_types_1 = require("./permission.types");
|
|
21
|
+
Object.defineProperty(exports, "CaslPermissionAction", { enumerable: true, get: function () { return permission_types_1.CaslPermissionAction; } });
|
|
28
22
|
class PermissionProvider {
|
|
29
23
|
}
|
|
30
24
|
exports.PermissionProvider = PermissionProvider;
|
|
@@ -35,18 +29,7 @@ let DefaultPermissionProvider = DefaultPermissionProvider_1 = class DefaultPermi
|
|
|
35
29
|
this.caslAbilityFactory = caslAbilityFactory || new casl_1.JwtCaslAbilityFactory();
|
|
36
30
|
}
|
|
37
31
|
checkPermission(context, permission) {
|
|
38
|
-
|
|
39
|
-
const hostType = context.getType();
|
|
40
|
-
let user = undefined;
|
|
41
|
-
if (hostType === "http") {
|
|
42
|
-
user = (_a = context.switchToHttp().getRequest()) === null || _a === void 0 ? void 0 : _a.user;
|
|
43
|
-
}
|
|
44
|
-
else if (hostType === "rpc") {
|
|
45
|
-
user = (_b = context.switchToRpc().getData()) === null || _b === void 0 ? void 0 : _b.user;
|
|
46
|
-
}
|
|
47
|
-
else if (hostType === "ws") {
|
|
48
|
-
user = (_c = context.switchToWs().getData()) === null || _c === void 0 ? void 0 : _c.user;
|
|
49
|
-
}
|
|
32
|
+
const user = (0, utils_1.getPrincipalFromContext)(context);
|
|
50
33
|
if (!user || !this.isPermissionable(user)) {
|
|
51
34
|
this.logger.debug("user not found or user has empty permission");
|
|
52
35
|
this.logger.debug(`user: ${JSON.stringify(user)}`);
|
|
@@ -104,18 +87,7 @@ exports.DefaultPermissionProvider = DefaultPermissionProvider = DefaultPermissio
|
|
|
104
87
|
], DefaultPermissionProvider);
|
|
105
88
|
class SimplePermissionProvider {
|
|
106
89
|
checkPermission(context, permission) {
|
|
107
|
-
|
|
108
|
-
const hostType = context.getType();
|
|
109
|
-
let user = undefined;
|
|
110
|
-
if (hostType === "http") {
|
|
111
|
-
user = (_a = context.switchToHttp().getRequest()) === null || _a === void 0 ? void 0 : _a.user;
|
|
112
|
-
}
|
|
113
|
-
else if (hostType === "rpc") {
|
|
114
|
-
user = (_b = context.switchToRpc().getData()) === null || _b === void 0 ? void 0 : _b.user;
|
|
115
|
-
}
|
|
116
|
-
else if (hostType === "ws") {
|
|
117
|
-
user = (_c = context.switchToWs().getData()) === null || _c === void 0 ? void 0 : _c.user;
|
|
118
|
-
}
|
|
90
|
+
const user = (0, utils_1.getPrincipalFromContext)(context);
|
|
119
91
|
return user ? true : false;
|
|
120
92
|
}
|
|
121
93
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission.provider.js","sourceRoot":"","sources":["../../lib/permission/permission.provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA4E;
|
|
1
|
+
{"version":3,"file":"permission.provider.js","sourceRoot":"","sources":["../../lib/permission/permission.provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA4E;AAG5E,oCAAkF;AAClF,kCAAoE;AAMpE,uDAA0D;AAAjD,wHAAA,oBAAoB,OAAA;AA4B7B,MAAsB,kBAAkB;CAIvC;AAJD,gDAIC;AAOD,IAAa,yBAAyB,iCAAtC,MAAa,yBAA0B,SAAQ,kBAAkB;IAK/D,YAAoD,kBAAuC;QACzF,KAAK,EAAE,CAAC;QAJO,WAAM,GAAG,IAAI,eAAM,CAAC,2BAAyB,CAAC,IAAI,CAAC,CAAC;QAKnE,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,IAAI,IAAI,4BAAqB,EAAE,CAAC;IAC9E,CAAC;IASD,eAAe,CAAC,OAAyB,EAAE,UAA0B;QAInE,MAAM,IAAI,GAAG,IAAA,+BAAuB,EAAC,OAAO,CAAC,CAAC;QAC9C,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1C,IAAI,CAAC,MAAM,CAAC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I,GAAG,IAAA,+BAAuB,EAAC,OAAO,CAAC,CAAC;QAE9C,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IAC7B,CAAC;CAEF;AAhBD,4DAgBC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { MongoAbility } from '@casl/ability';
|
|
2
|
+
export declare enum CaslPermissionAction {
|
|
3
|
+
CREATE = "create",
|
|
4
|
+
READ = "read",
|
|
5
|
+
UPDATE = "update",
|
|
6
|
+
DELETE = "delete",
|
|
7
|
+
MANAGE = "manage"
|
|
8
|
+
}
|
|
9
|
+
export type CaslPermissionSubject = any;
|
|
10
|
+
export type AppAbility = MongoAbility<[CaslPermissionAction, CaslPermissionSubject]>;
|
|
11
|
+
export interface CaslPermission {
|
|
12
|
+
action: CaslPermissionAction;
|
|
13
|
+
subject: string;
|
|
14
|
+
conditions?: CaslPermissionCondition;
|
|
15
|
+
}
|
|
16
|
+
export interface CaslPermissionCondition {
|
|
17
|
+
}
|
|
18
|
+
export interface Authority {
|
|
19
|
+
id: string | number;
|
|
20
|
+
name: string;
|
|
21
|
+
}
|
|
22
|
+
export interface Permissionable {
|
|
23
|
+
authorities: string[] | Authority[] | CaslPermission[];
|
|
24
|
+
}
|
|
25
|
+
export type RequiredCaslPermission = [CaslPermissionAction, CaslPermissionSubject];
|
|
26
|
+
export type PermissionType = string | RequiredCaslPermission | RequiredCaslPermission[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CaslPermissionAction = void 0;
|
|
4
|
+
var CaslPermissionAction;
|
|
5
|
+
(function (CaslPermissionAction) {
|
|
6
|
+
CaslPermissionAction["CREATE"] = "create";
|
|
7
|
+
CaslPermissionAction["READ"] = "read";
|
|
8
|
+
CaslPermissionAction["UPDATE"] = "update";
|
|
9
|
+
CaslPermissionAction["DELETE"] = "delete";
|
|
10
|
+
CaslPermissionAction["MANAGE"] = "manage";
|
|
11
|
+
})(CaslPermissionAction || (exports.CaslPermissionAction = CaslPermissionAction = {}));
|
|
12
|
+
//# sourceMappingURL=permission.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission.types.js","sourceRoot":"","sources":["../../lib/permission/permission.types.ts"],"names":[],"mappings":";;;AAKA,IAAY,oBAMX;AAND,WAAY,oBAAoB;IAC9B,yCAAiB,CAAA;IACjB,qCAAa,CAAA;IACb,yCAAiB,CAAA;IACjB,yCAAiB,CAAA;IACjB,yCAAiB,CAAA;AACnB,CAAC,EANW,oBAAoB,oCAApB,oBAAoB,QAM/B"}
|
|
@@ -29,12 +29,15 @@ class BaseJwtStrategyProvider {
|
|
|
29
29
|
this.passReqToCallback = this.jwtOptions.passReqToCallback;
|
|
30
30
|
}
|
|
31
31
|
getStrategyOptions() {
|
|
32
|
-
var _a;
|
|
32
|
+
var _a, _b, _c;
|
|
33
|
+
const algorithms = this.jwtOptions.jwks
|
|
34
|
+
? (_a = this.jwtOptions.jwks.algorithms) !== null && _a !== void 0 ? _a : ['RS256']
|
|
35
|
+
: [(_c = (_b = this.jwtOptions.signOption) === null || _b === void 0 ? void 0 : _b.algorithm) !== null && _c !== void 0 ? _c : 'HS512'];
|
|
33
36
|
const partialOptions = {
|
|
34
37
|
ignoreExpiration: this.ignoreExpiration,
|
|
38
|
+
algorithms,
|
|
35
39
|
...(this.jwtOptions.issuer && { issuer: this.jwtOptions.issuer }),
|
|
36
40
|
...(this.jwtOptions.audience && { audience: this.jwtOptions.audience }),
|
|
37
|
-
...(this.jwtOptions.jwks && { algorithms: (_a = this.jwtOptions.jwks.algorithms) !== null && _a !== void 0 ? _a : ['RS256'] }),
|
|
38
41
|
};
|
|
39
42
|
const keyConfig = this.secretOrKeyProviderFn
|
|
40
43
|
? { secretOrKeyProvider: this.secretOrKeyProviderFn }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-jwt-strategy-provider.js","sourceRoot":"","sources":["../../lib/strategy/base-jwt-strategy-provider.ts"],"names":[],"mappings":";;;AACA,+CAA8I;
|
|
1
|
+
{"version":3,"file":"base-jwt-strategy-provider.js","sourceRoot":"","sources":["../../lib/strategy/base-jwt-strategy-provider.ts"],"names":[],"mappings":";;;AACA,+CAA8I;AAI9I,0CAAmG;AAcnG,MAAsB,uBAAuB;IAW3C,YAAY,UAAsB,EAAE,cAAoC;QACtE,MAAM,YAAY,GAAwB;YACxC,MAAM,EAAE,KAAK;YACb,mBAAmB,EAAE,IAAI;YACzB,gBAAgB,EAAE,IAAI;YACtB,gBAAgB,EAAE,KAAK;YACvB,iBAAiB,EAAE,IAAI;YACvB,qBAAqB,EAAE,KAAK;SAC7B,CAAC;QAEF,MAAM,cAAc,GAAG,EAAE,GAAG,YAAY,EAAE,GAAG,cAAc,EAAE,CAAC;QAC9D,IAAI,CAAC,UAAU,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,UAAU,EAAE,CAAC;QAEvD,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;YACzB,IAAA,2BAAmB,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACrC,IAAI,CAAC,qBAAqB,GAAG,IAAA,iCAAyB,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC1E,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,WAAW,GAAG,IAAA,yBAAiB,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACtD,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC;YAC9D,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC;QAC9D,CAAC;QAED,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC,UAAU,CAAC,sBAAsB,IAAI,yBAAU,CAAC,2BAA2B,EAAE,CAAC;QACjH,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC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,EAAE,OAAyB;QAC/D,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;QACzF,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;IAMD,MAAM,CAAC,KAAa,EAAE,YAAgC;QACpD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,sFAAsF,CAAC,CAAC;QAC1G,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IACtD,CAAC;CAMF;AA5GD,0DA4GC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPrincipalFromContext = getPrincipalFromContext;
|
|
4
|
+
function getPrincipalFromContext(context) {
|
|
5
|
+
var _a, _b, _c;
|
|
6
|
+
switch (context.getType()) {
|
|
7
|
+
case "http":
|
|
8
|
+
return (_a = context.switchToHttp().getRequest()) === null || _a === void 0 ? void 0 : _a.user;
|
|
9
|
+
case "rpc":
|
|
10
|
+
return (_b = context.switchToRpc().getContext()) === null || _b === void 0 ? void 0 : _b.user;
|
|
11
|
+
case "ws":
|
|
12
|
+
return (_c = context.switchToWs().getClient()) === null || _c === void 0 ? void 0 : _c.user;
|
|
13
|
+
default:
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=execution-context.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-context.utils.js","sourceRoot":"","sources":["../../lib/utils/execution-context.utils.ts"],"names":[],"mappings":";;AAcA,0DAWC;AAXD,SAAgB,uBAAuB,CAAC,OAAyB;;IAC/D,QAAQ,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QAC1B,KAAK,MAAM;YACT,OAAO,MAAA,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,0CAAE,IAAI,CAAC;QACnD,KAAK,KAAK;YACR,OAAO,MAAA,OAAO,CAAC,WAAW,EAAE,CAAC,UAAU,EAAE,0CAAE,IAAI,CAAC;QAClD,KAAK,IAAI;YACP,OAAO,MAAA,OAAO,CAAC,UAAU,EAAE,CAAC,SAAS,EAAE,0CAAE,IAAI,CAAC;QAChD;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC"}
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isRequiredCaslPermission = exports.isCaslPermissionAction = exports.isAuthority = exports.isCaslPermission = void 0;
|
|
3
|
+
exports.getPrincipalFromContext = exports.isRequiredCaslPermission = exports.isCaslPermissionAction = exports.isAuthority = exports.isCaslPermission = void 0;
|
|
4
4
|
const utils_1 = require("./utils");
|
|
5
5
|
Object.defineProperty(exports, "isAuthority", { enumerable: true, get: function () { return utils_1.isAuthority; } });
|
|
6
6
|
Object.defineProperty(exports, "isCaslPermission", { enumerable: true, get: function () { return utils_1.isCaslPermission; } });
|
|
7
7
|
Object.defineProperty(exports, "isCaslPermissionAction", { enumerable: true, get: function () { return utils_1.isCaslPermissionAction; } });
|
|
8
8
|
Object.defineProperty(exports, "isRequiredCaslPermission", { enumerable: true, get: function () { return utils_1.isRequiredCaslPermission; } });
|
|
9
|
+
var execution_context_utils_1 = require("./execution-context.utils");
|
|
10
|
+
Object.defineProperty(exports, "getPrincipalFromContext", { enumerable: true, get: function () { return execution_context_utils_1.getPrincipalFromContext; } });
|
|
9
11
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/utils/index.ts"],"names":[],"mappings":";;;AAAA,mCAA0G;AAIxG,4FAJO,mBAAW,OAIP;AADX,iGAHoB,wBAAgB,OAGpB;AAEhB,uGALsC,8BAAsB,OAKtC;AACtB,yGAN8D,gCAAwB,OAM9D"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/utils/index.ts"],"names":[],"mappings":";;;AAAA,mCAA0G;AAIxG,4FAJO,mBAAW,OAIP;AADX,iGAHoB,wBAAgB,OAGpB;AAEhB,uGALsC,8BAAsB,OAKtC;AACtB,yGAN8D,gCAAwB,OAM9D;AAG1B,qEAAoE;AAA3D,kIAAA,uBAAuB,OAAA"}
|
package/dist/utils/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JwtProvider } from "@nathapp/auth";
|
|
2
|
-
import { Authority, CaslPermission, PermissionType } from "../permission";
|
|
2
|
+
import { Authority, CaslPermission, PermissionType } from "../permission/permission.types";
|
|
3
3
|
import { JwtOptions } from "../strategy";
|
|
4
4
|
import { Algorithm } from "jsonwebtoken";
|
|
5
5
|
export declare const isCaslPermission: (val: any) => val is CaslPermission;
|
package/dist/utils/utils.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validateJwksOptions = exports.createSecretOrKeyProvider = exports.isAsymmetricAlgo = exports.createJwtProvider = exports.isRequiredCaslPermission = exports.isCaslPermissionAction = exports.isAuthority = exports.isCaslPermission = void 0;
|
|
4
4
|
const auth_1 = require("@nathapp/auth");
|
|
5
|
-
const
|
|
5
|
+
const permission_types_1 = require("../permission/permission.types");
|
|
6
6
|
const isCaslPermission = (val) => {
|
|
7
7
|
return val != null && typeof val === 'object' && 'subject' in val && 'action' in val;
|
|
8
8
|
};
|
|
@@ -12,7 +12,7 @@ const isAuthority = (val) => {
|
|
|
12
12
|
};
|
|
13
13
|
exports.isAuthority = isAuthority;
|
|
14
14
|
const isCaslPermissionAction = (val) => {
|
|
15
|
-
const actions = Object.values(
|
|
15
|
+
const actions = Object.values(permission_types_1.CaslPermissionAction);
|
|
16
16
|
return actions.includes(val);
|
|
17
17
|
};
|
|
18
18
|
exports.isCaslPermissionAction = isCaslPermissionAction;
|
package/dist/utils/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../lib/utils/utils.ts"],"names":[],"mappings":";;;AAAA,wCAA4C;AAC5C,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../lib/utils/utils.ts"],"names":[],"mappings":";;;AAAA,wCAA4C;AAC5C,qEAAiH;AAO1G,MAAO,gBAAgB,GAAG,CAAC,GAAQ,EAAyB,EAAE;IACnE,OAAO,GAAG,IAAI,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,SAAS,IAAI,GAAG,IAAI,QAAQ,IAAI,GAAG,CAAC;AACvF,CAAC,CAAA;AAFa,QAAA,gBAAgB,oBAE7B;AAKM,MAAM,WAAW,GAAG,CAAC,GAAQ,EAAoB,EAAE;IACxD,OAAO,GAAG,IAAI,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,IAAI,IAAI,GAAG,IAAI,CAAC,OAAO,GAAG,CAAC,EAAE,KAAK,QAAQ,IAAI,OAAO,GAAG,CAAC,EAAE,KAAK,QAAQ,CAAC,IAAI,MAAM,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC9K,CAAC,CAAA;AAFY,QAAA,WAAW,eAEvB;AAKM,MAAM,sBAAsB,GAAG,CAAC,GAAQ,EAAW,EAAE;IAC1D,MAAM,OAAO,GAAa,MAAM,CAAC,MAAM,CAAC,uCAAoB,CAAC,CAAC;IAChE,OAAO,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC,CAAA;AAHY,QAAA,sB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AI,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAC7D,CAAC;QACD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACtD,MAAM,IAAI,KAAK,CACb,0DAA0D,IAAI,KAAK;gBACnE,uEAAuE,CACxE,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAnCW,QAAA,mBAAmB,uBAmC9B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nathapp/nestjs-auth",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "nestjs-auth",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rimraf dist/ .turbo/",
|
|
@@ -9,10 +9,15 @@
|
|
|
9
9
|
"test": "jest --config ./test/jest-test.json",
|
|
10
10
|
"test:cov": "jest --config ./test/jest-test.json --coverage",
|
|
11
11
|
"test:watch": "jest --config ./test/jest-test.json --watch",
|
|
12
|
-
"lint": "eslint -c .eslintrc.js"
|
|
12
|
+
"lint": "eslint -c .eslintrc.js",
|
|
13
|
+
"type-check": "tsc --noEmit -p tsconfig.json",
|
|
14
|
+
"lint:fix": "eslint -c .eslintrc.js --fix"
|
|
13
15
|
},
|
|
14
16
|
"author": "",
|
|
15
17
|
"license": "ISC",
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
20
|
+
},
|
|
16
21
|
"devDependencies": {
|
|
17
22
|
"@nathapp/eslint-config": "1.0.1",
|
|
18
23
|
"@nathapp/typescript-config": "1.0.1",
|
|
@@ -27,14 +32,14 @@
|
|
|
27
32
|
"lib": "lib"
|
|
28
33
|
},
|
|
29
34
|
"dependencies": {
|
|
30
|
-
"@nathapp/nestjs-common": "^
|
|
35
|
+
"@nathapp/nestjs-common": "^4.0.0",
|
|
31
36
|
"passport-jwt": "^4.0.1"
|
|
32
37
|
},
|
|
33
38
|
"peerDependencies": {
|
|
34
39
|
"@casl/ability": "^6.7.1",
|
|
35
40
|
"@nathapp/auth": "^1.0.2",
|
|
36
|
-
"@nathapp/nestjs-common": "^
|
|
37
|
-
"@nestjs/passport": "^
|
|
41
|
+
"@nathapp/nestjs-common": "^4.0.0-rc.0",
|
|
42
|
+
"@nestjs/passport": "^10.0.0 || ^11.0.0 || ^12.0.0",
|
|
38
43
|
"jwks-rsa": "^3.2.0"
|
|
39
44
|
},
|
|
40
45
|
"peerDependenciesMeta": {
|