mirror of
https://github.com/whyour/qinglong.git
synced 2026-12-01 01:39:52 +08:00
fix(security): restrict task environment controls and app scopes
This commit is contained in:
1 parent
a5f22f8d44
commit
b0f15241d2
17 files changed
+364
-30
No files matched your search
+2
-2
@@ -48,7 +48,7 @@ The CLI also supports task/subscription CRUD, application and secret management,
|
||||
```sh
|
||||
ql task create --name demo --command 'task demo.js' --schedule '0 0 * * *' --json
|
||||
ql subscription create --type public-repo --url https://example.com/repo.git --alias demo --schedule-type crontab --schedule '0 0 * * *' --json
|
||||
ql app create --name agent --scopes crons,subscriptions --show-secrets --json
|
||||
ql app create --name agent --scopes crons,subscriptions,envs:write --show-secrets --json
|
||||
ql env create --data @envs.json --json
|
||||
ql api request PUT /open/crons/run --data '[12,13]' --json
|
||||
```
|
||||
@@ -68,7 +68,7 @@ Protected requests use `Authorization: Bearer <token>`. Two credential sources a
|
||||
|
||||
### Application login
|
||||
|
||||
Create a dedicated panel application with the required scopes, such as crons, subscriptions or envs. `login` and `auth login` are equivalent. Interactive login hides the Client Secret; secret command-line arguments are not supported.
|
||||
Create a dedicated panel application with the required scopes, such as crons or subscriptions. `envs` only permits reading environment variables. Creating, changing, importing or enabling them requires `envs:write`, which can affect task execution. `configs` only permits reading configuration files. `login` and `auth login` are equivalent. Interactive login hides the Client Secret; secret command-line arguments are not supported.
|
||||
|
||||
```sh
|
||||
ql login --url https://ql.example.com
|
||||
|
||||
+2
-2
@@ -48,7 +48,7 @@ ql auth logout --json
|
||||
```sh
|
||||
ql task create --name demo --command 'task demo.js' --schedule '0 0 * * *' --json
|
||||
ql subscription create --type public-repo --url https://example.com/repo.git --alias demo --schedule-type crontab --schedule '0 0 * * *' --json
|
||||
ql app create --name agent --scopes crons,subscriptions --show-secrets --json
|
||||
ql app create --name agent --scopes crons,subscriptions,envs:write --show-secrets --json
|
||||
ql env create --data @envs.json --json
|
||||
ql api request PUT /open/crons/run --data '[12,13]' --json
|
||||
```
|
||||
@@ -68,7 +68,7 @@ ql api request PUT /open/crons/run --data '[12,13]' --json
|
||||
|
||||
### 应用凭据登录
|
||||
|
||||
在面板创建专用应用,按需授予 crons、subscriptions、envs 等权限。`login` 与 `auth login` 等价;交互输入 Client ID 和不回显的 Client Secret,密钥不支持命令行参数。
|
||||
在面板创建专用应用,按需授予 crons、subscriptions 等权限。`envs` 仅允许读取环境变量;创建、修改、导入或启用环境变量需要 `envs:write`,该权限可影响任务执行。`configs` 仅允许读取配置文件。`login` 与 `auth login` 等价;交互输入 Client ID 和不回显的 Client Secret,密钥不支持命令行参数。
|
||||
|
||||
```sh
|
||||
ql login --url https://ql.example.com
|
||||
|
||||
@@ -6,12 +6,14 @@ The catalogue covers 146 active routes in the current backend. `ql api routes --
|
||||
|
||||
## 认证与权限 / Authentication and permissions
|
||||
|
||||
常规使用 `ql login` 的应用凭据。scope 是 /open 后首个路径段:crons、subscriptions、envs、configs、scripts、logs、dependencies、system、dashboard 等。应用管理需要 apps;user、health、update 等路由同样接受服务端权限校验。面板 UI 当前没有列出全部这些 scope,不能把路由存在理解成现有应用已获授权。
|
||||
常规使用 `ql login` 的应用凭据。scope 通常对应 /open 后首个路径段:crons、subscriptions、envs、configs、scripts、logs、dependencies、system、dashboard 等。`envs` 仅允许读取;写入须授予 `envs:write`,它同时包含读取能力且可影响任务执行。`configs` 对应用令牌仅允许读取,保存配置需要面板会话。外部应用的 `system` scope 仅允许读取系统状态和发送通知。应用管理需要 apps;user、health、update 等路由同样接受服务端权限校验。面板 UI 当前没有列出全部这些 scope,不能把路由存在理解成现有应用已获授权。
|
||||
|
||||
认证步骤、环境变量优先级、应用登录、面板会话与双因素验证、退出行为,统一见 [认证参考](panel.md#authentication)。应用管理可用 apps 权限的应用或授权面板会话;QL_URL/QL_ACCESS_TOKEN 不保存、不刷新,不自动退回应用配置。
|
||||
|
||||
See the [authentication reference](panel.md#authentication) for application login, direct-token precedence, owner sessions/2FA and logout. App management accepts apps-scoped credentials or an authorized owner session. Direct tokens are not saved/refreshed and never fall back to application configuration.
|
||||
|
||||
The `envs` scope is read only. Grant `envs:write` for environment changes; it also permits reads and can affect task execution. Application tokens with `configs` may read configuration, while saving requires a panel session. External `system` applications may only read system status and send notifications.
|
||||
|
||||
`auth status --scope <scope>` tests a representative read; update has no read endpoint and is not offered by status. This does not prove permission for every write. `app list/create/update/reset-secret` 默认隐藏 client_secret/tokens;只有明确需要凭据时才加 --show-secrets,并避免把输出记录到共享日志。其他资源/通用请求可能含环境值、配置、脚本、订阅凭据和会话,按敏感数据处理。
|
||||
|
||||
App results omit client_secret/tokens unless --show-secrets is explicit. Other resources and raw responses may contain sensitive values. Handle them accordingly.
|
||||
@@ -40,7 +42,7 @@ ql subscription create --type public-repo --url https://example.com/repo.git --a
|
||||
ql subscription update 5 --data @subscription.json --json
|
||||
ql subscription delete 5 --query '{"force":true}' --json
|
||||
ql app create --name agent --scopes crons,subscriptions --show-secrets --json
|
||||
ql app update 3 --name agent --scopes crons,subscriptions,envs --json
|
||||
ql app update 3 --name agent --scopes crons,subscriptions,envs:write --json
|
||||
ql app reset-secret 3 --show-secrets --json
|
||||
ql env create --data @envs.json --json
|
||||
ql env update 8 --data '{"name":"EXAMPLE","value":"value"}' --json
|
||||
@@ -49,6 +51,7 @@ ql script get --query '{"file":"demo.js","path":""}' --json
|
||||
ql script history-list --query '{"filename":"demo.js","path":""}' --json
|
||||
ql script history-detail --query '{"filename":"demo.js","path":"","id":"VERSION_UUID"}' --json
|
||||
ql script history-restore --data '{"filename":"demo.js","path":"","id":"VERSION_UUID","expectedHash":"CURRENT_SHA256"}' --json
|
||||
# Requires a panel session token.
|
||||
ql config save --data '{"name":"example.sh","content":"# example"}' --json
|
||||
ql config get --query '{"path":"example.sh"}' --json
|
||||
ql log download --data '{"filename":"example.log","path":"example"}' --output ./example.log --json
|
||||
|
||||
@@ -28,11 +28,11 @@ const fs = require('node:fs/promises');
|
||||
assert.equal(result.status, 0, args.slice(0, 2).join(' ') + ': ' + result.stderr);
|
||||
return JSON.parse(result.stdout).data;
|
||||
};
|
||||
const app = cli(['app', 'create', '--name', 'cli-fixture', '--scopes', 'crons,subscriptions,envs,configs,scripts,logs,dependencies,system,dashboard,apps', '--show-secrets'], true);
|
||||
const app = cli(['app', 'create', '--name', 'cli-fixture', '--scopes', 'crons,subscriptions,envs:write,configs,scripts,logs,dependencies,system,dashboard,apps', '--show-secrets'], true);
|
||||
assert.ok(app.client_id && app.client_secret);
|
||||
cli(['login', '--url', url], false, { QL_CLIENT_ID: app.client_id, QL_CLIENT_SECRET: app.client_secret });
|
||||
cli(['auth', 'status', '--scope', 'apps']);
|
||||
cli(['app', 'update', String(app.id), '--name', 'cli-updated', '--scopes', 'crons,subscriptions,envs,configs,scripts,logs,dependencies,system,dashboard,apps']);
|
||||
cli(['app', 'update', String(app.id), '--name', 'cli-updated', '--scopes', 'crons,subscriptions,envs:write,configs,scripts,logs,dependencies,system,dashboard,apps']);
|
||||
assert.ok(cli(['app', 'list']).every(item => !('client_secret' in item) && !('tokens' in item)));
|
||||
const task = cli(['task', 'create', '--name', 'cli-task', '--command', 'echo OPENAPI_FIXTURE', '--schedule', '0 0 * * *']);
|
||||
cli(['task', 'update', String(task.id), '--name', 'cli-task-updated', '--command', 'echo OPENAPI_UPDATED', '--schedule', '0 1 * * *']);
|
||||
@@ -48,7 +48,7 @@ const fs = require('node:fs/promises');
|
||||
cli(['env', 'delete', String(env.id)]);
|
||||
cli(['script', 'create', '--data', '{"filename":"cli-openapi.js","content":"console.log(1)","path":""}']);
|
||||
assert.equal(cli(['script', 'get', '--query', '{"file":"cli-openapi.js"}']), 'console.log(1)');
|
||||
cli(['config', 'save', '--data', '{"name":"cli-openapi.sh","content":"# fixture"}']);
|
||||
cli(['config', 'save', '--data', '{"name":"cli-openapi.sh","content":"# fixture"}'], true);
|
||||
assert.equal(cli(['config', 'get', '--query', '{"path":"cli-openapi.sh"}']), '# fixture');
|
||||
cli(['log', 'list']); cli(['dependency', 'list']);
|
||||
cli(['task', 'delete', String(task.id)]); cli(['subscription', 'delete', String(sub.id)]);
|
||||
|
||||
Reference in new issue
Block a user