cabloy 5.1.243 → 5.1.244
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/.cabloy-version +1 -1
- package/.github/workflows/vona-test-sqlite3.yml +1 -1
- package/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/repo-agent-governance/managed-assets.json +6 -6
- package/repo-agent-governance/policies/repository.md +1 -0
- package/repo-agent-governance/skills/cabloy-frontend-scaffold/SKILL.md +4 -2
- package/repo-docs/backend/auth-guide.md +48 -0
- package/repo-docs/backend/demonstration-mode-guide.md +22 -5
- package/repo-docs/backend/openapi-guide.md +1 -1
- package/repo-docs/frontend/behavior-guide.md +12 -0
- package/repo-e2e/specs/home-user-account.spec.ts +98 -3
- package/vona/env/.env +2 -0
- package/vona/packages-cli/cli/package.json +1 -1
- package/vona/packages-cli/cli-set-api/package.json +1 -1
- package/vona/packages-utils/babel-plugin-vona-bean-module/package.json +1 -1
- package/vona/packages-utils/babel-plugin-vona-bean-module/src/index.test.ts +27 -0
- package/vona/packages-utils/babel-plugin-vona-bean-module/src/index.ts +1 -0
- package/vona/packages-vona/vona/package.json +1 -1
- package/vona/src/suite/a-demo/modules/demo-demonstration/src/bean/guard.demonstration.ts +8 -1
- package/vona/src/suite/a-demo/modules/demo-demonstration/test/guardDemonstration.test.ts +76 -1
- package/vona/src/suite/a-home/modules/home-user/test/passportSession.test.ts +380 -0
- package/vona/src/suite-vendor/a-cabloy/modules/a-rbac/package.json +1 -1
- package/vona/src/suite-vendor/a-cabloy/package.json +2 -2
- package/vona/src/suite-vendor/a-vona/modules/a-openapiutils/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-openapiutils/src/lib/decorator/mcp.ts +2 -2
- package/vona/src/suite-vendor/a-vona/modules/a-permission/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-user/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-user/src/bean/bean.passport.ts +82 -20
- package/vona/src/suite-vendor/a-vona/modules/a-user/src/config/config.ts +4 -1
- package/vona/src/suite-vendor/a-vona/modules/a-user/src/lib/auth.ts +20 -1
- package/vona/src/suite-vendor/a-vona/modules/a-user/src/main.ts +3 -0
- package/vona/src/suite-vendor/a-vona/modules/a-user/src/service/authTokenAdapter.ts +4 -1
- package/vona/src/suite-vendor/a-vona/modules/a-user/src/service/redisToken.ts +6 -2
- package/vona/src/suite-vendor/a-vona/modules/a-user/src/types/auth.ts +8 -0
- package/vona/src/suite-vendor/a-vona/modules/a-user/src/types/passport.ts +1 -0
- package/vona/src/suite-vendor/a-vona/package.json +1 -1
- package/zova/src/suite/a-home/modules/home-layoutadmin/src/component/layoutAdmin/render.user.tsx +5 -4
- package/zova/src/suite/a-home/modules/home-layoutweb/src/component/layoutWeb/render.user.tsx +5 -4
|
@@ -2,9 +2,12 @@ import type { IModuleMain, VonaContext } from 'vona';
|
|
|
2
2
|
|
|
3
3
|
import { BeanSimple } from 'vona';
|
|
4
4
|
|
|
5
|
+
import { $getAuthTokenMode } from './lib/auth.ts';
|
|
6
|
+
|
|
5
7
|
export class Main extends BeanSimple implements IModuleMain {
|
|
6
8
|
async moduleLoading() {}
|
|
7
9
|
async moduleLoaded() {
|
|
10
|
+
$getAuthTokenMode(this.app.config.modules['a-user'].authToken);
|
|
8
11
|
// user
|
|
9
12
|
Object.defineProperty(this.app.context, 'user', {
|
|
10
13
|
enumerable: false,
|
|
@@ -10,7 +10,10 @@ import type { IUser } from '../types/user.ts';
|
|
|
10
10
|
export class ServiceAuthTokenAdapter extends BeanBase implements IAuthTokenAdapter {
|
|
11
11
|
async create(payloadData: IPayloadData, ttl?: number): Promise<IPayloadData> {
|
|
12
12
|
const authIdStr = this._getAuthId(payloadData)?.toString();
|
|
13
|
-
const token =
|
|
13
|
+
const token =
|
|
14
|
+
this.bean.passport.authTokenMode === 'auth' && authIdStr === '-1'
|
|
15
|
+
? createHash(authIdStr)
|
|
16
|
+
: uuidv4();
|
|
14
17
|
const payloadDataNew = Object.assign({}, payloadData, {
|
|
15
18
|
[this.scope.config.payloadData.fields.token]: token,
|
|
16
19
|
});
|
|
@@ -47,11 +47,15 @@ export class ServiceRedisToken extends BeanBase {
|
|
|
47
47
|
|
|
48
48
|
private _getAuthRedisKey(payloadData: IPayloadData) {
|
|
49
49
|
if (!this.ctx.instance) return;
|
|
50
|
-
|
|
50
|
+
const key = `${this._getUserId(payloadData)}:${this._getAuthId(payloadData)}`;
|
|
51
|
+
if (this.bean.passport.authTokenMode === 'auth') return key;
|
|
52
|
+
const token = this._getToken(payloadData);
|
|
53
|
+
if (!token) return;
|
|
54
|
+
return `${key}:${token}`;
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
private _getAuthRedisKeyPrefix(user: IUser) {
|
|
54
|
-
return `${user.id}
|
|
58
|
+
return `${user.id}:`;
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
private _getToken(payloadData: IPayloadData) {
|
|
@@ -21,8 +21,10 @@ export interface IAuth {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export type TypeAuthTokenStrategy = 'reissue' | 'refresh' | 'reuse';
|
|
24
|
+
export type TypeAuthTokenMode = 'auth' | 'session';
|
|
24
25
|
|
|
25
26
|
export interface IAuthTokenConfig {
|
|
27
|
+
mode: TypeAuthTokenMode;
|
|
26
28
|
stateless: boolean;
|
|
27
29
|
strategy: {
|
|
28
30
|
refreshAuthToken: TypeAuthTokenStrategy;
|
|
@@ -60,3 +62,9 @@ export interface IAuthTokenOptions {
|
|
|
60
62
|
export interface ISigninOptions {
|
|
61
63
|
authToken?: IAuthTokenOptions;
|
|
62
64
|
}
|
|
65
|
+
|
|
66
|
+
declare module 'vona' {
|
|
67
|
+
export interface VonaConfigEnv {
|
|
68
|
+
AUTH_TOKEN_MODE: string | undefined;
|
|
69
|
+
}
|
|
70
|
+
}
|
package/zova/src/suite/a-home/modules/home-layoutadmin/src/component/layoutAdmin/render.user.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BeanRenderBase } from 'zova';
|
|
2
2
|
import { Render } from 'zova-module-a-bean';
|
|
3
|
+
import { ZButton } from 'zova-module-basic-button';
|
|
3
4
|
import { resolveImagePreviewUrl } from 'zova-module-basic-image';
|
|
4
5
|
import { closeNearestDetails } from 'zova-module-home-base';
|
|
5
6
|
|
|
@@ -32,14 +33,14 @@ export class RenderUser extends BeanRenderBase {
|
|
|
32
33
|
</a>
|
|
33
34
|
</li>
|
|
34
35
|
<li>
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
this.$passport.logout().mutate();
|
|
36
|
+
<ZButton
|
|
37
|
+
onPerform={async event => {
|
|
38
38
|
closeNearestDetails(event);
|
|
39
|
+
await this.$passport.logout().mutateAsync();
|
|
39
40
|
}}
|
|
40
41
|
>
|
|
41
42
|
{this.scope.locale.Logout()}
|
|
42
|
-
</
|
|
43
|
+
</ZButton>
|
|
43
44
|
</li>
|
|
44
45
|
</ul>
|
|
45
46
|
</details>
|
package/zova/src/suite/a-home/modules/home-layoutweb/src/component/layoutWeb/render.user.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BeanRenderBase, ClientOnly } from 'zova';
|
|
2
2
|
import { Render } from 'zova-module-a-bean';
|
|
3
|
+
import { ZButton } from 'zova-module-basic-button';
|
|
3
4
|
import { resolveImagePreviewUrl } from 'zova-module-basic-image';
|
|
4
5
|
import { closeNearestDetails } from 'zova-module-home-base';
|
|
5
6
|
|
|
@@ -39,14 +40,14 @@ export class RenderUser extends BeanRenderBase {
|
|
|
39
40
|
</a>
|
|
40
41
|
</li>
|
|
41
42
|
<li>
|
|
42
|
-
<
|
|
43
|
-
|
|
44
|
-
this.$passport.logout().mutate();
|
|
43
|
+
<ZButton
|
|
44
|
+
onPerform={async event => {
|
|
45
45
|
closeNearestDetails(event);
|
|
46
|
+
await this.$passport.logout().mutateAsync();
|
|
46
47
|
}}
|
|
47
48
|
>
|
|
48
49
|
{this.scope.locale.Logout()}
|
|
49
|
-
</
|
|
50
|
+
</ZButton>
|
|
50
51
|
</li>
|
|
51
52
|
</>
|
|
52
53
|
) : (
|