@nocobase/plugin-auth 2.1.0-alpha.40 → 2.1.0-alpha.46
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/client/{443.634aca1f12f4906b.js → 443.aa711879b4855b88.js} +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client-v2/{217.67ac4fe4bbc76329.js → 217.09744ff679406aff.js} +1 -1
- package/dist/client-v2/657.2a9dcca9ddc31ec0.js +10 -0
- package/dist/client-v2/{795.6fbe6abacb03f9a6.js → 795.b26178560fd03daa.js} +1 -1
- package/dist/client-v2/{841.83e6cab5e9918668.js → 841.ac9bfbb0615510e5.js} +1 -1
- package/dist/client-v2/{9.e88efa64328b39d7.js → 9.5301763a7da120fa.js} +1 -1
- package/dist/client-v2/index.js +1 -1
- package/dist/client-v2/locale.d.ts +0 -170
- package/dist/client-v2/pages/TokenPolicyPage.d.ts +32 -0
- package/dist/client-v2/plugin.d.ts +3 -11
- package/dist/externalVersion.js +11 -11
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -2
- package/dist/node_modules/cron/package.json +1 -1
- package/dist/node_modules/ms/package.json +1 -1
- package/dist/server/collections/issued-tokens.js +5 -0
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +5 -1
- package/dist/server/plugin.d.ts +2 -0
- package/dist/server/plugin.js +2 -0
- package/dist/server/token-controller.d.ts +3 -1
- package/dist/server/token-controller.js +3 -2
- package/dist/server/utils/buildRedirectPath.d.ts +32 -9
- package/dist/server/utils/buildRedirectPath.js +16 -2
- package/package.json +2 -2
package/dist/server/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export { BasicAuth } from './basic-auth';
|
|
|
10
10
|
export { AuthModel } from './model/authenticator';
|
|
11
11
|
export { presetAuthType } from '../preset';
|
|
12
12
|
export { defaultTokenPolicyConfig } from '../constants';
|
|
13
|
-
export { buildRedirectPath } from './utils/buildRedirectPath';
|
|
14
|
-
export type { BuildRedirectPathOptions } from './utils/buildRedirectPath';
|
|
13
|
+
export { buildRedirectPath, getModernClientPrefix, resolveSigninPrefix } from './utils/buildRedirectPath';
|
|
14
|
+
export type { BuildRedirectPathOptions, ResolveSigninPrefixOptions } from './utils/buildRedirectPath';
|
|
15
15
|
export { default } from './plugin';
|
|
16
16
|
export * from '../constants';
|
package/dist/server/index.js
CHANGED
|
@@ -42,7 +42,9 @@ __export(server_exports, {
|
|
|
42
42
|
buildRedirectPath: () => import_buildRedirectPath.buildRedirectPath,
|
|
43
43
|
default: () => import_plugin.default,
|
|
44
44
|
defaultTokenPolicyConfig: () => import_constants.defaultTokenPolicyConfig,
|
|
45
|
-
|
|
45
|
+
getModernClientPrefix: () => import_buildRedirectPath.getModernClientPrefix,
|
|
46
|
+
presetAuthType: () => import_preset.presetAuthType,
|
|
47
|
+
resolveSigninPrefix: () => import_buildRedirectPath.resolveSigninPrefix
|
|
46
48
|
});
|
|
47
49
|
module.exports = __toCommonJS(server_exports);
|
|
48
50
|
var import_basic_auth = require("./basic-auth");
|
|
@@ -58,6 +60,8 @@ __reExport(server_exports, require("../constants"), module.exports);
|
|
|
58
60
|
BasicAuth,
|
|
59
61
|
buildRedirectPath,
|
|
60
62
|
defaultTokenPolicyConfig,
|
|
63
|
+
getModernClientPrefix,
|
|
61
64
|
presetAuthType,
|
|
65
|
+
resolveSigninPrefix,
|
|
62
66
|
...require("../constants")
|
|
63
67
|
});
|
package/dist/server/plugin.d.ts
CHANGED
|
@@ -8,8 +8,10 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { Cache } from '@nocobase/cache';
|
|
10
10
|
import { InstallOptions, Plugin } from '@nocobase/server';
|
|
11
|
+
import { Storer } from './storer';
|
|
11
12
|
export declare class PluginAuthServer extends Plugin {
|
|
12
13
|
cache: Cache;
|
|
14
|
+
storer: Storer;
|
|
13
15
|
afterAdd(): void;
|
|
14
16
|
beforeLoad(): Promise<void>;
|
|
15
17
|
load(): Promise<void>;
|
package/dist/server/plugin.js
CHANGED
|
@@ -53,6 +53,7 @@ var import_token_blacklist = require("./token-blacklist");
|
|
|
53
53
|
var import_token_controller = require("./token-controller");
|
|
54
54
|
class PluginAuthServer extends import_server.Plugin {
|
|
55
55
|
cache;
|
|
56
|
+
storer;
|
|
56
57
|
afterAdd() {
|
|
57
58
|
this.app.on("afterLoad", async () => {
|
|
58
59
|
if (this.app.authManager.tokenController) {
|
|
@@ -90,6 +91,7 @@ class PluginAuthServer extends import_server.Plugin {
|
|
|
90
91
|
cache: this.cache,
|
|
91
92
|
authManager: this.app.authManager
|
|
92
93
|
});
|
|
94
|
+
this.storer = storer;
|
|
93
95
|
this.app.authManager.setStorer(storer);
|
|
94
96
|
if (!this.app.authManager.jwt.blacklist) {
|
|
95
97
|
this.app.authManager.setTokenBlacklistService(new import_token_blacklist.TokenBlacklistService(this));
|
|
@@ -26,14 +26,16 @@ export declare class TokenController implements TokenControlService {
|
|
|
26
26
|
getConfig(): Promise<NumericTokenPolicyConfig>;
|
|
27
27
|
setConfig(config: TokenPolicyConfig): Promise<void>;
|
|
28
28
|
removeSessionExpiredTokens(userId: number): Promise<number>;
|
|
29
|
-
add({ userId }: {
|
|
29
|
+
add({ userId, authenticator }: {
|
|
30
30
|
userId: number;
|
|
31
|
+
authenticator?: string;
|
|
31
32
|
}): Promise<{
|
|
32
33
|
jti: `${string}-${string}-${string}-${string}-${string}`;
|
|
33
34
|
issuedTime: number;
|
|
34
35
|
signInTime: number;
|
|
35
36
|
renewed: boolean;
|
|
36
37
|
userId: number;
|
|
38
|
+
authenticator: string;
|
|
37
39
|
}>;
|
|
38
40
|
renew: TokenControlService['renew'];
|
|
39
41
|
}
|
|
@@ -93,7 +93,7 @@ class TokenController {
|
|
|
93
93
|
}
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
|
-
async add({ userId }) {
|
|
96
|
+
async add({ userId, authenticator }) {
|
|
97
97
|
const jti = (0, import_crypto.randomUUID)();
|
|
98
98
|
const currTS = Date.now();
|
|
99
99
|
const data = {
|
|
@@ -101,7 +101,8 @@ class TokenController {
|
|
|
101
101
|
issuedTime: currTS,
|
|
102
102
|
signInTime: currTS,
|
|
103
103
|
renewed: false,
|
|
104
|
-
userId
|
|
104
|
+
userId,
|
|
105
|
+
authenticator
|
|
105
106
|
};
|
|
106
107
|
await this.setTokenInfo(jti, data);
|
|
107
108
|
try {
|
|
@@ -22,8 +22,8 @@ export interface BuildRedirectPathOptions {
|
|
|
22
22
|
/**
|
|
23
23
|
* The raw redirect the client supplied. May be:
|
|
24
24
|
* - v1 basename-relative (`/admin/abc`), needs full prefix prepended.
|
|
25
|
-
* -
|
|
26
|
-
* `/nocobase/
|
|
25
|
+
* - modern-client root-relative (`/nocobase/v/admin/abc` or
|
|
26
|
+
* `/nocobase/v/apps/<id>/admin/abc`), already absolute under the
|
|
27
27
|
* document root; must NOT be touched.
|
|
28
28
|
* - missing — falls back to `/admin`.
|
|
29
29
|
*/
|
|
@@ -35,16 +35,39 @@ export interface BuildRedirectPathOptions {
|
|
|
35
35
|
*
|
|
36
36
|
* v1 clients emit `redirect` as a basename-relative path (`/admin/abc`)
|
|
37
37
|
* and the server is expected to prepend `APP_PUBLIC_PATH` + the legacy
|
|
38
|
-
* sub-app segment. v2 clients emit `redirect` as an already-root-
|
|
39
|
-
* path that includes `APP_PUBLIC_PATH` and (for sub-apps) the
|
|
40
|
-
*
|
|
41
|
-
* URLs like `/nocobase/apps/<id>/nocobase/
|
|
38
|
+
* sub-app segment. Modern (v2) clients emit `redirect` as an already-root-
|
|
39
|
+
* relative path that includes `APP_PUBLIC_PATH` and (for sub-apps) the
|
|
40
|
+
* `/<modern-prefix>/apps/<id>` segment — so any further prepending produces
|
|
41
|
+
* nonsense URLs like `/nocobase/apps/<id>/nocobase/v/apps/<id>/admin/…`.
|
|
42
42
|
*
|
|
43
|
-
* Detection rule: a target is
|
|
43
|
+
* Detection rule: a target is modern-shaped iff it starts with
|
|
44
44
|
* `appPublicPath + '/'`. The sub-app segment is irrelevant to detection
|
|
45
|
-
* because
|
|
46
|
-
* (`/<APP_PUBLIC_PATH>/
|
|
45
|
+
* because modern clients always prefix with `appPublicPath` regardless of
|
|
46
|
+
* sub-app (`/<APP_PUBLIC_PATH>/v/...` or `/<…>/v/apps/<id>/...`).
|
|
47
47
|
*
|
|
48
48
|
* Single export shared by all auth-related SSO plugins (CAS, SAML, …).
|
|
49
49
|
*/
|
|
50
50
|
export declare function buildRedirectPath({ appPublicPath, subAppSegment, target }: BuildRedirectPathOptions): string;
|
|
51
|
+
/**
|
|
52
|
+
* The runtime URL segment under which the modern (v2) client is served,
|
|
53
|
+
* read from `APP_MODERN_CLIENT_PREFIX` (default `v`). Returns a bare
|
|
54
|
+
* segment without surrounding slashes.
|
|
55
|
+
*/
|
|
56
|
+
export declare function getModernClientPrefix(): string;
|
|
57
|
+
export interface ResolveSigninPrefixOptions {
|
|
58
|
+
/** `process.env.APP_PUBLIC_PATH`, with or without trailing slash. */
|
|
59
|
+
appPublicPath?: string | null;
|
|
60
|
+
/** The raw redirect target supplied by the client (RelayState / state / query). */
|
|
61
|
+
redirect?: string | null;
|
|
62
|
+
/** Legacy (v1) sub-app segment, e.g. `/apps/<name>` or empty. */
|
|
63
|
+
subAppSegment?: string | null;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* On SSO failure the user must land back on the signin page of the *same*
|
|
67
|
+
* shell they started from (legacy v1 vs modern v2). Modern-client URLs always
|
|
68
|
+
* carry the `<APP_PUBLIC_PATH>/<modern-prefix>/` segment in the redirect;
|
|
69
|
+
* legacy URLs never do. Returns the signin prefix to prepend to `/signin`.
|
|
70
|
+
*
|
|
71
|
+
* Shared by all SSO plugins (SAML, OIDC, CAS).
|
|
72
|
+
*/
|
|
73
|
+
export declare function resolveSigninPrefix({ appPublicPath, redirect, subAppSegment }: ResolveSigninPrefixOptions): string;
|
|
@@ -26,7 +26,9 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
26
26
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
27
|
var buildRedirectPath_exports = {};
|
|
28
28
|
__export(buildRedirectPath_exports, {
|
|
29
|
-
buildRedirectPath: () => buildRedirectPath
|
|
29
|
+
buildRedirectPath: () => buildRedirectPath,
|
|
30
|
+
getModernClientPrefix: () => getModernClientPrefix,
|
|
31
|
+
resolveSigninPrefix: () => resolveSigninPrefix
|
|
30
32
|
});
|
|
31
33
|
module.exports = __toCommonJS(buildRedirectPath_exports);
|
|
32
34
|
function buildRedirectPath({ appPublicPath, subAppSegment, target }) {
|
|
@@ -38,7 +40,19 @@ function buildRedirectPath({ appPublicPath, subAppSegment, target }) {
|
|
|
38
40
|
}
|
|
39
41
|
return `${normalizedAppPublicPath}${normalizedSubAppSegment}${resolvedTarget}`;
|
|
40
42
|
}
|
|
43
|
+
function getModernClientPrefix() {
|
|
44
|
+
return String(process.env.APP_MODERN_CLIENT_PREFIX || "").trim().replace(/^\/+|\/+$/g, "") || "v";
|
|
45
|
+
}
|
|
46
|
+
function resolveSigninPrefix({ appPublicPath, redirect, subAppSegment }) {
|
|
47
|
+
const normalizedAppPublicPath = (appPublicPath || "").replace(/\/+$/, "");
|
|
48
|
+
const modernSegment = `/${getModernClientPrefix()}`;
|
|
49
|
+
const modernMarker = `${normalizedAppPublicPath}${modernSegment}`;
|
|
50
|
+
const isModernOrigin = typeof redirect === "string" && (redirect === modernMarker || redirect.startsWith(`${modernMarker}/`));
|
|
51
|
+
return `${normalizedAppPublicPath}${isModernOrigin ? modernSegment : ""}${subAppSegment || ""}`;
|
|
52
|
+
}
|
|
41
53
|
// Annotate the CommonJS export names for ESM import in node:
|
|
42
54
|
0 && (module.exports = {
|
|
43
|
-
buildRedirectPath
|
|
55
|
+
buildRedirectPath,
|
|
56
|
+
getModernClientPrefix,
|
|
57
|
+
resolveSigninPrefix
|
|
44
58
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-auth",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.46",
|
|
4
4
|
"main": "./dist/server/index.js",
|
|
5
5
|
"homepage": "https://docs.nocobase.com/handbook/auth",
|
|
6
6
|
"homepage.ru-RU": "https://docs-ru.nocobase.com/handbook/auth",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"description": "User authentication management, including password, SMS, and support for Single Sign-On (SSO) protocols, with extensibility.",
|
|
32
32
|
"description.ru-RU": "Управление аутентификацией пользователей: пароли, SMS, поддержка протоколов единого входа (SSO) и возможность расширения.",
|
|
33
33
|
"description.zh-CN": "用户认证管理,包括基础的密码认证、短信认证、SSO 协议的认证等,可扩展。",
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "42b269944cdd1908d7a848c0af4936fe94c03bb7",
|
|
35
35
|
"keywords": [
|
|
36
36
|
"Authentication",
|
|
37
37
|
"Security"
|