@kevisual/cli 0.0.86 → 0.0.87
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/assistant-server.js +13 -11
- package/dist/envision.js +11294 -11291
- package/package.json +3 -5
- package/readme.md +4 -0
package/dist/assistant-server.js
CHANGED
|
@@ -102196,7 +102196,7 @@ var authFilter = async (req, res) => {
|
|
|
102196
102196
|
const share = auth.share || "protected";
|
|
102197
102197
|
const noAdmin = !auth.username;
|
|
102198
102198
|
if (noAdmin)
|
|
102199
|
-
return
|
|
102199
|
+
return { code: 500, message: "没有管理员" };
|
|
102200
102200
|
const admin = auth.username;
|
|
102201
102201
|
const admins = auth.admin || [];
|
|
102202
102202
|
if (admin) {
|
|
@@ -102205,39 +102205,40 @@ var authFilter = async (req, res) => {
|
|
|
102205
102205
|
const url3 = new URL(req.url, "http://localhost");
|
|
102206
102206
|
const pathname = decodeURIComponent(url3.pathname);
|
|
102207
102207
|
if (pathname === "/" || pathname === "/favicon.ico") {
|
|
102208
|
-
return
|
|
102208
|
+
return { code: 200, message: "允许访问根路径" };
|
|
102209
102209
|
}
|
|
102210
102210
|
if (pathname.startsWith("/root/home") || pathname === "/root/cli") {
|
|
102211
|
-
return
|
|
102211
|
+
return { code: 200, message: "允许访问首页" };
|
|
102212
102212
|
}
|
|
102213
|
-
const openApiPaths = ["/api", "/v1", "/client", "/serve"];
|
|
102213
|
+
const openApiPaths = ["/api", "/v1", "/client", "/serve", "/proxy"];
|
|
102214
102214
|
for (const openPath of openApiPaths) {
|
|
102215
102215
|
if (pathname.startsWith(openPath)) {
|
|
102216
|
-
return
|
|
102216
|
+
return { code: 200, message: "允许访问API" };
|
|
102217
102217
|
}
|
|
102218
102218
|
}
|
|
102219
102219
|
if (share === "public") {
|
|
102220
|
-
return
|
|
102220
|
+
return { code: 200, message: "公开模式允许访问" };
|
|
102221
102221
|
}
|
|
102222
102222
|
const { token } = await getToken(req);
|
|
102223
102223
|
if (!token) {
|
|
102224
102224
|
res.writeHead(302, { Location: `/root/home/` });
|
|
102225
102225
|
res.end();
|
|
102226
|
-
return
|
|
102226
|
+
return { code: 500, message: "未登录" };
|
|
102227
102227
|
}
|
|
102228
102228
|
const tokenUser = await getTokenUserCache(token);
|
|
102229
|
+
console.log("authFilter tokenUser", tokenUser, token);
|
|
102229
102230
|
if (share === "protected" && tokenUser?.code === 200) {
|
|
102230
|
-
return
|
|
102231
|
+
return { code: 200, message: "受保护模式已登录允许访问" };
|
|
102231
102232
|
}
|
|
102232
102233
|
if (share === "private") {
|
|
102233
102234
|
if (tokenUser?.code === 200) {
|
|
102234
102235
|
const username = tokenUser?.data?.username;
|
|
102235
102236
|
if (admins.includes(username)) {
|
|
102236
|
-
return
|
|
102237
|
+
return { code: 200, message: "私有模式管理员允许访问" };
|
|
102237
102238
|
}
|
|
102238
102239
|
}
|
|
102239
102240
|
}
|
|
102240
|
-
return
|
|
102241
|
+
return { code: 500, message: "没有权限访问" };
|
|
102241
102242
|
};
|
|
102242
102243
|
var proxyRoute = async (req, res) => {
|
|
102243
102244
|
const _assistantConfig = assistantConfig2.getCacheAssistantConfig();
|
|
@@ -102333,7 +102334,8 @@ var proxyRoute = async (req, res) => {
|
|
|
102333
102334
|
});
|
|
102334
102335
|
}
|
|
102335
102336
|
const filter2 = await authFilter(req, res);
|
|
102336
|
-
if (filter2) {
|
|
102337
|
+
if (filter2.code !== 200) {
|
|
102338
|
+
console.log("auth filter deny", filter2);
|
|
102337
102339
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
102338
102340
|
return res.end(renderNoAuthAndLogin("Not Authorized Proxy"));
|
|
102339
102341
|
}
|