@appxdigital/appx-core 0.1.121-beta.15 → 0.1.121-beta.16
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/CHANGELOG.md
CHANGED
|
@@ -51,6 +51,7 @@ A scalar field is included unless it is: the primary key (`@id`), a server-manag
|
|
|
51
51
|
- `app.module.ts` uses `coreEnvFilePath()` for `envFilePath`.
|
|
52
52
|
- Generated `package.json` adds `helmet`; the `start` script sets `NODE_ENV=development`.
|
|
53
53
|
- `AuthController.getAllSessions` / `closeSpecificSession` use `@UseGuards(AuthenticatedGuard)`.
|
|
54
|
+
- `app.module.ts` imports `AuthModule.forRoot()` (not the bare `AuthModule`) — see the migration note below.
|
|
54
55
|
|
|
55
56
|
### Migration
|
|
56
57
|
|
|
@@ -132,6 +133,17 @@ async update(@Param('id') id: string, @Body() data: Update<Model>Dto) { return s
|
|
|
132
133
|
>
|
|
133
134
|
> **For AI agents:** this is a behaviour restriction on a production app. Before deploying, tell the developer that (a) any create that sets a foreign key to a model without a `connect` rule now fails — and the app won't boot until those rules exist, and (b) any `create` condition that referenced a relation no longer enforces it there and must be re-expressed as a `connect` rule. Do not proceed silently. The boot-time error message names exactly what to add. See [`docs/permissions.md`](../docs/permissions.md#the-connect-action--authorizes-every-relationship-a-create-establishes).
|
|
134
135
|
|
|
136
|
+
**6. Auth module — `AuthModule` → `AuthModule.forRoot()` (`src/app.module.ts`).**
|
|
137
|
+
The bare `AuthModule` no longer registers anything; wire it as `AuthModule.forRoot()`
|
|
138
|
+
(all providers + the built-in `/auth` controller). This exists so the controller
|
|
139
|
+
can be conditionally omitted: to override the auth endpoints (e.g. widen
|
|
140
|
+
registration to accept `name`), import `AuthModule.forRoot({ controller: false })`
|
|
141
|
+
and register your own controller that `extends AuthController` at the same `/auth`
|
|
142
|
+
prefix. The auth building blocks (`AuthController`, `AuthService`, `RegisterDto`,
|
|
143
|
+
`UserDto`, the Passport strategies, guards) are now exported from the package root
|
|
144
|
+
— stop importing them from `@appxdigital/appx-core/dist/...`. Full guide:
|
|
145
|
+
[`docs/authentication.md`](../docs/authentication.md).
|
|
146
|
+
|
|
135
147
|
**5. Create-permission enforcement (behaviour change — review before upgrading).**
|
|
136
148
|
- Ensure every model/role that legitimately creates records has an explicit `create` permission (or `'ALL'`). Without one, create now returns `403` (previously unchecked). Internal framework flows (registration, sessions, tokens) are unaffected.
|
|
137
149
|
- If you supplied arbitrary values for a field a `create` condition constrains (e.g. an owner id), those requests now return `403` unless the value matches — use `setUserIdField` to have the framework set it.
|
package/PRERELEASES.md
CHANGED
|
@@ -31,6 +31,20 @@ Prereleases are excluded from normal semver range resolution, so a project on
|
|
|
31
31
|
|
|
32
32
|
---
|
|
33
33
|
|
|
34
|
+
## [0.1.121-beta.16] — unreleased
|
|
35
|
+
|
|
36
|
+
**Fix — `AuthModule.forRoot({ controller: false })` now actually omits the
|
|
37
|
+
controller.** In beta.15 the controller was also declared on the static `@Module()`,
|
|
38
|
+
and NestJS *extends* (does not replace) that metadata with `forRoot()`'s — so
|
|
39
|
+
`AuthController` stayed registered and overriding `/auth/register` produced a
|
|
40
|
+
duplicate route (the base `RegisterDto` won → extra fields like `name` were
|
|
41
|
+
rejected). All wiring now lives in `forRoot()`.
|
|
42
|
+
|
|
43
|
+
- **Migration:** import **`AuthModule.forRoot()`**, not the bare `AuthModule` (which
|
|
44
|
+
now registers nothing). The scaffold is updated. `forRoot({ controller: false })`
|
|
45
|
+
omits the built-in controller so your own can take over `/auth`. Regression
|
|
46
|
+
test added (`test/unit/auth-module.spec.ts`).
|
|
47
|
+
|
|
34
48
|
## [0.1.121-beta.15] — unreleased
|
|
35
49
|
|
|
36
50
|
**Library / docs. Additive — no behaviour change.** Auth is now extensible from
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { DynamicModule } from '@nestjs/common';
|
|
2
2
|
export declare class AuthModule {
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* Wires the auth module. **Always use `AuthModule.forRoot()`** — importing the
|
|
5
|
+
* bare `AuthModule` registers nothing (all wiring is here so the controller
|
|
6
|
+
* can be conditionally omitted).
|
|
7
|
+
*
|
|
8
|
+
* `AuthModule.forRoot()` registers the built-in `AuthController` (default).
|
|
9
|
+
* `AuthModule.forRoot({ controller: false })` registers every auth provider
|
|
10
|
+
* globally (AuthService, Jwt, Passport, strategies, guards) but NOT the
|
|
11
|
+
* controller — so you can register your OWN controller (e.g. one that
|
|
12
|
+
* `extends AuthController`) at the same `/auth` prefix with no duplicate
|
|
13
|
+
* route. See docs/authentication.md.
|
|
9
14
|
*/
|
|
10
15
|
static forRoot(options?: {
|
|
11
16
|
controller?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.module.d.ts","sourceRoot":"","sources":["../../../src/modules/auth/auth.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAiB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.module.d.ts","sourceRoot":"","sources":["../../../src/modules/auth/auth.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAiB,MAAM,gBAAgB,CAAC;AAkC7D,qBAEa,UAAU;IACnB;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAC,GAAG,aAAa;CAUlE"}
|
|
@@ -21,8 +21,10 @@ const jwt_auth_guard_1 = require("./jwt-auth.guard");
|
|
|
21
21
|
const authenticated_guard_1 = require("./authenticated.guard");
|
|
22
22
|
const jwt_strategy_1 = require("./jwt.strategy");
|
|
23
23
|
const refresh_token_strategy_1 = require("./refresh-token.strategy");
|
|
24
|
-
//
|
|
25
|
-
//
|
|
24
|
+
// All wiring lives in forRoot() so the controller can be conditionally omitted.
|
|
25
|
+
// The @Module() decorator is intentionally empty: NestJS *extends* (concatenates)
|
|
26
|
+
// the decorator's metadata onto a DynamicModule, so a controller declared there
|
|
27
|
+
// could never be removed by forRoot({ controller: false }).
|
|
26
28
|
const authImports = [
|
|
27
29
|
config_1.ConfigModule,
|
|
28
30
|
user_module_1.UserModule,
|
|
@@ -40,11 +42,16 @@ const authProviders = [auth_service_1.AuthService, local_strategy_1.LocalStrateg
|
|
|
40
42
|
const authExports = [auth_service_1.AuthService, jwt_auth_guard_1.JwtAuthGuard, authenticated_guard_1.AuthenticatedGuard, jwt_1.JwtModule];
|
|
41
43
|
let AuthModule = exports.AuthModule = AuthModule_1 = class AuthModule {
|
|
42
44
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
45
|
+
* Wires the auth module. **Always use `AuthModule.forRoot()`** — importing the
|
|
46
|
+
* bare `AuthModule` registers nothing (all wiring is here so the controller
|
|
47
|
+
* can be conditionally omitted).
|
|
48
|
+
*
|
|
49
|
+
* `AuthModule.forRoot()` registers the built-in `AuthController` (default).
|
|
50
|
+
* `AuthModule.forRoot({ controller: false })` registers every auth provider
|
|
51
|
+
* globally (AuthService, Jwt, Passport, strategies, guards) but NOT the
|
|
52
|
+
* controller — so you can register your OWN controller (e.g. one that
|
|
53
|
+
* `extends AuthController`) at the same `/auth` prefix with no duplicate
|
|
54
|
+
* route. See docs/authentication.md.
|
|
48
55
|
*/
|
|
49
56
|
static forRoot(options) {
|
|
50
57
|
return {
|
|
@@ -59,10 +66,5 @@ let AuthModule = exports.AuthModule = AuthModule_1 = class AuthModule {
|
|
|
59
66
|
};
|
|
60
67
|
exports.AuthModule = AuthModule = AuthModule_1 = __decorate([
|
|
61
68
|
(0, common_1.Global)(),
|
|
62
|
-
(0, common_1.Module)({
|
|
63
|
-
imports: authImports,
|
|
64
|
-
providers: authProviders,
|
|
65
|
-
controllers: [auth_controller_1.AuthController],
|
|
66
|
-
exports: authExports,
|
|
67
|
-
})
|
|
69
|
+
(0, common_1.Module)({})
|
|
68
70
|
], AuthModule);
|
package/docs/authentication.md
CHANGED
|
@@ -10,7 +10,10 @@ framework class).
|
|
|
10
10
|
|
|
11
11
|
## What `AuthModule` provides
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
**Always wire it as `AuthModule.forRoot()`** — importing the bare `AuthModule`
|
|
14
|
+
registers nothing (all wiring lives in `forRoot()` so the controller can be
|
|
15
|
+
conditionally omitted; see the override section). `AuthModule.forRoot()` registers,
|
|
16
|
+
under the `/auth` prefix:
|
|
14
17
|
|
|
15
18
|
| Route | Guard | Body |
|
|
16
19
|
|---|---|---|
|
|
@@ -80,11 +83,13 @@ export class AppModule {}
|
|
|
80
83
|
export class MyAuthModule {}
|
|
81
84
|
```
|
|
82
85
|
|
|
83
|
-
> **Why `forRoot({ controller: false })`?** If
|
|
84
|
-
>
|
|
85
|
-
> routes
|
|
86
|
-
>
|
|
87
|
-
>
|
|
86
|
+
> **Why `forRoot({ controller: false })`?** If the built-in controller *and* your
|
|
87
|
+
> own `/auth` controller are both registered, you get two handlers for the same
|
|
88
|
+
> routes (Express runs the first-registered, so the base `RegisterDto` would win
|
|
89
|
+
> and reject your extra fields). `forRoot({ controller: false })` drops the built-in
|
|
90
|
+
> controller while keeping every provider global, so your controller takes over
|
|
91
|
+
> cleanly. Use plain `AuthModule.forRoot()` (no options) when you're *not*
|
|
92
|
+
> overriding the controller.
|
|
88
93
|
|
|
89
94
|
---
|
|
90
95
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appxdigital/appx-core",
|
|
3
|
-
"version": "0.1.121-beta.
|
|
3
|
+
"version": "0.1.121-beta.16",
|
|
4
4
|
"description": "Appx Core is a library that provides a set of tools to help you build your application faster.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|