@3sixty/api-tenant-processor 0.20.0-next.0 → 0.20.0-next.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/dist/es/entities/tenant.js.map +1 -1
- package/dist/es/entities/tenantV0.js.map +1 -1
- package/dist/es/entities/tenantV1.js.map +1 -1
- package/dist/es/index.js +4 -3
- package/dist/es/index.js.map +1 -1
- package/dist/es/models/ISingleTenantProcessorConfig.js.map +1 -1
- package/dist/es/models/ISingleTenantProcessorConstructorOptions.js.map +1 -1
- package/dist/es/models/ITenantAdminServiceConfig.js.map +1 -1
- package/dist/es/models/ITenantAdminServiceConstructorOptions.js.map +1 -1
- package/dist/es/models/ITenantProcessorConfig.js.map +1 -1
- package/dist/es/models/ITenantProcessorConstructorOptions.js.map +1 -1
- package/dist/es/models/api/ITenantCreateRequest.js.map +1 -1
- package/dist/es/models/api/ITenantGetByApiKeyRequest.js.map +1 -1
- package/dist/es/models/api/ITenantGetByIdRequest.js.map +1 -1
- package/dist/es/models/api/ITenantGetByPublicOriginRequest.js.map +1 -1
- package/dist/es/models/api/ITenantGetResponse.js.map +1 -1
- package/dist/es/models/api/ITenantListRequest.js.map +1 -1
- package/dist/es/models/api/ITenantListResponse.js.map +1 -1
- package/dist/es/models/api/ITenantRemoveRequest.js.map +1 -1
- package/dist/es/models/api/ITenantUpdateRequest.js.map +1 -1
- package/dist/es/restEntryPoints.js.map +1 -1
- package/dist/es/schema.js.map +1 -1
- package/dist/es/singleTenantProcessor.js.map +1 -1
- package/dist/es/tenantAdminService.js +12 -2
- package/dist/es/tenantAdminService.js.map +1 -1
- package/dist/es/tenantIdContextIdHandler.js.map +1 -1
- package/dist/es/tenantProcessor.js.map +1 -1
- package/dist/es/tenantRoutes.js +20 -7
- package/dist/es/tenantRoutes.js.map +1 -1
- package/dist/es/utils/tenantIdHelper.js.map +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/models/ITenantAdminServiceConstructorOptions.d.ts +5 -0
- package/docs/changelog.md +17 -0
- package/docs/reference/classes/SingleTenantProcessor.md +2 -0
- package/docs/reference/classes/TenantAdminService.md +1 -1
- package/docs/reference/classes/TenantProcessor.md +2 -0
- package/docs/reference/classes/TenantV0.md +61 -0
- package/docs/reference/classes/TenantV1.md +77 -0
- package/docs/reference/index.md +3 -3
- package/docs/reference/interfaces/ITenantAdminServiceConstructorOptions.md +14 -0
- package/docs/reference/variables/restEntryPoints.md +5 -0
- package/locales/en.json +0 -4
- package/package.json +2 -2
- package/dist/es/models/ITenantOverrideProcessorConfig.js +0 -4
- package/dist/es/models/ITenantOverrideProcessorConfig.js.map +0 -1
- package/dist/es/models/ITenantOverrideProcessorConstructorOptions.js +0 -2
- package/dist/es/models/ITenantOverrideProcessorConstructorOptions.js.map +0 -1
- package/dist/es/tenantOverrideProcessor.js +0 -119
- package/dist/es/tenantOverrideProcessor.js.map +0 -1
- package/dist/types/models/ITenantOverrideProcessorConfig.d.ts +0 -13
- package/dist/types/models/ITenantOverrideProcessorConstructorOptions.d.ts +0 -15
- package/dist/types/tenantOverrideProcessor.d.ts +0 -44
- package/docs/reference/classes/TenantOverrideProcessor.md +0 -119
- package/docs/reference/interfaces/ITenantOverrideProcessorConfig.md +0 -19
- package/docs/reference/interfaces/ITenantOverrideProcessorConstructorOptions.md +0 -25
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 IOTA Stiftung.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
-
import { ForbiddenError, HttpContextIdKeys, HttpErrorHelper, ScopeHelper } from "@3sixty/api-models";
|
|
4
|
-
import { ContextIdKeys } from "@3sixty/context";
|
|
5
|
-
import { BaseError, ComponentFactory, GuardError, Is, NotFoundError } from "@3sixty/core";
|
|
6
|
-
/**
|
|
7
|
-
* Processes the overrideTenant query parameter for routes that allow tenant override.
|
|
8
|
-
* Requires the caller to hold the escalated privilege scope. Runs after AuthHeaderProcessor so
|
|
9
|
-
* authentication is always resolved in the caller's own partition first.
|
|
10
|
-
*/
|
|
11
|
-
export class TenantOverrideProcessor {
|
|
12
|
-
/**
|
|
13
|
-
* The query parameter name used to supply the override tenant ID.
|
|
14
|
-
*/
|
|
15
|
-
static OVERRIDE_TENANT_PARAM = "override-tenant";
|
|
16
|
-
/**
|
|
17
|
-
* The scope string required to perform a tenant override.
|
|
18
|
-
*/
|
|
19
|
-
static DEFAULT_ESCALATED_PRIVILEGE_SCOPE = "global-admin";
|
|
20
|
-
/**
|
|
21
|
-
* Runtime name for the class.
|
|
22
|
-
*/
|
|
23
|
-
static CLASS_NAME = "TenantOverrideProcessor";
|
|
24
|
-
/**
|
|
25
|
-
* The component used to resolve tenants, which also provides the lookup caching.
|
|
26
|
-
* @internal
|
|
27
|
-
*/
|
|
28
|
-
_tenantAdminComponent;
|
|
29
|
-
/**
|
|
30
|
-
* Include the stack with errors.
|
|
31
|
-
* @internal
|
|
32
|
-
*/
|
|
33
|
-
_includeErrorStack;
|
|
34
|
-
/**
|
|
35
|
-
* The scope value that grants cross-tenant access.
|
|
36
|
-
* @internal
|
|
37
|
-
*/
|
|
38
|
-
_escalatedPrivilegeScope;
|
|
39
|
-
/**
|
|
40
|
-
* Create a new instance of TenantOverrideProcessor.
|
|
41
|
-
* @param options Options for the processor.
|
|
42
|
-
*/
|
|
43
|
-
constructor(options) {
|
|
44
|
-
this._tenantAdminComponent = ComponentFactory.get(options?.tenantAdminComponentType ?? "tenant-admin");
|
|
45
|
-
this._includeErrorStack = options?.config?.includeErrorStack ?? false;
|
|
46
|
-
this._escalatedPrivilegeScope =
|
|
47
|
-
options?.config?.escalatedPrivilegeScope ??
|
|
48
|
-
TenantOverrideProcessor.DEFAULT_ESCALATED_PRIVILEGE_SCOPE;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Returns the class name of the component.
|
|
52
|
-
* @returns The class name of the component.
|
|
53
|
-
*/
|
|
54
|
-
className() {
|
|
55
|
-
return TenantOverrideProcessor.CLASS_NAME;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Pre process the REST request for the specified route.
|
|
59
|
-
* @param request The incoming request.
|
|
60
|
-
* @param response The outgoing response.
|
|
61
|
-
* @param route The route to process.
|
|
62
|
-
* @param contextIds The context IDs of the request.
|
|
63
|
-
* @param processorState The state handed through the processors.
|
|
64
|
-
* @returns A promise that resolves when the tenant override has been applied or skipped.
|
|
65
|
-
*/
|
|
66
|
-
async pre(request, response, route, contextIds, processorState) {
|
|
67
|
-
if (Is.empty(route) || (route.disableTenantOverride ?? false)) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
const overrideTenantParam = request.query?.[TenantOverrideProcessor.OVERRIDE_TENANT_PARAM];
|
|
71
|
-
if (!Is.stringValue(overrideTenantParam)) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
// If a prior processor already set an error response, skip processing.
|
|
75
|
-
if (Is.notEmpty(response.statusCode)) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
try {
|
|
79
|
-
// Caller must hold the escalated privilege scope.
|
|
80
|
-
if (!ScopeHelper.includes(contextIds[HttpContextIdKeys.Scope], this._escalatedPrivilegeScope)) {
|
|
81
|
-
throw new ForbiddenError(TenantOverrideProcessor.CLASS_NAME, "insufficientScopeForTenantOverride");
|
|
82
|
-
}
|
|
83
|
-
// Verify the tenant exists before substituting.
|
|
84
|
-
await this.verifyTenantExists(overrideTenantParam);
|
|
85
|
-
contextIds[HttpContextIdKeys.OriginalTenant] = contextIds[ContextIdKeys.Tenant];
|
|
86
|
-
contextIds[ContextIdKeys.Tenant] = overrideTenantParam;
|
|
87
|
-
}
|
|
88
|
-
catch (err) {
|
|
89
|
-
const error = BaseError.fromError(err);
|
|
90
|
-
const { httpStatusCode } = HttpErrorHelper.processError(error);
|
|
91
|
-
HttpErrorHelper.buildResponse(response, error, httpStatusCode, this._includeErrorStack);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Confirm the tenant being switched to exists.
|
|
96
|
-
* @param tenantId The tenant id from the override query parameter.
|
|
97
|
-
* @throws NotFoundError if no tenant matches the id.
|
|
98
|
-
* @internal
|
|
99
|
-
*/
|
|
100
|
-
async verifyTenantExists(tenantId) {
|
|
101
|
-
let tenant;
|
|
102
|
-
try {
|
|
103
|
-
tenant = await this._tenantAdminComponent.get(tenantId);
|
|
104
|
-
}
|
|
105
|
-
catch (err) {
|
|
106
|
-
// An id that matches no tenant, or is not even well formed, is a not found; anything
|
|
107
|
-
// else is a genuine fault and keeps its own status code.
|
|
108
|
-
if (BaseError.isErrorName(err, NotFoundError.CLASS_NAME) ||
|
|
109
|
-
BaseError.isErrorName(err, GuardError.CLASS_NAME)) {
|
|
110
|
-
throw new NotFoundError(TenantOverrideProcessor.CLASS_NAME, "tenantNotFound", tenantId, undefined, err);
|
|
111
|
-
}
|
|
112
|
-
throw err;
|
|
113
|
-
}
|
|
114
|
-
if (tenant.id !== tenantId) {
|
|
115
|
-
throw new NotFoundError(TenantOverrideProcessor.CLASS_NAME, "tenantNotFound", tenantId);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
//# sourceMappingURL=tenantOverrideProcessor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tenantOverrideProcessor.js","sourceRoot":"","sources":["../../src/tenantOverrideProcessor.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,WAAW,EAOX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAoB,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAI1F;;;;GAIG;AACH,MAAM,OAAO,uBAAuB;IACnC;;OAEG;IACI,MAAM,CAAU,qB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,CACH,CAAC;YACH,CAAC;YACD,MAAM,GAAG,CAAC;QACX,CAAC;QAED,IAAI,MAAM,CAAC,EAAE,KAAK,QAAQ,EAAE,CAAC;YAC5B,MAAM,IAAI,aAAa,CAAC,uBAAuB,CAAC,UAAU,EAAE,gBAAgB,EAAE,QAAQ,CAAC,CAAC;QACzF,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tForbiddenError,\n\tHttpContextIdKeys,\n\tHttpErrorHelper,\n\tScopeHelper,\n\ttype IBaseRoute,\n\ttype IBaseRouteProcessor,\n\ttype IHttpResponse,\n\ttype IHttpServerRequest,\n\ttype ITenant,\n\ttype ITenantAdminComponent\n} from \"@3sixty/api-models\";\nimport { ContextIdKeys, type IContextIds } from \"@3sixty/context\";\nimport { BaseError, ComponentFactory, GuardError, Is, NotFoundError } from \"@3sixty/core\";\nimport { nameof } from \"@3sixty/nameof\";\nimport type { ITenantOverrideProcessorConstructorOptions } from \"./models/ITenantOverrideProcessorConstructorOptions.js\";\n\n/**\n * Processes the overrideTenant query parameter for routes that allow tenant override.\n * Requires the caller to hold the escalated privilege scope. Runs after AuthHeaderProcessor so\n * authentication is always resolved in the caller's own partition first.\n */\nexport class TenantOverrideProcessor implements IBaseRouteProcessor {\n\t/**\n\t * The query parameter name used to supply the override tenant ID.\n\t */\n\tpublic static readonly OVERRIDE_TENANT_PARAM: string = \"override-tenant\";\n\n\t/**\n\t * The scope string required to perform a tenant override.\n\t */\n\tpublic static readonly DEFAULT_ESCALATED_PRIVILEGE_SCOPE: string = \"global-admin\";\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<TenantOverrideProcessor>();\n\n\t/**\n\t * The component used to resolve tenants, which also provides the lookup caching.\n\t * @internal\n\t */\n\tprivate readonly _tenantAdminComponent: ITenantAdminComponent;\n\n\t/**\n\t * Include the stack with errors.\n\t * @internal\n\t */\n\tprivate readonly _includeErrorStack: boolean;\n\n\t/**\n\t * The scope value that grants cross-tenant access.\n\t * @internal\n\t */\n\tprivate readonly _escalatedPrivilegeScope: string;\n\n\t/**\n\t * Create a new instance of TenantOverrideProcessor.\n\t * @param options Options for the processor.\n\t */\n\tconstructor(options?: ITenantOverrideProcessorConstructorOptions) {\n\t\tthis._tenantAdminComponent = ComponentFactory.get<ITenantAdminComponent>(\n\t\t\toptions?.tenantAdminComponentType ?? \"tenant-admin\"\n\t\t);\n\t\tthis._includeErrorStack = options?.config?.includeErrorStack ?? false;\n\t\tthis._escalatedPrivilegeScope =\n\t\t\toptions?.config?.escalatedPrivilegeScope ??\n\t\t\tTenantOverrideProcessor.DEFAULT_ESCALATED_PRIVILEGE_SCOPE;\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn TenantOverrideProcessor.CLASS_NAME;\n\t}\n\n\t/**\n\t * Pre process the REST request for the specified route.\n\t * @param request The incoming request.\n\t * @param response The outgoing response.\n\t * @param route The route to process.\n\t * @param contextIds The context IDs of the request.\n\t * @param processorState The state handed through the processors.\n\t * @returns A promise that resolves when the tenant override has been applied or skipped.\n\t */\n\tpublic async pre(\n\t\trequest: IHttpServerRequest,\n\t\tresponse: IHttpResponse,\n\t\troute: IBaseRoute | undefined,\n\t\tcontextIds: IContextIds,\n\t\tprocessorState: { [id: string]: unknown }\n\t): Promise<void> {\n\t\tif (Is.empty(route) || (route.disableTenantOverride ?? false)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst overrideTenantParam = request.query?.[TenantOverrideProcessor.OVERRIDE_TENANT_PARAM];\n\t\tif (!Is.stringValue(overrideTenantParam)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If a prior processor already set an error response, skip processing.\n\t\tif (Is.notEmpty(response.statusCode)) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\t// Caller must hold the escalated privilege scope.\n\t\t\tif (\n\t\t\t\t!ScopeHelper.includes(contextIds[HttpContextIdKeys.Scope], this._escalatedPrivilegeScope)\n\t\t\t) {\n\t\t\t\tthrow new ForbiddenError(\n\t\t\t\t\tTenantOverrideProcessor.CLASS_NAME,\n\t\t\t\t\t\"insufficientScopeForTenantOverride\"\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Verify the tenant exists before substituting.\n\t\t\tawait this.verifyTenantExists(overrideTenantParam);\n\n\t\t\tcontextIds[HttpContextIdKeys.OriginalTenant] = contextIds[ContextIdKeys.Tenant];\n\t\t\tcontextIds[ContextIdKeys.Tenant] = overrideTenantParam;\n\t\t} catch (err) {\n\t\t\tconst error = BaseError.fromError(err);\n\t\t\tconst { httpStatusCode } = HttpErrorHelper.processError(error);\n\t\t\tHttpErrorHelper.buildResponse(response, error, httpStatusCode, this._includeErrorStack);\n\t\t}\n\t}\n\n\t/**\n\t * Confirm the tenant being switched to exists.\n\t * @param tenantId The tenant id from the override query parameter.\n\t * @throws NotFoundError if no tenant matches the id.\n\t * @internal\n\t */\n\tprivate async verifyTenantExists(tenantId: string): Promise<void> {\n\t\tlet tenant: ITenant;\n\n\t\ttry {\n\t\t\ttenant = await this._tenantAdminComponent.get(tenantId);\n\t\t} catch (err) {\n\t\t\t// An id that matches no tenant, or is not even well formed, is a not found; anything\n\t\t\t// else is a genuine fault and keeps its own status code.\n\t\t\tif (\n\t\t\t\tBaseError.isErrorName(err, NotFoundError.CLASS_NAME) ||\n\t\t\t\tBaseError.isErrorName(err, GuardError.CLASS_NAME)\n\t\t\t) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\tTenantOverrideProcessor.CLASS_NAME,\n\t\t\t\t\t\"tenantNotFound\",\n\t\t\t\t\ttenantId,\n\t\t\t\t\tundefined,\n\t\t\t\t\terr\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow err;\n\t\t}\n\n\t\tif (tenant.id !== tenantId) {\n\t\t\tthrow new NotFoundError(TenantOverrideProcessor.CLASS_NAME, \"tenantNotFound\", tenantId);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration for the TenantOverrideProcessor.
|
|
3
|
-
*/
|
|
4
|
-
export interface ITenantOverrideProcessorConfig {
|
|
5
|
-
/**
|
|
6
|
-
* Include the stack with errors.
|
|
7
|
-
*/
|
|
8
|
-
includeErrorStack?: boolean;
|
|
9
|
-
/**
|
|
10
|
-
* The scope value that grants escalated privilege for cross-tenant access. Defaults to "global-admin".
|
|
11
|
-
*/
|
|
12
|
-
escalatedPrivilegeScope?: string;
|
|
13
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ITenantOverrideProcessorConfig } from "./ITenantOverrideProcessorConfig.js";
|
|
2
|
-
/**
|
|
3
|
-
* Options for the TenantOverrideProcessor constructor.
|
|
4
|
-
*/
|
|
5
|
-
export interface ITenantOverrideProcessorConstructorOptions {
|
|
6
|
-
/**
|
|
7
|
-
* The component used to resolve tenants, which also provides the lookup caching.
|
|
8
|
-
* @default tenant-admin
|
|
9
|
-
*/
|
|
10
|
-
tenantAdminComponentType?: string;
|
|
11
|
-
/**
|
|
12
|
-
* Configuration for the processor.
|
|
13
|
-
*/
|
|
14
|
-
config?: ITenantOverrideProcessorConfig;
|
|
15
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { type IBaseRoute, type IBaseRouteProcessor, type IHttpResponse, type IHttpServerRequest } from "@3sixty/api-models";
|
|
2
|
-
import { type IContextIds } from "@3sixty/context";
|
|
3
|
-
import type { ITenantOverrideProcessorConstructorOptions } from "./models/ITenantOverrideProcessorConstructorOptions.js";
|
|
4
|
-
/**
|
|
5
|
-
* Processes the overrideTenant query parameter for routes that allow tenant override.
|
|
6
|
-
* Requires the caller to hold the escalated privilege scope. Runs after AuthHeaderProcessor so
|
|
7
|
-
* authentication is always resolved in the caller's own partition first.
|
|
8
|
-
*/
|
|
9
|
-
export declare class TenantOverrideProcessor implements IBaseRouteProcessor {
|
|
10
|
-
/**
|
|
11
|
-
* The query parameter name used to supply the override tenant ID.
|
|
12
|
-
*/
|
|
13
|
-
static readonly OVERRIDE_TENANT_PARAM: string;
|
|
14
|
-
/**
|
|
15
|
-
* The scope string required to perform a tenant override.
|
|
16
|
-
*/
|
|
17
|
-
static readonly DEFAULT_ESCALATED_PRIVILEGE_SCOPE: string;
|
|
18
|
-
/**
|
|
19
|
-
* Runtime name for the class.
|
|
20
|
-
*/
|
|
21
|
-
static readonly CLASS_NAME: string;
|
|
22
|
-
/**
|
|
23
|
-
* Create a new instance of TenantOverrideProcessor.
|
|
24
|
-
* @param options Options for the processor.
|
|
25
|
-
*/
|
|
26
|
-
constructor(options?: ITenantOverrideProcessorConstructorOptions);
|
|
27
|
-
/**
|
|
28
|
-
* Returns the class name of the component.
|
|
29
|
-
* @returns The class name of the component.
|
|
30
|
-
*/
|
|
31
|
-
className(): string;
|
|
32
|
-
/**
|
|
33
|
-
* Pre process the REST request for the specified route.
|
|
34
|
-
* @param request The incoming request.
|
|
35
|
-
* @param response The outgoing response.
|
|
36
|
-
* @param route The route to process.
|
|
37
|
-
* @param contextIds The context IDs of the request.
|
|
38
|
-
* @param processorState The state handed through the processors.
|
|
39
|
-
* @returns A promise that resolves when the tenant override has been applied or skipped.
|
|
40
|
-
*/
|
|
41
|
-
pre(request: IHttpServerRequest, response: IHttpResponse, route: IBaseRoute | undefined, contextIds: IContextIds, processorState: {
|
|
42
|
-
[id: string]: unknown;
|
|
43
|
-
}): Promise<void>;
|
|
44
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
# Class: TenantOverrideProcessor
|
|
2
|
-
|
|
3
|
-
Processes the overrideTenant query parameter for routes that allow tenant override.
|
|
4
|
-
Requires the caller to hold the escalated privilege scope. Runs after AuthHeaderProcessor so
|
|
5
|
-
authentication is always resolved in the caller's own partition first.
|
|
6
|
-
|
|
7
|
-
## Implements
|
|
8
|
-
|
|
9
|
-
- `IBaseRouteProcessor`
|
|
10
|
-
|
|
11
|
-
## Constructors
|
|
12
|
-
|
|
13
|
-
### Constructor
|
|
14
|
-
|
|
15
|
-
> **new TenantOverrideProcessor**(`options?`): `TenantOverrideProcessor`
|
|
16
|
-
|
|
17
|
-
Create a new instance of TenantOverrideProcessor.
|
|
18
|
-
|
|
19
|
-
#### Parameters
|
|
20
|
-
|
|
21
|
-
##### options?
|
|
22
|
-
|
|
23
|
-
[`ITenantOverrideProcessorConstructorOptions`](../interfaces/ITenantOverrideProcessorConstructorOptions.md)
|
|
24
|
-
|
|
25
|
-
Options for the processor.
|
|
26
|
-
|
|
27
|
-
#### Returns
|
|
28
|
-
|
|
29
|
-
`TenantOverrideProcessor`
|
|
30
|
-
|
|
31
|
-
## Properties
|
|
32
|
-
|
|
33
|
-
### OVERRIDE\_TENANT\_PARAM {#override_tenant_param}
|
|
34
|
-
|
|
35
|
-
> `readonly` `static` **OVERRIDE\_TENANT\_PARAM**: `string` = `"override-tenant"`
|
|
36
|
-
|
|
37
|
-
The query parameter name used to supply the override tenant ID.
|
|
38
|
-
|
|
39
|
-
***
|
|
40
|
-
|
|
41
|
-
### DEFAULT\_ESCALATED\_PRIVILEGE\_SCOPE {#default_escalated_privilege_scope}
|
|
42
|
-
|
|
43
|
-
> `readonly` `static` **DEFAULT\_ESCALATED\_PRIVILEGE\_SCOPE**: `string` = `"global-admin"`
|
|
44
|
-
|
|
45
|
-
The scope string required to perform a tenant override.
|
|
46
|
-
|
|
47
|
-
***
|
|
48
|
-
|
|
49
|
-
### CLASS\_NAME {#class_name}
|
|
50
|
-
|
|
51
|
-
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
52
|
-
|
|
53
|
-
Runtime name for the class.
|
|
54
|
-
|
|
55
|
-
## Methods
|
|
56
|
-
|
|
57
|
-
### className() {#classname}
|
|
58
|
-
|
|
59
|
-
> **className**(): `string`
|
|
60
|
-
|
|
61
|
-
Returns the class name of the component.
|
|
62
|
-
|
|
63
|
-
#### Returns
|
|
64
|
-
|
|
65
|
-
`string`
|
|
66
|
-
|
|
67
|
-
The class name of the component.
|
|
68
|
-
|
|
69
|
-
#### Implementation of
|
|
70
|
-
|
|
71
|
-
`IBaseRouteProcessor.className`
|
|
72
|
-
|
|
73
|
-
***
|
|
74
|
-
|
|
75
|
-
### pre() {#pre}
|
|
76
|
-
|
|
77
|
-
> **pre**(`request`, `response`, `route`, `contextIds`, `processorState`): `Promise`\<`void`\>
|
|
78
|
-
|
|
79
|
-
Pre process the REST request for the specified route.
|
|
80
|
-
|
|
81
|
-
#### Parameters
|
|
82
|
-
|
|
83
|
-
##### request
|
|
84
|
-
|
|
85
|
-
`IHttpServerRequest`
|
|
86
|
-
|
|
87
|
-
The incoming request.
|
|
88
|
-
|
|
89
|
-
##### response
|
|
90
|
-
|
|
91
|
-
`IHttpResponse`
|
|
92
|
-
|
|
93
|
-
The outgoing response.
|
|
94
|
-
|
|
95
|
-
##### route
|
|
96
|
-
|
|
97
|
-
`IBaseRoute` \| `undefined`
|
|
98
|
-
|
|
99
|
-
The route to process.
|
|
100
|
-
|
|
101
|
-
##### contextIds
|
|
102
|
-
|
|
103
|
-
`IContextIds`
|
|
104
|
-
|
|
105
|
-
The context IDs of the request.
|
|
106
|
-
|
|
107
|
-
##### processorState
|
|
108
|
-
|
|
109
|
-
The state handed through the processors.
|
|
110
|
-
|
|
111
|
-
#### Returns
|
|
112
|
-
|
|
113
|
-
`Promise`\<`void`\>
|
|
114
|
-
|
|
115
|
-
A promise that resolves when the tenant override has been applied or skipped.
|
|
116
|
-
|
|
117
|
-
#### Implementation of
|
|
118
|
-
|
|
119
|
-
`IBaseRouteProcessor.pre`
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# Interface: ITenantOverrideProcessorConfig
|
|
2
|
-
|
|
3
|
-
Configuration for the TenantOverrideProcessor.
|
|
4
|
-
|
|
5
|
-
## Properties
|
|
6
|
-
|
|
7
|
-
### includeErrorStack? {#includeerrorstack}
|
|
8
|
-
|
|
9
|
-
> `optional` **includeErrorStack?**: `boolean`
|
|
10
|
-
|
|
11
|
-
Include the stack with errors.
|
|
12
|
-
|
|
13
|
-
***
|
|
14
|
-
|
|
15
|
-
### escalatedPrivilegeScope? {#escalatedprivilegescope}
|
|
16
|
-
|
|
17
|
-
> `optional` **escalatedPrivilegeScope?**: `string`
|
|
18
|
-
|
|
19
|
-
The scope value that grants escalated privilege for cross-tenant access. Defaults to "global-admin".
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# Interface: ITenantOverrideProcessorConstructorOptions
|
|
2
|
-
|
|
3
|
-
Options for the TenantOverrideProcessor constructor.
|
|
4
|
-
|
|
5
|
-
## Properties
|
|
6
|
-
|
|
7
|
-
### tenantAdminComponentType? {#tenantadmincomponenttype}
|
|
8
|
-
|
|
9
|
-
> `optional` **tenantAdminComponentType?**: `string`
|
|
10
|
-
|
|
11
|
-
The component used to resolve tenants, which also provides the lookup caching.
|
|
12
|
-
|
|
13
|
-
#### Default
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
tenant-admin
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
***
|
|
20
|
-
|
|
21
|
-
### config? {#config}
|
|
22
|
-
|
|
23
|
-
> `optional` **config?**: [`ITenantOverrideProcessorConfig`](ITenantOverrideProcessorConfig.md)
|
|
24
|
-
|
|
25
|
-
Configuration for the processor.
|