mirror of
https://github.com/whyour/qinglong.git
synced 2026-12-01 01:39:52 +08:00
fix(security): preserve legacy scopes and add read-only access
This commit is contained in:
1 parent
b0f15241d2
commit
be8721204b
13 files changed
+141
-43
No files matched your search
@@ -81,6 +81,11 @@ async function fixture(t) {
|
||||
code: 200,
|
||||
data: { data: [{ id: 12, name: 'example' }], total: 1 },
|
||||
});
|
||||
else if (
|
||||
['/panel/open/envs', '/panel/open/configs/files', '/panel/open/scripts']
|
||||
.includes(url.pathname)
|
||||
)
|
||||
json({ code: 200, data: [] });
|
||||
else if (
|
||||
['/panel/open/crons/run', '/panel/open/crons/stop'].includes(
|
||||
url.pathname,
|
||||
@@ -155,6 +160,16 @@ test('compiled entry: login aliases, private storage, status, refresh and local
|
||||
assert.equal(JSON.parse(status.out).data.scopeChecked, 'crons');
|
||||
assert.doesNotMatch(status.out, /test-secret|test-token/);
|
||||
assert.equal(f.requests.at(-1).url.pathname, '/panel/open/crons');
|
||||
for (const [scope, pathname] of [
|
||||
['envs:read', '/panel/open/envs'],
|
||||
['configs:read', '/panel/open/configs/files'],
|
||||
['scripts:read', '/panel/open/scripts'],
|
||||
]) {
|
||||
const checked = await f.invoke(['auth', 'status', '--scope', scope, '--json']);
|
||||
assert.equal(checked.code, 0, checked.err);
|
||||
assert.equal(JSON.parse(checked.out).data.scopeChecked, scope);
|
||||
assert.equal(f.requests.at(-1).url.pathname, pathname);
|
||||
}
|
||||
const config = JSON.parse(fs.readFileSync(f.file));
|
||||
config.expiration = 1;
|
||||
fs.writeFileSync(f.file, JSON.stringify(config));
|
||||
|
||||
Reference in new issue
Block a user