feat: update README with installation command and add debug logs in deploy command
- Added installation command for the CLI tool in README. - Enhanced deploy command with debug logging for upload results and query app version. - Integrated useKey for fetching KEVISUAL_TOKEN in get-config module. - Added debug logging in queryAppVersion for better traceability. - Updated temp.md with new dependency and example command for deployment.
This commit is contained in:
@@ -31,7 +31,7 @@ const authFilter = async (req: http.IncomingMessage, res: http.ServerResponse) =
|
||||
const auth = _assistantConfig?.auth || {};
|
||||
const share = auth.share || 'protected';
|
||||
const noAdmin = !auth.username;
|
||||
if (noAdmin) return false;
|
||||
if (noAdmin) return { code: 500, message: '没有管理员' };
|
||||
const admin = auth.username;
|
||||
const admins = auth.admin || [];
|
||||
if (admin) {
|
||||
@@ -41,42 +41,43 @@ const authFilter = async (req: http.IncomingMessage, res: http.ServerResponse) =
|
||||
const pathname = decodeURIComponent(url.pathname);
|
||||
// 放开 /
|
||||
if (pathname === '/' || pathname === '/favicon.ico') {
|
||||
return false;
|
||||
return { code: 200, message: '允许访问根路径' };
|
||||
}
|
||||
// 放开首页
|
||||
if (pathname.startsWith('/root/home') || pathname === '/root/cli') {
|
||||
return false;
|
||||
if (pathname.startsWith('/root/home') || pathname === '/root/cli/docs/') {
|
||||
return { code: 200, message: '允许访问首页' };
|
||||
}
|
||||
// 放开api, 以 /api, /v1, /client, /serve 开头的请求
|
||||
const openApiPaths = ['/api', '/v1', '/client', '/serve'];
|
||||
const openApiPaths = ['/api', '/v1', '/client', '/serve', '/proxy'];
|
||||
for (const openPath of openApiPaths) {
|
||||
if (pathname.startsWith(openPath)) {
|
||||
return false;
|
||||
return { code: 200, message: '允许访问API' };
|
||||
}
|
||||
}
|
||||
if (share === 'public') {
|
||||
return false;
|
||||
return { code: 200, message: '公开模式允许访问' };
|
||||
}
|
||||
const { token } = await getToken(req)
|
||||
if (!token) {
|
||||
// no token 转到登录页面
|
||||
res.writeHead(302, { Location: `/root/home/` });
|
||||
res.end();
|
||||
return false;
|
||||
return { code: 500, message: '未登录' };
|
||||
}
|
||||
const tokenUser = await getTokenUserCache(token);
|
||||
console.log('authFilter tokenUser', tokenUser, token);
|
||||
if (share === 'protected' && tokenUser?.code === 200) {
|
||||
return false;
|
||||
return { code: 200, message: '受保护模式已登录允许访问' };
|
||||
}
|
||||
if (share === 'private') {
|
||||
if (tokenUser?.code === 200) {
|
||||
const username = tokenUser?.data?.username;
|
||||
if (admins.includes(username)) {
|
||||
return false;
|
||||
return { code: 200, message: '私有模式管理员允许访问' };
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return { code: 500, message: '没有权限访问' };
|
||||
}
|
||||
export const proxyRoute = async (req: http.IncomingMessage, res: http.ServerResponse) => {
|
||||
const _assistantConfig = assistantConfig.getCacheAssistantConfig();
|
||||
@@ -180,7 +181,8 @@ export const proxyRoute = async (req: http.IncomingMessage, res: http.ServerResp
|
||||
});
|
||||
}
|
||||
const filter = await authFilter(req, res);
|
||||
if (filter) {
|
||||
if (filter.code !== 200) {
|
||||
console.log('auth filter deny', filter);
|
||||
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
|
||||
return res.end(renderNoAuthAndLogin('Not Authorized Proxy'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user