@tachybase/plugin-auth-main-app 1.6.6 → 1.6.8-alpha.1
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/externalVersion.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
"@tachybase/client": "1.6.
|
|
3
|
-
"@tachybase/module-auth": "1.6.
|
|
2
|
+
"@tachybase/client": "1.6.8-alpha.1",
|
|
3
|
+
"@tachybase/module-auth": "1.6.8-alpha.1",
|
|
4
4
|
"react": "18.3.1",
|
|
5
|
-
"@tachybase/schema": "1.6.
|
|
5
|
+
"@tachybase/schema": "1.6.3",
|
|
6
6
|
"antd": "5.22.5",
|
|
7
|
-
"@tego/server": "1.6.
|
|
7
|
+
"@tego/server": "1.6.3"
|
|
8
8
|
};
|
package/dist/server/plugin.js
CHANGED
|
@@ -71,8 +71,7 @@ var import_authMainApp = require("./actions/authMainApp");
|
|
|
71
71
|
var import_authMainAppService = require("./service/authMainAppService");
|
|
72
72
|
var _PluginAuthMainAppServer_decorators, _init, _a;
|
|
73
73
|
_PluginAuthMainAppServer_decorators = [(0, import_server.InjectedPlugin)({
|
|
74
|
-
Controllers: [import_authMainApp.AuthMainAppController]
|
|
75
|
-
Services: [import_authMainAppService.AuthMainAppService]
|
|
74
|
+
Controllers: [import_authMainApp.AuthMainAppController]
|
|
76
75
|
})];
|
|
77
76
|
class PluginAuthMainAppServer extends (_a = import_server.Plugin) {
|
|
78
77
|
async afterAdd() {
|
|
@@ -80,6 +79,8 @@ class PluginAuthMainAppServer extends (_a = import_server.Plugin) {
|
|
|
80
79
|
async beforeLoad() {
|
|
81
80
|
}
|
|
82
81
|
async load() {
|
|
82
|
+
const authMainAppService = new import_authMainAppService.AuthMainAppService(this.app);
|
|
83
|
+
await authMainAppService.load();
|
|
83
84
|
}
|
|
84
85
|
async install() {
|
|
85
86
|
}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import { Application
|
|
1
|
+
import { Application } from '@tego/server';
|
|
2
|
+
/**
|
|
3
|
+
* 主应用登录配置管理器
|
|
4
|
+
*
|
|
5
|
+
* 注意: 不使用 @Service() + @App() 装饰器, 因为全局 DI Container 在多子应用并发启动时
|
|
6
|
+
* 存在竞态条件, 会导致 @App() 注入错误的 Application 实例.
|
|
7
|
+
* 改为由 Plugin 传入正确的 app/db 引用.
|
|
8
|
+
*/
|
|
2
9
|
export declare class AuthMainAppService {
|
|
3
|
-
db
|
|
4
|
-
app
|
|
5
|
-
private logger;
|
|
10
|
+
private db;
|
|
11
|
+
private app;
|
|
6
12
|
private selfSignIn;
|
|
7
13
|
private authMainApp;
|
|
14
|
+
constructor(app: Application);
|
|
8
15
|
load(): Promise<void>;
|
|
9
16
|
checkInstall(): Promise<void>;
|
|
10
17
|
addMiddleWare(): void;
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
|
|
7
|
-
var __typeError = (msg) => {
|
|
8
|
-
throw TypeError(msg);
|
|
9
|
-
};
|
|
10
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
12
5
|
var __export = (target, all) => {
|
|
13
6
|
for (var name in all)
|
|
14
7
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -22,63 +15,19 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
22
15
|
return to;
|
|
23
16
|
};
|
|
24
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
-
var __decoratorStart = (base) => [, , , __create((base == null ? void 0 : base[__knownSymbol("metadata")]) ?? null)];
|
|
26
|
-
var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
|
|
27
|
-
var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
|
|
28
|
-
var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) });
|
|
29
|
-
var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
|
|
30
|
-
var __runInitializers = (array, flags, self, value) => {
|
|
31
|
-
for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
|
|
32
|
-
return value;
|
|
33
|
-
};
|
|
34
|
-
var __decorateElement = (array, flags, name, decorators, target, extra) => {
|
|
35
|
-
var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
|
|
36
|
-
var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];
|
|
37
|
-
var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
|
|
38
|
-
var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name]() {
|
|
39
|
-
return __privateGet(this, extra);
|
|
40
|
-
}, set [name](x) {
|
|
41
|
-
return __privateSet(this, extra, x);
|
|
42
|
-
} }, name));
|
|
43
|
-
k ? p && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name);
|
|
44
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
45
|
-
ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
|
|
46
|
-
if (k) {
|
|
47
|
-
ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x };
|
|
48
|
-
if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
|
|
49
|
-
if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
|
|
50
|
-
}
|
|
51
|
-
it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;
|
|
52
|
-
if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);
|
|
53
|
-
else if (typeof it !== "object" || it === null) __typeError("Object expected");
|
|
54
|
-
else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
|
|
55
|
-
}
|
|
56
|
-
return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
|
|
57
|
-
};
|
|
58
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
59
|
-
var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
|
|
60
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
61
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
62
|
-
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
63
18
|
var authMainAppService_exports = {};
|
|
64
19
|
__export(authMainAppService_exports, {
|
|
65
20
|
AuthMainAppService: () => AuthMainAppService
|
|
66
21
|
});
|
|
67
22
|
module.exports = __toCommonJS(authMainAppService_exports);
|
|
68
|
-
var import_server = require("@tego/server");
|
|
69
23
|
var import_constants = require("../../constants");
|
|
70
|
-
var _logger_dec, _app_dec, _db_dec, _AuthMainAppService_decorators, _init;
|
|
71
|
-
_AuthMainAppService_decorators = [(0, import_server.Service)()], _db_dec = [(0, import_server.Db)()], _app_dec = [(0, import_server.App)()], _logger_dec = [(0, import_server.InjectLog)()];
|
|
72
24
|
class AuthMainAppService {
|
|
73
|
-
constructor() {
|
|
74
|
-
this.db = __runInitializers(_init, 8, this), __runInitializers(_init, 11, this);
|
|
75
|
-
this.app = __runInitializers(_init, 12, this), __runInitializers(_init, 15, this);
|
|
76
|
-
this.logger = __runInitializers(_init, 16, this), __runInitializers(_init, 19, this);
|
|
25
|
+
constructor(app) {
|
|
77
26
|
this.selfSignIn = true;
|
|
78
|
-
//子应用本身登录
|
|
79
27
|
this.authMainApp = true;
|
|
28
|
+
this.app = app;
|
|
29
|
+
this.db = app.db;
|
|
80
30
|
}
|
|
81
|
-
//通过主应用登录
|
|
82
31
|
async load() {
|
|
83
32
|
this.addMiddleWare();
|
|
84
33
|
this.app.on("afterStart", async () => {
|
|
@@ -122,27 +71,25 @@ class AuthMainAppService {
|
|
|
122
71
|
ctx.body = [];
|
|
123
72
|
}
|
|
124
73
|
if (this.authMainApp) {
|
|
125
|
-
ctx.body.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
74
|
+
const alreadyHasMainApp = Array.isArray(ctx.body) && ctx.body.some((item) => item.authType === "mainApp");
|
|
75
|
+
if (!alreadyHasMainApp) {
|
|
76
|
+
ctx.body.unshift({
|
|
77
|
+
name: ctx.t("Main app signIn", { ns: import_constants.NAMESPACE }),
|
|
78
|
+
authType: "mainApp",
|
|
79
|
+
authTypeTitle: "main app"
|
|
80
|
+
});
|
|
81
|
+
}
|
|
130
82
|
}
|
|
131
83
|
}
|
|
132
84
|
},
|
|
133
85
|
{
|
|
134
86
|
tag: "forbidSignIn",
|
|
135
|
-
after: "acl"
|
|
87
|
+
after: "acl",
|
|
88
|
+
unique: true
|
|
136
89
|
}
|
|
137
90
|
);
|
|
138
91
|
}
|
|
139
92
|
}
|
|
140
|
-
_init = __decoratorStart(null);
|
|
141
|
-
__decorateElement(_init, 5, "db", _db_dec, AuthMainAppService);
|
|
142
|
-
__decorateElement(_init, 5, "app", _app_dec, AuthMainAppService);
|
|
143
|
-
__decorateElement(_init, 5, "logger", _logger_dec, AuthMainAppService);
|
|
144
|
-
AuthMainAppService = __decorateElement(_init, 0, "AuthMainAppService", _AuthMainAppService_decorators, AuthMainAppService);
|
|
145
|
-
__runInitializers(_init, 1, AuthMainAppService);
|
|
146
93
|
// Annotate the CommonJS export names for ESM import in node:
|
|
147
94
|
0 && (module.exports = {
|
|
148
95
|
AuthMainAppService
|
package/package.json
CHANGED
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/plugin-auth-main-app",
|
|
3
3
|
"displayName": "Single Sign-On on multi app (SSO)",
|
|
4
|
-
"version": "1.6.
|
|
4
|
+
"version": "1.6.8-alpha.1",
|
|
5
5
|
"description": "Users log in via the main application; sub-applications can disable their standalone login.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"Authentication"
|
|
8
8
|
],
|
|
9
|
+
"homepage": "https://github.com/tegojs/tego-standard#readme",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/tegojs/tego-standard/issues"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/tegojs/tego-standard",
|
|
16
|
+
"directory": "packages/plugin-auth-main-app"
|
|
17
|
+
},
|
|
9
18
|
"main": "dist/server/index.js",
|
|
10
19
|
"devDependencies": {
|
|
11
|
-
"@tachybase/schema": "1.6.
|
|
12
|
-
"@tachybase/test": "1.6.
|
|
13
|
-
"@tego/client": "1.6.
|
|
14
|
-
"@tego/server": "1.6.
|
|
20
|
+
"@tachybase/schema": "1.6.3",
|
|
21
|
+
"@tachybase/test": "1.6.3",
|
|
22
|
+
"@tego/client": "1.6.3",
|
|
23
|
+
"@tego/server": "1.6.3",
|
|
15
24
|
"antd": "5.22.5",
|
|
16
|
-
"@tachybase/
|
|
17
|
-
"@tachybase/
|
|
25
|
+
"@tachybase/client": "1.6.8-alpha.1",
|
|
26
|
+
"@tachybase/module-auth": "1.6.8-alpha.1"
|
|
18
27
|
},
|
|
19
28
|
"description.zh-CN": "通过主应用登录子应用,子应用可关闭登录",
|
|
20
29
|
"displayName.zh-CN": "多应用统一登录"
|