@nocobase/plugin-auth 2.3.0-alpha.1 → 2.3.0-beta.10

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.
@@ -8,21 +8,21 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.3.0-alpha.1",
11
+ "@nocobase/client": "2.3.0-beta.10",
12
12
  "react": "18.2.0",
13
13
  "react-router-dom": "6.30.1",
14
- "@nocobase/utils": "2.3.0-alpha.1",
14
+ "@nocobase/utils": "2.3.0-beta.10",
15
15
  "axios": "1.7.7",
16
16
  "lodash": "4.18.1",
17
- "@nocobase/client-v2": "2.3.0-alpha.1",
18
- "@nocobase/flow-engine": "2.3.0-alpha.1",
17
+ "@nocobase/client-v2": "2.3.0-beta.10",
18
+ "@nocobase/flow-engine": "2.3.0-beta.10",
19
19
  "react-i18next": "11.18.6",
20
- "@nocobase/auth": "2.3.0-alpha.1",
21
- "@nocobase/database": "2.3.0-alpha.1",
22
- "@nocobase/cache": "2.3.0-alpha.1",
23
- "@nocobase/server": "2.3.0-alpha.1",
24
- "@nocobase/logger": "2.3.0-alpha.1",
25
- "@nocobase/test": "2.3.0-alpha.1",
20
+ "@nocobase/auth": "2.3.0-beta.10",
21
+ "@nocobase/database": "2.3.0-beta.10",
22
+ "@nocobase/cache": "2.3.0-beta.10",
23
+ "@nocobase/server": "2.3.0-beta.10",
24
+ "@nocobase/logger": "2.3.0-beta.10",
25
+ "@nocobase/test": "2.3.0-beta.10",
26
26
  "@formily/antd-v5": "1.2.3",
27
27
  "antd": "5.24.2",
28
28
  "@formily/shared": "2.3.7",
@@ -30,6 +30,6 @@ module.exports = {
30
30
  "@emotion/css": "11.13.0",
31
31
  "@ant-design/icons": "5.6.1",
32
32
  "ahooks": "3.7.8",
33
- "@nocobase/actions": "2.3.0-alpha.1",
33
+ "@nocobase/actions": "2.3.0-beta.10",
34
34
  "@formily/core": "2.3.7"
35
35
  };
package/dist/index.d.ts CHANGED
@@ -6,5 +6,5 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
- export { AuthModel, BasicAuth, buildRedirectPath, defaultTokenPolicyConfig, default, getModernClientPrefix, presetAuthType, resolveSigninPrefix, } from './server';
9
+ export { AuthModel, BasicAuth, buildRedirectPath, defaultTokenPolicyConfig, default, getModernClientPrefix, presetAuthType, resolveSubAppSegment, resolveSigninPrefix, } from './server';
10
10
  export type { BuildRedirectPathOptions, ResolveSigninPrefixOptions } from './server';
package/dist/index.js CHANGED
@@ -43,7 +43,8 @@ __export(src_exports, {
43
43
  defaultTokenPolicyConfig: () => import_server.defaultTokenPolicyConfig,
44
44
  getModernClientPrefix: () => import_server.getModernClientPrefix,
45
45
  presetAuthType: () => import_server.presetAuthType,
46
- resolveSigninPrefix: () => import_server.resolveSigninPrefix
46
+ resolveSigninPrefix: () => import_server.resolveSigninPrefix,
47
+ resolveSubAppSegment: () => import_server.resolveSubAppSegment
47
48
  });
48
49
  module.exports = __toCommonJS(src_exports);
49
50
  var import_server = __toESM(require("./server"));
@@ -55,5 +56,6 @@ var import_server = __toESM(require("./server"));
55
56
  defaultTokenPolicyConfig,
56
57
  getModernClientPrefix,
57
58
  presetAuthType,
58
- resolveSigninPrefix
59
+ resolveSigninPrefix,
60
+ resolveSubAppSegment
59
61
  });
@@ -1 +1 @@
1
- {"name":"cron","description":"Cron jobs for your node","version":"2.4.4","author":"Nick Campbell <nicholas.j.campbell@gmail.com> (https://github.com/ncb000gt)","bugs":{"url":"https://github.com/kelektiv/node-cron/issues"},"repository":{"type":"git","url":"https://github.com/kelektiv/node-cron.git"},"main":"lib/cron","scripts":{"lint":"eslint {lib,tests}/*.js","test":"jest --coverage","test:watch":"jest --watch --coverage","test:types":"tsd","prepare":"husky install","release":"semantic-release"},"types":"types/index.d.ts","dependencies":{"@types/luxon":"~3.3.0","luxon":"~3.3.0"},"devDependencies":{"@commitlint/cli":"~17.6.6","@insurgentlab/commitlint-config":"^18.1.0","@insurgentlab/conventional-changelog-preset":"~6.0.3","@semantic-release/changelog":"~6.0.x","@semantic-release/commit-analyzer":"~9.0.x","@semantic-release/git":"~10.0.x","@semantic-release/github":"~8.1.x","@semantic-release/npm":"~10.0.x","@semantic-release/release-notes-generator":"~11.0.x","chai":"~4.2.x","eslint":"~8.36.x","eslint-config-prettier":"^8.7.x","eslint-config-standard":"~17.0.x","eslint-plugin-import":"~2.27.x","eslint-plugin-jest":"~27.2.x","eslint-plugin-n":"~15.6.x","eslint-plugin-prettier":"~4.2.x","eslint-plugin-promise":"~6.1.x","husky":"^8.0.3","jest":"~29.5.x","prettier":"~2.8.x","semantic-release":"~21.0.x","sinon":"^15.0.x","tsd":"^0.28.1"},"keywords":["cron","node cron","node-cron","schedule","scheduler","cronjob","cron job"],"license":"MIT","contributors":["Brandon der Blätter <https://interlucid.com/contact/> (https://github.com/intcreator)","Romain Beauxis <toots@rastageeks.org> (https://github.com/toots)","James Padolsey <> (https://github.com/jamespadolsey)","Finn Herpich <fh@three-heads.de> (https://github.com/ErrorProne)","Clifton Cunningham <clifton.cunningham@gmail.com> (https://github.com/cliftonc)","Eric Abouaf <eric.abouaf@gmail.com> (https://github.com/neyric)","humanchimp <morphcham@gmail.com> (https://github.com/humanchimp)","Craig Condon <craig@spiceapps.com> (https://github.com/spiceapps)","Dan Bear <daniel@hulu.com> (https://github.com/danhbear)","Vadim Baryshev <vadimbaryshev@gmail.com> (https://github.com/baryshev)","Leandro Ferrari <lfthomaz@gmail.com> (https://github.com/lfthomaz)","Gregg Zigler <greggzigler@gmail.com> (https://github.com/greggzigler)","Jordan Abderrachid <jabderrachid@gmail.com> (https://github.com/jordanabderrachid)","Masakazu Matsushita <matsukaz@gmail.com> (matsukaz)","Christopher Lunt <me@kirisu.co.uk> (https://github.com/kirisu)"],"jest":{"collectCoverage":true,"collectCoverageFrom":["lib/*.js"],"coverageThreshold":{"global":{"statements":80,"branches":80,"functions":70,"lines":80}}},"files":["lib","types","CHANGELOG.md","LICENSE","README.md"],"_lastModified":"2026-07-16T12:56:43.859Z"}
1
+ {"name":"cron","description":"Cron jobs for your node","version":"2.4.4","author":"Nick Campbell <nicholas.j.campbell@gmail.com> (https://github.com/ncb000gt)","bugs":{"url":"https://github.com/kelektiv/node-cron/issues"},"repository":{"type":"git","url":"https://github.com/kelektiv/node-cron.git"},"main":"lib/cron","scripts":{"lint":"eslint {lib,tests}/*.js","test":"jest --coverage","test:watch":"jest --watch --coverage","test:types":"tsd","prepare":"husky install","release":"semantic-release"},"types":"types/index.d.ts","dependencies":{"@types/luxon":"~3.3.0","luxon":"~3.3.0"},"devDependencies":{"@commitlint/cli":"~17.6.6","@insurgentlab/commitlint-config":"^18.1.0","@insurgentlab/conventional-changelog-preset":"~6.0.3","@semantic-release/changelog":"~6.0.x","@semantic-release/commit-analyzer":"~9.0.x","@semantic-release/git":"~10.0.x","@semantic-release/github":"~8.1.x","@semantic-release/npm":"~10.0.x","@semantic-release/release-notes-generator":"~11.0.x","chai":"~4.2.x","eslint":"~8.36.x","eslint-config-prettier":"^8.7.x","eslint-config-standard":"~17.0.x","eslint-plugin-import":"~2.27.x","eslint-plugin-jest":"~27.2.x","eslint-plugin-n":"~15.6.x","eslint-plugin-prettier":"~4.2.x","eslint-plugin-promise":"~6.1.x","husky":"^8.0.3","jest":"~29.5.x","prettier":"~2.8.x","semantic-release":"~21.0.x","sinon":"^15.0.x","tsd":"^0.28.1"},"keywords":["cron","node cron","node-cron","schedule","scheduler","cronjob","cron job"],"license":"MIT","contributors":["Brandon der Blätter <https://interlucid.com/contact/> (https://github.com/intcreator)","Romain Beauxis <toots@rastageeks.org> (https://github.com/toots)","James Padolsey <> (https://github.com/jamespadolsey)","Finn Herpich <fh@three-heads.de> (https://github.com/ErrorProne)","Clifton Cunningham <clifton.cunningham@gmail.com> (https://github.com/cliftonc)","Eric Abouaf <eric.abouaf@gmail.com> (https://github.com/neyric)","humanchimp <morphcham@gmail.com> (https://github.com/humanchimp)","Craig Condon <craig@spiceapps.com> (https://github.com/spiceapps)","Dan Bear <daniel@hulu.com> (https://github.com/danhbear)","Vadim Baryshev <vadimbaryshev@gmail.com> (https://github.com/baryshev)","Leandro Ferrari <lfthomaz@gmail.com> (https://github.com/lfthomaz)","Gregg Zigler <greggzigler@gmail.com> (https://github.com/greggzigler)","Jordan Abderrachid <jabderrachid@gmail.com> (https://github.com/jordanabderrachid)","Masakazu Matsushita <matsukaz@gmail.com> (matsukaz)","Christopher Lunt <me@kirisu.co.uk> (https://github.com/kirisu)"],"jest":{"collectCoverage":true,"collectCoverageFrom":["lib/*.js"],"coverageThreshold":{"global":{"statements":80,"branches":80,"functions":70,"lines":80}}},"files":["lib","types","CHANGELOG.md","LICENSE","README.md"],"_lastModified":"2026-09-15T04:37:06.183Z"}
@@ -1 +1 @@
1
- {"name":"ms","version":"2.1.3","description":"Tiny millisecond conversion utility","repository":"vercel/ms","main":"./index","files":["index.js"],"scripts":{"precommit":"lint-staged","lint":"eslint lib/* bin/*","test":"mocha tests.js"},"eslintConfig":{"extends":"eslint:recommended","env":{"node":true,"es6":true}},"lint-staged":{"*.js":["npm run lint","prettier --single-quote --write","git add"]},"license":"MIT","devDependencies":{"eslint":"4.18.2","expect.js":"0.3.1","husky":"0.14.3","lint-staged":"5.0.0","mocha":"4.0.1","prettier":"2.0.5"},"_lastModified":"2026-07-16T12:56:43.948Z"}
1
+ {"name":"ms","version":"2.1.3","description":"Tiny millisecond conversion utility","repository":"vercel/ms","main":"./index","files":["index.js"],"scripts":{"precommit":"lint-staged","lint":"eslint lib/* bin/*","test":"mocha tests.js"},"eslintConfig":{"extends":"eslint:recommended","env":{"node":true,"es6":true}},"lint-staged":{"*.js":["npm run lint","prettier --single-quote --write","git add"]},"license":"MIT","devDependencies":{"eslint":"4.18.2","expect.js":"0.3.1","husky":"0.14.3","lint-staged":"5.0.0","mocha":"4.0.1","prettier":"2.0.5"},"_lastModified":"2026-09-15T04:37:06.275Z"}
@@ -12,5 +12,6 @@ export { presetAuthType } from '../preset';
12
12
  export { defaultTokenPolicyConfig } from '../constants';
13
13
  export { buildRedirectPath, getModernClientPrefix, resolveSigninPrefix } from './utils/buildRedirectPath';
14
14
  export type { BuildRedirectPathOptions, ResolveSigninPrefixOptions } from './utils/buildRedirectPath';
15
+ export { resolveSubAppSegment } from './utils/resolveSubAppSegment';
15
16
  export { default } from './plugin';
16
17
  export * from '../constants';
@@ -44,7 +44,8 @@ __export(server_exports, {
44
44
  defaultTokenPolicyConfig: () => import_constants.defaultTokenPolicyConfig,
45
45
  getModernClientPrefix: () => import_buildRedirectPath.getModernClientPrefix,
46
46
  presetAuthType: () => import_preset.presetAuthType,
47
- resolveSigninPrefix: () => import_buildRedirectPath.resolveSigninPrefix
47
+ resolveSigninPrefix: () => import_buildRedirectPath.resolveSigninPrefix,
48
+ resolveSubAppSegment: () => import_resolveSubAppSegment.resolveSubAppSegment
48
49
  });
49
50
  module.exports = __toCommonJS(server_exports);
50
51
  var import_basic_auth = require("./basic-auth");
@@ -52,6 +53,7 @@ var import_authenticator = require("./model/authenticator");
52
53
  var import_preset = require("../preset");
53
54
  var import_constants = require("../constants");
54
55
  var import_buildRedirectPath = require("./utils/buildRedirectPath");
56
+ var import_resolveSubAppSegment = require("./utils/resolveSubAppSegment");
55
57
  var import_plugin = __toESM(require("./plugin"));
56
58
  __reExport(server_exports, require("../constants"), module.exports);
57
59
  // Annotate the CommonJS export names for ESM import in node:
@@ -63,5 +65,6 @@ __reExport(server_exports, require("../constants"), module.exports);
63
65
  getModernClientPrefix,
64
66
  presetAuthType,
65
67
  resolveSigninPrefix,
68
+ resolveSubAppSegment,
66
69
  ...require("../constants")
67
70
  });
@@ -139,6 +139,11 @@ class PluginAuthServer extends import_server.Plugin {
139
139
  ["check", "signOut", "syncCookies", "changePassword"].forEach(
140
140
  (action) => this.app.acl.allow("auth", action, "loggedIn")
141
141
  );
142
+ this.app.acl.allow(
143
+ "auth",
144
+ "checkLegacyFileAccess",
145
+ (ctx) => ctx.state.currentUser || ctx.state.legacyLocalStoragePublicAccess === true
146
+ );
142
147
  ["lostPassword", "resetPassword", "checkResetToken"].forEach(
143
148
  (action) => this.app.acl.allow("auth", action, "public")
144
149
  );
@@ -26,6 +26,7 @@ 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
+ private cleanupSessionExpiredTokens;
29
30
  add({ userId, authenticator }: {
30
31
  userId: number;
31
32
  authenticator?: string;
@@ -93,6 +93,13 @@ class TokenController {
93
93
  }
94
94
  });
95
95
  }
96
+ async cleanupSessionExpiredTokens(userId) {
97
+ try {
98
+ await this.removeSessionExpiredTokens(userId);
99
+ } catch (err) {
100
+ this.logger.error(err, { module: "auth", submodule: "token-controller", method: "removeSessionExpiredTokens" });
101
+ }
102
+ }
96
103
  async add({ userId, authenticator }) {
97
104
  const jti = (0, import_crypto.randomUUID)();
98
105
  const currTS = Date.now();
@@ -105,14 +112,10 @@ class TokenController {
105
112
  authenticator
106
113
  };
107
114
  await this.setTokenInfo(jti, data);
108
- try {
109
- if (process.env.DB_DIALECT === "sqlite") {
110
- await this.removeSessionExpiredTokens(userId);
111
- } else {
112
- this.removeSessionExpiredTokens(userId);
113
- }
114
- } catch (err) {
115
- this.logger.error(err, { module: "auth", submodule: "token-controller", method: "removeSessionExpiredTokens" });
115
+ if (process.env.DB_DIALECT === "sqlite") {
116
+ await this.cleanupSessionExpiredTokens(userId);
117
+ } else {
118
+ this.cleanupSessionExpiredTokens(userId);
116
119
  }
117
120
  return data;
118
121
  }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ /// <reference types="node" />
10
+ import type { IncomingMessage } from 'http';
11
+ /**
12
+ * Resolve the legacy sub-application URL segment for an authentication
13
+ * redirect. A sub-application reached through its custom domain is mounted at
14
+ * the root, while one reached through the supervisor domain uses
15
+ * `/apps/<name>`.
16
+ */
17
+ export declare function resolveSubAppSegment(req: IncomingMessage, appName?: string | null): Promise<string>;
@@ -0,0 +1,82 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var resolveSubAppSegment_exports = {};
28
+ __export(resolveSubAppSegment_exports, {
29
+ resolveSubAppSegment: () => resolveSubAppSegment
30
+ });
31
+ module.exports = __toCommonJS(resolveSubAppSegment_exports);
32
+ var import_server = require("@nocobase/server");
33
+ function normalizeHostname(value) {
34
+ const host = value == null ? void 0 : value.split(",", 1)[0].trim();
35
+ if (!host) {
36
+ return "";
37
+ }
38
+ try {
39
+ return new URL(`http://${host}`).hostname;
40
+ } catch {
41
+ return "";
42
+ }
43
+ }
44
+ function getRequestHostname(req) {
45
+ const hostnameHeader = req.headers["x-hostname"];
46
+ if (Array.isArray(hostnameHeader)) {
47
+ for (const value of hostnameHeader) {
48
+ const hostname = normalizeHostname(value);
49
+ if (hostname) {
50
+ return hostname;
51
+ }
52
+ }
53
+ } else {
54
+ const hostname = normalizeHostname(hostnameHeader);
55
+ if (hostname) {
56
+ return hostname;
57
+ }
58
+ }
59
+ return (0, import_server.getHostname)(req);
60
+ }
61
+ async function resolveSubAppSegment(req, appName) {
62
+ var _a;
63
+ if (!appName || appName === "main") {
64
+ return "";
65
+ }
66
+ const appSupervisor = import_server.AppSupervisor.getInstance();
67
+ if (!appSupervisor || appSupervisor.runningMode === "single") {
68
+ return "";
69
+ }
70
+ const hostname = getRequestHostname(req);
71
+ if (hostname) {
72
+ const cnameAppName = await ((_a = appSupervisor.getAppNameByCName) == null ? void 0 : _a.call(appSupervisor, hostname));
73
+ if (cnameAppName === appName) {
74
+ return "";
75
+ }
76
+ }
77
+ return `/apps/${appName}`;
78
+ }
79
+ // Annotate the CommonJS export names for ESM import in node:
80
+ 0 && (module.exports = {
81
+ resolveSubAppSegment
82
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-auth",
3
- "version": "2.3.0-alpha.1",
3
+ "version": "2.3.0-beta.10",
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": "2377df8ceb12549149017f7f14a61207bf6e49a2",
34
+ "gitHead": "7aa3dce6cf3201752882f7012c72997898015d89",
35
35
  "keywords": [
36
36
  "Authentication",
37
37
  "Security"