@adonis-agora/config 0.0.0-stage → 0.1.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/CHANGELOG.md +52 -0
- package/LICENSE +21 -0
- package/README.md +28 -2
- package/dist/assets/spa/assets/index-CAHRPNZj.js +50 -0
- package/dist/assets/spa/assets/index-CAHRPNZj.js.map +1 -0
- package/dist/assets/spa/assets/index-Cvjcgc6i.css +1 -0
- package/dist/assets/spa/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
- package/dist/assets/spa/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- package/dist/assets/spa/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
- package/dist/assets/spa/assets/jetbrains-mono-latin-500-normal-CJOVTJB7.woff +0 -0
- package/dist/assets/spa/assets/jetbrains-mono-latin-600-normal-BfsvjouI.woff +0 -0
- package/dist/assets/spa/assets/jetbrains-mono-latin-600-normal-C8RAYTDA.woff2 +0 -0
- package/dist/assets/spa/assets/sora-latin-400-normal-CRt88UEn.woff2 +0 -0
- package/dist/assets/spa/assets/sora-latin-400-normal-OW7qkl5a.woff +0 -0
- package/dist/assets/spa/assets/sora-latin-500-normal-01eiPEn0.woff2 +0 -0
- package/dist/assets/spa/assets/sora-latin-500-normal-w58xtEt9.woff +0 -0
- package/dist/assets/spa/assets/sora-latin-600-normal-1_7fyUAY.woff +0 -0
- package/dist/assets/spa/assets/sora-latin-600-normal-Cdg4DaK0.woff2 +0 -0
- package/dist/assets/spa/assets/sora-latin-700-normal-9waGdLWo.woff2 +0 -0
- package/dist/assets/spa/assets/sora-latin-700-normal-BKPfQAnC.woff +0 -0
- package/dist/assets/spa/index.html +20 -0
- package/dist/commands/agora_doctor.d.ts +23 -0
- package/dist/commands/agora_doctor.d.ts.map +1 -0
- package/dist/commands/agora_doctor.js +120 -0
- package/dist/commands/agora_doctor.js.map +1 -0
- package/dist/commands/config.d.ts +100 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +447 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/crypto.d.ts +17 -0
- package/dist/commands/crypto.d.ts.map +1 -0
- package/dist/commands/crypto.js +89 -0
- package/dist/commands/crypto.js.map +1 -0
- package/dist/commands/main.d.ts +16 -0
- package/dist/commands/main.d.ts.map +1 -0
- package/dist/commands/main.js +31 -0
- package/dist/commands/main.js.map +1 -0
- package/dist/commands/pull.d.ts +36 -0
- package/dist/commands/pull.d.ts.map +1 -0
- package/dist/commands/pull.js +262 -0
- package/dist/commands/pull.js.map +1 -0
- package/dist/commands/shared.d.ts +33 -0
- package/dist/commands/shared.d.ts.map +1 -0
- package/dist/commands/shared.js +134 -0
- package/dist/commands/shared.js.map +1 -0
- package/dist/commands/tenant_key.d.ts +22 -0
- package/dist/commands/tenant_key.d.ts.map +1 -0
- package/dist/commands/tenant_key.js +141 -0
- package/dist/commands/tenant_key.js.map +1 -0
- package/dist/configure.d.ts +13 -0
- package/dist/configure.d.ts.map +1 -0
- package/dist/configure.js +33 -0
- package/dist/configure.js.map +1 -0
- package/dist/providers/config_provider.d.ts +31 -0
- package/dist/providers/config_provider.d.ts.map +1 -0
- package/dist/providers/config_provider.js +460 -0
- package/dist/providers/config_provider.js.map +1 -0
- package/dist/services/main.d.ts +39 -0
- package/dist/services/main.d.ts.map +1 -0
- package/dist/services/main.js +67 -0
- package/dist/services/main.js.map +1 -0
- package/dist/src/admin.d.ts +110 -0
- package/dist/src/admin.d.ts.map +1 -0
- package/dist/src/admin.js +326 -0
- package/dist/src/admin.js.map +1 -0
- package/dist/src/bootstrap.d.ts +35 -0
- package/dist/src/bootstrap.d.ts.map +1 -0
- package/dist/src/bootstrap.js +35 -0
- package/dist/src/bootstrap.js.map +1 -0
- package/dist/src/crypto/secrets.d.ts +67 -0
- package/dist/src/crypto/secrets.d.ts.map +1 -0
- package/dist/src/crypto/secrets.js +100 -0
- package/dist/src/crypto/secrets.js.map +1 -0
- package/dist/src/crypto/tenant_keys.d.ts +49 -0
- package/dist/src/crypto/tenant_keys.d.ts.map +1 -0
- package/dist/src/crypto/tenant_keys.js +134 -0
- package/dist/src/crypto/tenant_keys.js.map +1 -0
- package/dist/src/crypto-kit/asymmetric.d.ts +61 -0
- package/dist/src/crypto-kit/asymmetric.d.ts.map +1 -0
- package/dist/src/crypto-kit/asymmetric.js +201 -0
- package/dist/src/crypto-kit/asymmetric.js.map +1 -0
- package/dist/src/crypto-kit/index.d.ts +5 -0
- package/dist/src/crypto-kit/index.d.ts.map +1 -0
- package/dist/src/crypto-kit/index.js +6 -0
- package/dist/src/crypto-kit/index.js.map +1 -0
- package/dist/src/crypto-kit/keyring.d.ts +52 -0
- package/dist/src/crypto-kit/keyring.d.ts.map +1 -0
- package/dist/src/crypto-kit/keyring.js +36 -0
- package/dist/src/crypto-kit/keyring.js.map +1 -0
- package/dist/src/crypto-kit/kms.d.ts +18 -0
- package/dist/src/crypto-kit/kms.d.ts.map +1 -0
- package/dist/src/crypto-kit/kms.js +29 -0
- package/dist/src/crypto-kit/kms.js.map +1 -0
- package/dist/src/crypto-kit/seal.d.ts +39 -0
- package/dist/src/crypto-kit/seal.d.ts.map +1 -0
- package/dist/src/crypto-kit/seal.js +159 -0
- package/dist/src/crypto-kit/seal.js.map +1 -0
- package/dist/src/dashboard/access_denied_page.d.ts +100 -0
- package/dist/src/dashboard/access_denied_page.d.ts.map +1 -0
- package/dist/src/dashboard/access_denied_page.js +262 -0
- package/dist/src/dashboard/access_denied_page.js.map +1 -0
- package/dist/src/dashboard/actor.d.ts +14 -0
- package/dist/src/dashboard/actor.d.ts.map +1 -0
- package/dist/src/dashboard/actor.js +60 -0
- package/dist/src/dashboard/actor.js.map +1 -0
- package/dist/src/dashboard/console.d.ts +71 -0
- package/dist/src/dashboard/console.d.ts.map +1 -0
- package/dist/src/dashboard/console.js +456 -0
- package/dist/src/dashboard/console.js.map +1 -0
- package/dist/src/dashboard/console_authorize.d.ts +91 -0
- package/dist/src/dashboard/console_authorize.d.ts.map +1 -0
- package/dist/src/dashboard/console_authorize.js +154 -0
- package/dist/src/dashboard/console_authorize.js.map +1 -0
- package/dist/src/dashboard/console_shell.d.ts +49 -0
- package/dist/src/dashboard/console_shell.d.ts.map +1 -0
- package/dist/src/dashboard/console_shell.js +183 -0
- package/dist/src/dashboard/console_shell.js.map +1 -0
- package/dist/src/dashboard/console_switcher.d.ts +92 -0
- package/dist/src/dashboard/console_switcher.d.ts.map +1 -0
- package/dist/src/dashboard/console_switcher.js +188 -0
- package/dist/src/dashboard/console_switcher.js.map +1 -0
- package/dist/src/dashboard/define_config.d.ts +54 -0
- package/dist/src/dashboard/define_config.d.ts.map +1 -0
- package/dist/src/dashboard/define_config.js +29 -0
- package/dist/src/dashboard/define_config.js.map +1 -0
- package/dist/src/dashboard/spa.d.ts +42 -0
- package/dist/src/dashboard/spa.d.ts.map +1 -0
- package/dist/src/dashboard/spa.js +51 -0
- package/dist/src/dashboard/spa.js.map +1 -0
- package/dist/src/define_config.d.ts +162 -0
- package/dist/src/define_config.d.ts.map +1 -0
- package/dist/src/define_config.js +53 -0
- package/dist/src/define_config.js.map +1 -0
- package/dist/src/dev_tools.d.ts +74 -0
- package/dist/src/dev_tools.d.ts.map +1 -0
- package/dist/src/dev_tools.js +414 -0
- package/dist/src/dev_tools.js.map +1 -0
- package/dist/src/diagnostics.d.ts +87 -0
- package/dist/src/diagnostics.d.ts.map +1 -0
- package/dist/src/diagnostics.js +35 -0
- package/dist/src/diagnostics.js.map +1 -0
- package/dist/src/doctor/agora_doctor.d.ts +116 -0
- package/dist/src/doctor/agora_doctor.d.ts.map +1 -0
- package/dist/src/doctor/agora_doctor.js +685 -0
- package/dist/src/doctor/agora_doctor.js.map +1 -0
- package/dist/src/doctor/checks.d.ts +8 -0
- package/dist/src/doctor/checks.d.ts.map +1 -0
- package/dist/src/doctor/checks.js +352 -0
- package/dist/src/doctor/checks.js.map +1 -0
- package/dist/src/doctor/index.d.ts +3 -0
- package/dist/src/doctor/index.d.ts.map +1 -0
- package/dist/src/doctor/index.js +3 -0
- package/dist/src/doctor/index.js.map +1 -0
- package/dist/src/env_file.d.ts +24 -0
- package/dist/src/env_file.d.ts.map +1 -0
- package/dist/src/env_file.js +74 -0
- package/dist/src/env_file.js.map +1 -0
- package/dist/src/http/control_plane.d.ts +93 -0
- package/dist/src/http/control_plane.d.ts.map +1 -0
- package/dist/src/http/control_plane.js +406 -0
- package/dist/src/http/control_plane.js.map +1 -0
- package/dist/src/http/list.d.ts +27 -0
- package/dist/src/http/list.d.ts.map +1 -0
- package/dist/src/http/list.js +75 -0
- package/dist/src/http/list.js.map +1 -0
- package/dist/src/index.d.ts +22 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +21 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/runtime.d.ts +31 -0
- package/dist/src/runtime.d.ts.map +1 -0
- package/dist/src/runtime.js +2 -0
- package/dist/src/runtime.js.map +1 -0
- package/dist/src/services/accessor.d.ts +6 -0
- package/dist/src/services/accessor.d.ts.map +1 -0
- package/dist/src/services/accessor.js +15 -0
- package/dist/src/services/accessor.js.map +1 -0
- package/dist/src/sql.d.ts +40 -0
- package/dist/src/sql.d.ts.map +1 -0
- package/dist/src/sql.js +97 -0
- package/dist/src/sql.js.map +1 -0
- package/dist/src/store/lucid_store.d.ts +62 -0
- package/dist/src/store/lucid_store.d.ts.map +1 -0
- package/dist/src/store/lucid_store.js +393 -0
- package/dist/src/store/lucid_store.js.map +1 -0
- package/dist/src/store/memory_store.d.ts +47 -0
- package/dist/src/store/memory_store.d.ts.map +1 -0
- package/dist/src/store/memory_store.js +184 -0
- package/dist/src/store/memory_store.js.map +1 -0
- package/dist/src/store/schema.d.ts +18 -0
- package/dist/src/store/schema.d.ts.map +1 -0
- package/dist/src/store/schema.js +74 -0
- package/dist/src/store/schema.js.map +1 -0
- package/dist/src/store/store.d.ts +160 -0
- package/dist/src/store/store.d.ts.map +1 -0
- package/dist/src/store/store.js +254 -0
- package/dist/src/store/store.js.map +1 -0
- package/dist/src/telescope/dashboard.d.ts +16 -0
- package/dist/src/telescope/dashboard.d.ts.map +1 -0
- package/dist/src/telescope/dashboard.js +129 -0
- package/dist/src/telescope/dashboard.js.map +1 -0
- package/dist/src/telescope/data-providers.d.ts +19 -0
- package/dist/src/telescope/data-providers.d.ts.map +1 -0
- package/dist/src/telescope/data-providers.js +266 -0
- package/dist/src/telescope/data-providers.js.map +1 -0
- package/dist/src/telescope/extension.d.ts +23 -0
- package/dist/src/telescope/extension.d.ts.map +1 -0
- package/dist/src/telescope/extension.js +36 -0
- package/dist/src/telescope/extension.js.map +1 -0
- package/dist/src/telescope/index.d.ts +6 -0
- package/dist/src/telescope/index.d.ts.map +1 -0
- package/dist/src/telescope/index.js +5 -0
- package/dist/src/telescope/index.js.map +1 -0
- package/dist/src/telescope/register.d.ts +17 -0
- package/dist/src/telescope/register.d.ts.map +1 -0
- package/dist/src/telescope/register.js +28 -0
- package/dist/src/telescope/register.js.map +1 -0
- package/dist/src/telescope/telescope-sdk.d.ts +116 -0
- package/dist/src/telescope/telescope-sdk.d.ts.map +1 -0
- package/dist/src/telescope/telescope-sdk.js +8 -0
- package/dist/src/telescope/telescope-sdk.js.map +1 -0
- package/dist/src/testing/index.d.ts +22 -0
- package/dist/src/testing/index.d.ts.map +1 -0
- package/dist/src/testing/index.js +35 -0
- package/dist/src/testing/index.js.map +1 -0
- package/dist/src/topology/tenant_client.d.ts +178 -0
- package/dist/src/topology/tenant_client.d.ts.map +1 -0
- package/dist/src/topology/tenant_client.js +642 -0
- package/dist/src/topology/tenant_client.js.map +1 -0
- package/dist/src/topology/tenant_keyring.d.ts +65 -0
- package/dist/src/topology/tenant_keyring.d.ts.map +1 -0
- package/dist/src/topology/tenant_keyring.js +150 -0
- package/dist/src/topology/tenant_keyring.js.map +1 -0
- package/dist/src/topology/token.d.ts +9 -0
- package/dist/src/topology/token.d.ts.map +1 -0
- package/dist/src/topology/token.js +10 -0
- package/dist/src/topology/token.js.map +1 -0
- package/dist/src/topology/verify.d.ts +79 -0
- package/dist/src/topology/verify.d.ts.map +1 -0
- package/dist/src/topology/verify.js +131 -0
- package/dist/src/topology/verify.js.map +1 -0
- package/dist/stubs/config/config.stub +23 -0
- package/dist/stubs/database/migrations/create_config_tables.stub +31 -0
- package/dist/stubs/main.ts +6 -0
- package/package.json +126 -3
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { basename, join } from 'node:path';
|
|
3
|
+
import { assertConfigKey, DEFAULT_LABEL, toConfigValue, } from '@adonis-agora/config-core';
|
|
4
|
+
import { InvalidColumnFilterError } from '@adonis-agora/filter';
|
|
5
|
+
import { booleanFilter, parseListQuery } from '../http/list.js';
|
|
6
|
+
import { resolveAccessDeniedPage } from './access_denied_page.js';
|
|
7
|
+
import { consoleActor } from './actor.js';
|
|
8
|
+
import { resolveConsoleAuthorize } from './console_authorize.js';
|
|
9
|
+
import { resolveSignOut, resolveViewer } from './console_shell.js';
|
|
10
|
+
import { listVisibleConsoles, otherConsoles, searchConsoles, } from './console_switcher.js';
|
|
11
|
+
import { contentTypeFor, renderIndexHtml } from './spa.js';
|
|
12
|
+
/** This console's id in the `'agora.consoles'` registry. */
|
|
13
|
+
export const CONSOLE_ID = 'config';
|
|
14
|
+
class HttpError extends Error {
|
|
15
|
+
status;
|
|
16
|
+
constructor(status, message) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.status = status;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function bearerOf(ctx) {
|
|
22
|
+
const header = ctx.request.header('authorization');
|
|
23
|
+
return header && /^bearer\s+/i.test(header)
|
|
24
|
+
? header.replace(/^bearer\s+/i, '').trim()
|
|
25
|
+
: undefined;
|
|
26
|
+
}
|
|
27
|
+
/** A console-local decision from the request's bearer token, body-less API calls only. */
|
|
28
|
+
function tokenAuthorize(token) {
|
|
29
|
+
return (ctx) => {
|
|
30
|
+
if (token === undefined || token === '')
|
|
31
|
+
return { allowed: false, status: 403, reason: 'forbidden' };
|
|
32
|
+
const presented = bearerOf(ctx);
|
|
33
|
+
return presented === token
|
|
34
|
+
? { allowed: true }
|
|
35
|
+
: { allowed: false, status: 401, reason: 'unauthenticated' };
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The config console: the SPA plus its JSON API, under `console.path` (default `/_config`).
|
|
40
|
+
*
|
|
41
|
+
* Every read and write goes through {@link ConfigAdmin}, so the console gets the same versioning,
|
|
42
|
+
* masking, reveal audit and actor as the commands and the MCP tools. The gate is the resolved
|
|
43
|
+
* `console.authorize`; a browser denial gets the shared access-denied page, an API denial gets
|
|
44
|
+
* `{ error }` with 401/403.
|
|
45
|
+
*/
|
|
46
|
+
export class ConfigConsole {
|
|
47
|
+
options;
|
|
48
|
+
#authorize;
|
|
49
|
+
#warned = false;
|
|
50
|
+
constructor(options) {
|
|
51
|
+
this.options = options;
|
|
52
|
+
this.#authorize = options.config.authorize
|
|
53
|
+
? resolveConsoleAuthorize(options.config.authorize)
|
|
54
|
+
: async (_ctx) => {
|
|
55
|
+
if (!this.options.inProduction)
|
|
56
|
+
return { allowed: true };
|
|
57
|
+
if (!this.#warned) {
|
|
58
|
+
this.#warned = true;
|
|
59
|
+
this.options.logger.warn('[@adonis-agora/config] the console has no `authorize`: it is open outside production and denies every request in production');
|
|
60
|
+
}
|
|
61
|
+
return { allowed: false, status: 403, reason: 'forbidden' };
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
get path() {
|
|
65
|
+
return this.options.config.path;
|
|
66
|
+
}
|
|
67
|
+
get api() {
|
|
68
|
+
return this.options.config.api;
|
|
69
|
+
}
|
|
70
|
+
get admin() {
|
|
71
|
+
return this.options.admin;
|
|
72
|
+
}
|
|
73
|
+
get config() {
|
|
74
|
+
return this.options.config;
|
|
75
|
+
}
|
|
76
|
+
register(router) {
|
|
77
|
+
const root = this.options.config.path === '' ? '' : this.options.config.path;
|
|
78
|
+
const api = this.options.config.api;
|
|
79
|
+
router.get(root === '' ? '/' : root, (ctx) => this.spa(ctx));
|
|
80
|
+
if (root !== '')
|
|
81
|
+
router.get(`${root}/`, (ctx) => this.spa(ctx));
|
|
82
|
+
router.get(`${root}/assets/:file`, (ctx) => this.asset(ctx));
|
|
83
|
+
router.get(`${api}/meta`, (ctx) => this.#guarded(ctx, 'api', () => this.meta(ctx)));
|
|
84
|
+
router.get(`${api}/entries`, (ctx) => this.#guarded(ctx, 'api', () => this.listEntries(ctx)));
|
|
85
|
+
router.get(`${api}/entries/:key`, (ctx) => this.#guarded(ctx, 'api', () => this.getEntry(ctx)));
|
|
86
|
+
router.put(`${api}/entries/:key`, (ctx) => this.#guarded(ctx, 'api', () => this.setEntry(ctx)));
|
|
87
|
+
router.delete(`${api}/entries/:key`, (ctx) => this.#guarded(ctx, 'api', () => this.unsetEntry(ctx)));
|
|
88
|
+
router.post(`${api}/entries/:key/reveal`, (ctx) => this.#guarded(ctx, 'api', () => this.reveal(ctx)));
|
|
89
|
+
router.get(`${api}/versions`, (ctx) => this.#guarded(ctx, 'api', () => this.listVersions(ctx)));
|
|
90
|
+
router.get(`${api}/versions/:version`, (ctx) => this.#guarded(ctx, 'api', () => this.getVersion(ctx)));
|
|
91
|
+
router.get(`${api}/diff`, (ctx) => this.#guarded(ctx, 'api', () => this.diff(ctx)));
|
|
92
|
+
router.post(`${api}/rollback`, (ctx) => this.#guarded(ctx, 'api', () => this.rollback(ctx)));
|
|
93
|
+
router.get(`${api}/audit`, (ctx) => this.#guarded(ctx, 'api', () => this.audit(ctx)));
|
|
94
|
+
router.get(`${api}/consoles`, (ctx) => this.#guarded(ctx, 'api', () => this.consoles(ctx)));
|
|
95
|
+
router.get(`${api}/consoles/search`, (ctx) => this.#guarded(ctx, 'api', () => this.search(ctx)));
|
|
96
|
+
}
|
|
97
|
+
async #guard(ctx, kind) {
|
|
98
|
+
const decision = await this.#authorize(ctx);
|
|
99
|
+
if (decision.allowed)
|
|
100
|
+
return true;
|
|
101
|
+
if (decision.status === 302) {
|
|
102
|
+
ctx.response.redirect(decision.redirectTo);
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
if (kind === 'api') {
|
|
106
|
+
ctx.response.status(decision.status).json({ error: decision.reason });
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
const html = await resolveAccessDeniedPage({
|
|
110
|
+
status: decision.status,
|
|
111
|
+
reason: decision.reason,
|
|
112
|
+
basePath: this.options.config.path,
|
|
113
|
+
...(this.options.config.loginHref ? { loginHref: this.options.config.loginHref } : {}),
|
|
114
|
+
}, this.options.config.accessDenied, ctx, () => false);
|
|
115
|
+
if (html !== null) {
|
|
116
|
+
ctx.response
|
|
117
|
+
.status(decision.status)
|
|
118
|
+
.header('content-type', 'text/html; charset=utf-8')
|
|
119
|
+
.header('cache-control', 'no-store')
|
|
120
|
+
.send(html);
|
|
121
|
+
}
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
async #guarded(ctx, kind, handler) {
|
|
125
|
+
if (!(await this.#guard(ctx, kind)))
|
|
126
|
+
return;
|
|
127
|
+
try {
|
|
128
|
+
return await handler();
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
return this.#fail(ctx, error);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
#fail(ctx, error) {
|
|
135
|
+
if (error instanceof HttpError) {
|
|
136
|
+
return ctx.response.status(error.status).json({ error: error.message });
|
|
137
|
+
}
|
|
138
|
+
if (error instanceof InvalidColumnFilterError) {
|
|
139
|
+
return ctx.response.status(400).json({ error: error.message });
|
|
140
|
+
}
|
|
141
|
+
if (error instanceof Error && error.message.startsWith('config:')) {
|
|
142
|
+
return ctx.response.status(400).json({ error: error.message });
|
|
143
|
+
}
|
|
144
|
+
this.options.logger.warn(`[@adonis-agora/config] console request failed: ${error.message}`);
|
|
145
|
+
return ctx.response.status(500).json({ error: error.message });
|
|
146
|
+
}
|
|
147
|
+
#body(ctx) {
|
|
148
|
+
const body = ctx.request.body();
|
|
149
|
+
return typeof body === 'object' && body !== null ? body : {};
|
|
150
|
+
}
|
|
151
|
+
#scope(ctx) {
|
|
152
|
+
const query = ctx.request.qs();
|
|
153
|
+
const body = this.#body(ctx);
|
|
154
|
+
const value = (name) => {
|
|
155
|
+
const fromQuery = query[name];
|
|
156
|
+
if (typeof fromQuery === 'string' && fromQuery !== '')
|
|
157
|
+
return fromQuery;
|
|
158
|
+
const fromBody = body[name];
|
|
159
|
+
if (typeof fromBody === 'string' && fromBody !== '')
|
|
160
|
+
return fromBody;
|
|
161
|
+
return undefined;
|
|
162
|
+
};
|
|
163
|
+
const app = value('app');
|
|
164
|
+
if (!app)
|
|
165
|
+
throw new HttpError(400, 'app is required');
|
|
166
|
+
const environment = value('environment') ?? this.options.environment;
|
|
167
|
+
const label = value('label') ?? DEFAULT_LABEL;
|
|
168
|
+
if (this.options.config.apps && !this.options.config.apps.includes(app)) {
|
|
169
|
+
throw new HttpError(403, `app "${app}" is not served by this console`);
|
|
170
|
+
}
|
|
171
|
+
return { app, environment, label };
|
|
172
|
+
}
|
|
173
|
+
async #actor(ctx) {
|
|
174
|
+
return consoleActor(ctx);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* The console's ordinary reads NEVER decrypt a secret: the entry arrives masked, and the operator
|
|
178
|
+
* asks for it explicitly (`POST /entries/:key/reveal`), which is audited. `revealSecrets` decides
|
|
179
|
+
* whether that button works at all.
|
|
180
|
+
*/
|
|
181
|
+
async #canReadSecrets() {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
async #shell(ctx) {
|
|
185
|
+
const registry = this.options.registry;
|
|
186
|
+
const viewer = await resolveViewer(ctx, this.options.config.viewer);
|
|
187
|
+
const signOut = resolveSignOut(ctx, this.options.config.signOut, registry);
|
|
188
|
+
const switcher = registry
|
|
189
|
+
? { endpoint: `${this.api}/consoles`, others: otherConsoles(registry, CONSOLE_ID) }
|
|
190
|
+
: undefined;
|
|
191
|
+
return {
|
|
192
|
+
...(viewer ? { viewer } : {}),
|
|
193
|
+
...(signOut ? { signOut } : {}),
|
|
194
|
+
...(switcher && switcher.others > 0 ? { switcher } : {}),
|
|
195
|
+
...(registry ? { search: { endpoint: `${this.api}/consoles/search` } } : {}),
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
async spa(ctx) {
|
|
199
|
+
if (!(await this.#guard(ctx, 'page')))
|
|
200
|
+
return;
|
|
201
|
+
let html;
|
|
202
|
+
try {
|
|
203
|
+
html = await readFile(join(this.options.spaDir, 'index.html'), 'utf8');
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
return ctx.response
|
|
207
|
+
.status(503)
|
|
208
|
+
.send('@adonis-agora/config-dashboard is not built: run `pnpm build` in the package.');
|
|
209
|
+
}
|
|
210
|
+
const shell = await this.#shell(ctx);
|
|
211
|
+
const rendered = renderIndexHtml(html, this.options.config.path, this.api, {
|
|
212
|
+
...(this.options.defaultApp ? { app: this.options.defaultApp } : {}),
|
|
213
|
+
environment: this.options.environment,
|
|
214
|
+
label: DEFAULT_LABEL,
|
|
215
|
+
}, shell);
|
|
216
|
+
ctx.response
|
|
217
|
+
.header('content-type', 'text/html; charset=utf-8')
|
|
218
|
+
.header('cache-control', 'no-store');
|
|
219
|
+
return ctx.response.send(rendered);
|
|
220
|
+
}
|
|
221
|
+
async asset(ctx) {
|
|
222
|
+
if (!(await this.#guard(ctx, 'page')))
|
|
223
|
+
return;
|
|
224
|
+
const file = String(ctx.params.file ?? '');
|
|
225
|
+
if (file === '' || file !== basename(file)) {
|
|
226
|
+
return ctx.response.status(404).send('not found');
|
|
227
|
+
}
|
|
228
|
+
try {
|
|
229
|
+
const bytes = await readFile(join(this.options.spaDir, 'assets', file));
|
|
230
|
+
ctx.response
|
|
231
|
+
.header('content-type', contentTypeFor(file))
|
|
232
|
+
.header('cache-control', 'public, max-age=31536000, immutable');
|
|
233
|
+
return ctx.response.send(bytes);
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
return ctx.response.status(404).send('not found');
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
async meta(ctx) {
|
|
240
|
+
const actor = await this.#actor(ctx);
|
|
241
|
+
const scopes = await this.options.admin.scopes();
|
|
242
|
+
const apps = this.options.config.apps ?? scopes.apps;
|
|
243
|
+
const defaultApp = this.options.defaultApp && apps.includes(this.options.defaultApp)
|
|
244
|
+
? this.options.defaultApp
|
|
245
|
+
: apps[0];
|
|
246
|
+
return ctx.response.header('cache-control', 'no-store').json({
|
|
247
|
+
apps,
|
|
248
|
+
environments: [...new Set([...scopes.environments, this.options.environment])],
|
|
249
|
+
labels: [...new Set([...scopes.labels, DEFAULT_LABEL])],
|
|
250
|
+
default: {
|
|
251
|
+
app: defaultApp ?? 'app',
|
|
252
|
+
environment: this.options.environment,
|
|
253
|
+
label: DEFAULT_LABEL,
|
|
254
|
+
},
|
|
255
|
+
secrets: this.options.secrets,
|
|
256
|
+
canRevealSecrets: this.options.config.revealSecrets,
|
|
257
|
+
topology: this.options.topology,
|
|
258
|
+
actor: actor.id,
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
async listEntries(ctx) {
|
|
262
|
+
const scope = this.#scope(ctx);
|
|
263
|
+
const list = parseListQuery(ctx.request.qs(), {
|
|
264
|
+
sortable: ['key', 'updatedAt', 'updatedBy'],
|
|
265
|
+
defaultSort: { field: 'key', direction: 'asc' },
|
|
266
|
+
filterable: ['key', 'secret', 'reloadable', 'updatedBy'],
|
|
267
|
+
defaultSize: 50,
|
|
268
|
+
maxSize: 200,
|
|
269
|
+
});
|
|
270
|
+
const secret = booleanFilter(list.filters.secret);
|
|
271
|
+
const reloadable = booleanFilter(list.filters.reloadable);
|
|
272
|
+
const updatedBy = list.filters.updatedBy;
|
|
273
|
+
return ctx.response.json(await this.options.admin.listEntries(scope, await this.#canReadSecrets(), {
|
|
274
|
+
page: list.page,
|
|
275
|
+
size: list.size,
|
|
276
|
+
filters: {
|
|
277
|
+
...(list.search !== undefined ? { search: list.search } : {}),
|
|
278
|
+
...(secret !== undefined ? { secret } : {}),
|
|
279
|
+
...(reloadable !== undefined ? { reloadable } : {}),
|
|
280
|
+
...(typeof updatedBy === 'string' ? { updatedBy } : {}),
|
|
281
|
+
},
|
|
282
|
+
sort: list.sort,
|
|
283
|
+
}));
|
|
284
|
+
}
|
|
285
|
+
async getEntry(ctx) {
|
|
286
|
+
const scope = this.#scope(ctx);
|
|
287
|
+
const key = String(ctx.params.key ?? '');
|
|
288
|
+
if (!key)
|
|
289
|
+
throw new HttpError(400, 'key is required');
|
|
290
|
+
const entry = await this.options.admin.getEntry(scope, key, {
|
|
291
|
+
canReadSecrets: await this.#canReadSecrets(),
|
|
292
|
+
});
|
|
293
|
+
if (!entry)
|
|
294
|
+
throw new HttpError(404, `no entry "${key}"`);
|
|
295
|
+
return ctx.response.header('cache-control', 'no-store').json(entry);
|
|
296
|
+
}
|
|
297
|
+
async setEntry(ctx) {
|
|
298
|
+
const scope = this.#scope(ctx);
|
|
299
|
+
const key = String(ctx.params.key ?? '');
|
|
300
|
+
assertConfigKey(key);
|
|
301
|
+
const body = this.#body(ctx);
|
|
302
|
+
if (body.value === undefined && body.vault === undefined) {
|
|
303
|
+
throw new HttpError(400, 'value or vault is required (a PUT is an upsert, not an unset)');
|
|
304
|
+
}
|
|
305
|
+
const input = {};
|
|
306
|
+
if (body.value !== undefined)
|
|
307
|
+
input.value = toConfigValue(body.value);
|
|
308
|
+
if (body.vault !== undefined) {
|
|
309
|
+
if (typeof body.vault !== 'string' || !body.vault.startsWith('vault://')) {
|
|
310
|
+
throw new HttpError(400, 'vault must be a vault:// reference');
|
|
311
|
+
}
|
|
312
|
+
input.vault = body.vault;
|
|
313
|
+
}
|
|
314
|
+
if (body.secret !== undefined) {
|
|
315
|
+
if (typeof body.secret !== 'boolean')
|
|
316
|
+
throw new HttpError(400, 'secret must be a boolean');
|
|
317
|
+
input.secret = body.secret;
|
|
318
|
+
}
|
|
319
|
+
if (body.sealedTo !== undefined) {
|
|
320
|
+
if (typeof body.sealedTo !== 'boolean') {
|
|
321
|
+
throw new HttpError(400, 'sealedTo must be a boolean');
|
|
322
|
+
}
|
|
323
|
+
input.sealedTo = body.sealedTo;
|
|
324
|
+
}
|
|
325
|
+
if (body.reloadable !== undefined) {
|
|
326
|
+
if (typeof body.reloadable !== 'boolean') {
|
|
327
|
+
throw new HttpError(400, 'reloadable must be a boolean');
|
|
328
|
+
}
|
|
329
|
+
input.reloadable = body.reloadable;
|
|
330
|
+
}
|
|
331
|
+
if (body.description !== undefined) {
|
|
332
|
+
if (body.description !== null && typeof body.description !== 'string') {
|
|
333
|
+
throw new HttpError(400, 'description must be a string or null');
|
|
334
|
+
}
|
|
335
|
+
input.description = body.description;
|
|
336
|
+
}
|
|
337
|
+
const actor = await this.#actor(ctx);
|
|
338
|
+
const result = await this.options.admin.setEntry(scope, key, input, {
|
|
339
|
+
actor: actor.id,
|
|
340
|
+
...(typeof body.message === 'string' && body.message !== '' ? { message: body.message } : {}),
|
|
341
|
+
});
|
|
342
|
+
const entry = await this.options.admin.getEntry(scope, key, {
|
|
343
|
+
canReadSecrets: await this.#canReadSecrets(),
|
|
344
|
+
});
|
|
345
|
+
return ctx.response
|
|
346
|
+
.status(200)
|
|
347
|
+
.json({ entry, version: result.version, changed: result.changed });
|
|
348
|
+
}
|
|
349
|
+
async unsetEntry(ctx) {
|
|
350
|
+
const scope = this.#scope(ctx);
|
|
351
|
+
const key = String(ctx.params.key ?? '');
|
|
352
|
+
assertConfigKey(key);
|
|
353
|
+
const actor = await this.#actor(ctx);
|
|
354
|
+
const body = this.#body(ctx);
|
|
355
|
+
const result = await this.options.admin.unsetEntry(scope, key, {
|
|
356
|
+
actor: actor.id,
|
|
357
|
+
...(typeof body.message === 'string' && body.message !== '' ? { message: body.message } : {}),
|
|
358
|
+
});
|
|
359
|
+
return ctx.response.json(result);
|
|
360
|
+
}
|
|
361
|
+
async reveal(ctx) {
|
|
362
|
+
if (!this.options.config.revealSecrets) {
|
|
363
|
+
throw new HttpError(403, 'revealing secrets is disabled on this console');
|
|
364
|
+
}
|
|
365
|
+
const scope = this.#scope(ctx);
|
|
366
|
+
const key = String(ctx.params.key ?? '');
|
|
367
|
+
const actor = await this.#actor(ctx);
|
|
368
|
+
const entry = await this.options.admin.getEntry(scope, key, {
|
|
369
|
+
canReadSecrets: true,
|
|
370
|
+
reveal: { actor: actor.id },
|
|
371
|
+
});
|
|
372
|
+
if (!entry)
|
|
373
|
+
throw new HttpError(404, `no entry "${key}"`);
|
|
374
|
+
return ctx.response.header('cache-control', 'no-store').json(entry);
|
|
375
|
+
}
|
|
376
|
+
async listVersions(ctx) {
|
|
377
|
+
const scope = this.#scope(ctx);
|
|
378
|
+
const list = parseListQuery(ctx.request.qs(), {
|
|
379
|
+
sortable: ['version', 'createdAt'],
|
|
380
|
+
defaultSort: { field: 'version', direction: 'desc' },
|
|
381
|
+
filterable: [],
|
|
382
|
+
defaultSize: 20,
|
|
383
|
+
maxSize: 100,
|
|
384
|
+
});
|
|
385
|
+
return ctx.response.json(await this.options.admin.listVersions(scope, {
|
|
386
|
+
page: list.page,
|
|
387
|
+
size: list.size,
|
|
388
|
+
direction: list.sort.direction,
|
|
389
|
+
}));
|
|
390
|
+
}
|
|
391
|
+
async getVersion(ctx) {
|
|
392
|
+
const scope = this.#scope(ctx);
|
|
393
|
+
const version = Number(ctx.params.version);
|
|
394
|
+
if (!Number.isInteger(version) || version < 1)
|
|
395
|
+
throw new HttpError(400, 'invalid version');
|
|
396
|
+
const found = await this.options.admin.version(scope, version, await this.#canReadSecrets());
|
|
397
|
+
if (!found)
|
|
398
|
+
throw new HttpError(404, `no version ${version}`);
|
|
399
|
+
return ctx.response.json(found);
|
|
400
|
+
}
|
|
401
|
+
async diff(ctx) {
|
|
402
|
+
const scope = this.#scope(ctx);
|
|
403
|
+
const query = ctx.request.qs();
|
|
404
|
+
const from = Number(query.from);
|
|
405
|
+
const to = Number(query.to);
|
|
406
|
+
if (!Number.isInteger(from) || !Number.isInteger(to)) {
|
|
407
|
+
throw new HttpError(400, 'from and to must be version numbers');
|
|
408
|
+
}
|
|
409
|
+
return ctx.response.json({
|
|
410
|
+
from,
|
|
411
|
+
to,
|
|
412
|
+
rows: await this.options.admin.diff(scope, from, to, await this.#canReadSecrets()),
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
async rollback(ctx) {
|
|
416
|
+
const scope = this.#scope(ctx);
|
|
417
|
+
const body = this.#body(ctx);
|
|
418
|
+
const to = Number(body.to);
|
|
419
|
+
if (!Number.isInteger(to) || to < 1)
|
|
420
|
+
throw new HttpError(400, 'to must be a version number');
|
|
421
|
+
const actor = await this.#actor(ctx);
|
|
422
|
+
const result = await this.options.admin.rollback(scope, to, {
|
|
423
|
+
actor: actor.id,
|
|
424
|
+
...(typeof body.message === 'string' && body.message !== '' ? { message: body.message } : {}),
|
|
425
|
+
});
|
|
426
|
+
return ctx.response.json(result);
|
|
427
|
+
}
|
|
428
|
+
async audit(ctx) {
|
|
429
|
+
const scope = this.#scope(ctx);
|
|
430
|
+
const list = parseListQuery(ctx.request.qs(), {
|
|
431
|
+
sortable: ['at', 'version'],
|
|
432
|
+
defaultSort: { field: 'at', direction: 'desc' },
|
|
433
|
+
filterable: ['key', 'action'],
|
|
434
|
+
defaultSize: 50,
|
|
435
|
+
maxSize: 200,
|
|
436
|
+
});
|
|
437
|
+
const action = list.filters.action;
|
|
438
|
+
const key = list.filters.key;
|
|
439
|
+
return ctx.response.json(await this.options.admin.audit(scope, {
|
|
440
|
+
page: list.page,
|
|
441
|
+
size: list.size,
|
|
442
|
+
...(typeof action === 'string' ? { action } : {}),
|
|
443
|
+
...(typeof key === 'string' ? { key } : {}),
|
|
444
|
+
}));
|
|
445
|
+
}
|
|
446
|
+
async consoles(ctx) {
|
|
447
|
+
return ctx.response.json(await listVisibleConsoles(this.options.registry, CONSOLE_ID, ctx));
|
|
448
|
+
}
|
|
449
|
+
async search(ctx) {
|
|
450
|
+
const q = ctx.request.qs().q ?? '';
|
|
451
|
+
return ctx.response.json(await searchConsoles(this.options.registry, CONSOLE_ID, ctx, q));
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
// A token-gated console still answers the same way; the helper is exported for apps that want it.
|
|
455
|
+
export const consoleAuthorizeByToken = tokenAuthorize;
|
|
456
|
+
//# sourceMappingURL=console.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console.js","sourceRoot":"","sources":["../../../src/dashboard/console.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,eAAe,EAGf,aAAa,EACb,aAAa,GACd,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAGhE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAqB,YAAY,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAiC,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAEL,mBAAmB,EACnB,aAAa,EACb,cAAc,GACf,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AA2B3D,4DAA4D;AAC5D,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC;AAEnC,MAAM,SAAU,SAAQ,KAAK;IAEhB,MAAM;IADjB,YACW,MAAc,EACvB,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAA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CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { HttpContext } from '@adonisjs/core/http';
|
|
2
|
+
/**
|
|
3
|
+
* The console access contract every `@adonis-agora` console (durable, telescope, media, payments, flags,
|
|
4
|
+
* agent, the authkit admin) takes for its `authorize` option. These types are copied, not shared
|
|
5
|
+
* through a package, and kept identical across the libs: TypeScript is structural, so one
|
|
6
|
+
* authorizer class satisfies every console.
|
|
7
|
+
*/
|
|
8
|
+
/** What an authorizer may answer. */
|
|
9
|
+
export type ConsoleAuthorizeResult = boolean | {
|
|
10
|
+
allowed: true;
|
|
11
|
+
} | {
|
|
12
|
+
allowed: false;
|
|
13
|
+
reason?: 'unauthenticated' | 'forbidden';
|
|
14
|
+
} | {
|
|
15
|
+
redirectTo: string;
|
|
16
|
+
};
|
|
17
|
+
/** A class form, for an authorizer in its own file (`@inject()` works). */
|
|
18
|
+
export interface ConsoleAuthorizer {
|
|
19
|
+
authorize(ctx: HttpContext): ConsoleAuthorizeResult | Promise<ConsoleAuthorizeResult>;
|
|
20
|
+
}
|
|
21
|
+
export type ConsoleAuthorizerClass = new (...args: any[]) => ConsoleAuthorizer;
|
|
22
|
+
/** The `authorize` option: an inline function, the authorizer class, or a lazy import of it. */
|
|
23
|
+
export type ConsoleAuthorize = ((ctx: HttpContext) => ConsoleAuthorizeResult | Promise<ConsoleAuthorizeResult>) | ConsoleAuthorizerClass | (() => Promise<{
|
|
24
|
+
default: ConsoleAuthorizerClass;
|
|
25
|
+
}>);
|
|
26
|
+
/** A {@link ConsoleAuthorizeResult} normalized to the answer the console writes. */
|
|
27
|
+
export type ConsoleAuthorizeDecision = {
|
|
28
|
+
allowed: true;
|
|
29
|
+
} | {
|
|
30
|
+
allowed: false;
|
|
31
|
+
status: 401;
|
|
32
|
+
reason: 'unauthenticated';
|
|
33
|
+
} | {
|
|
34
|
+
allowed: false;
|
|
35
|
+
status: 403;
|
|
36
|
+
reason: 'forbidden';
|
|
37
|
+
error?: unknown;
|
|
38
|
+
} | {
|
|
39
|
+
allowed: false;
|
|
40
|
+
status: 302;
|
|
41
|
+
redirectTo: string;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Normalize an authorizer's answer. Fails closed: only `true` or `{ allowed: true }` passes;
|
|
45
|
+
* `{ redirectTo }` with a non-empty string is a redirect; anything else is a denial (`401` for
|
|
46
|
+
* `reason: 'unauthenticated'`, `403` otherwise).
|
|
47
|
+
*/
|
|
48
|
+
export declare function normalizeConsoleAuthorizeResult(result: unknown): ConsoleAuthorizeDecision;
|
|
49
|
+
/**
|
|
50
|
+
* Turn an `authorize` option into one guard function.
|
|
51
|
+
*
|
|
52
|
+
* - A class is built through the request's container (`ctx.containerResolver.make`), so
|
|
53
|
+
* `@inject()` works, and its `authorize(ctx)` is called.
|
|
54
|
+
* - A function is called with `ctx`. When it resolves to a module whose `default` is an
|
|
55
|
+
* authorizer class, it was a lazy import: the class is remembered (the import runs once per
|
|
56
|
+
* returned guard) and used as above.
|
|
57
|
+
* - A thrown error is a `403` denial, carried on `error` so the caller can log it.
|
|
58
|
+
*/
|
|
59
|
+
export declare function resolveConsoleAuthorize(authorize: ConsoleAuthorize): (ctx: HttpContext) => Promise<ConsoleAuthorizeDecision>;
|
|
60
|
+
/** Options for {@link authorizeByToken}. */
|
|
61
|
+
export interface AuthorizeByTokenOptions {
|
|
62
|
+
/** The shared secret callers send as `Authorization: Bearer <token>`. */
|
|
63
|
+
token: string | undefined;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* An `authorize` check for machine access: allows a request whose `Authorization` header is
|
|
67
|
+
* `Bearer <token>` (compared in constant time), and answers
|
|
68
|
+
* `{ allowed: false, reason: 'unauthenticated' }` (`401`) otherwise. Only the header is read.
|
|
69
|
+
*
|
|
70
|
+
* ```ts
|
|
71
|
+
* authorize: authorizeByToken({ token: env.get('CONSOLE_TOKEN') }),
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* Throws at config time when `token` is empty or undefined.
|
|
75
|
+
*/
|
|
76
|
+
export declare function authorizeByToken(options: AuthorizeByTokenOptions): ConsoleAuthorize;
|
|
77
|
+
/**
|
|
78
|
+
* Allows a request when ANY of the given checks allows it, tried in order. Typical: a token for MCP
|
|
79
|
+
* clients and scripts, or a signed-in admin for the browser.
|
|
80
|
+
*
|
|
81
|
+
* ```ts
|
|
82
|
+
* authorize: anyAuthorize(
|
|
83
|
+
* authorizeByToken({ token: env.get('CONSOLE_TOKEN') }),
|
|
84
|
+
* (ctx) => ctx.auth.user?.isAdmin ?? false,
|
|
85
|
+
* ),
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* Refused by all: a redirect when one asked for it, else `401` when one wanted a sign-in, else `403`.
|
|
89
|
+
*/
|
|
90
|
+
export declare function anyAuthorize(...authorizers: ConsoleAuthorize[]): (ctx: HttpContext) => Promise<ConsoleAuthorizeResult>;
|
|
91
|
+
//# sourceMappingURL=console_authorize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console_authorize.d.ts","sourceRoot":"","sources":["../../../src/dashboard/console_authorize.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;GAKG;AAEH,qCAAqC;AACrC,MAAM,MAAM,sBAAsB,GAC9B,OAAO,GACP;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,GACjB;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,CAAC,EAAE,iBAAiB,GAAG,WAAW,CAAA;CAAE,GAC5D;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3B,2EAA2E;AAC3E,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,GAAG,EAAE,WAAW,GAAG,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;CACvF;AAGD,MAAM,MAAM,sBAAsB,GAAG,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE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