@cloudbase/manager-node 5.10.3 → 5.10.5
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 +8 -0
- package/changelog_content_en.md +2 -2
- package/jest.config.js +3 -1
- package/lib/deploy/FunctionDeployer.js +4 -1
- package/lib/env/index.js +61 -3
- package/lib/env/postgresql.js +14 -0
- package/lib/permission/index.js +84 -36
- package/package.json +1 -1
- package/types/deploy/FunctionDeployer.d.ts +4 -1
- package/types/env/index.d.ts +18 -1
- package/types/env/postgresql.d.ts +9 -0
- package/types/env/type.d.ts +94 -0
- package/types/permission/index.d.ts +47 -20
- package/types/permission/types.d.ts +25 -0
package/CHANGELOG.md
CHANGED
package/changelog_content_en.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
## [5.10.
|
|
1
|
+
## [5.10.4] 2026-11-11
|
|
2
2
|
|
|
3
|
-
- [Added] [TODO: translate]
|
|
3
|
+
- [Added] [TODO: translate] permission: 补齐网关鉴权引擎查询与策略清空能力
|
package/jest.config.js
CHANGED
|
@@ -16,7 +16,9 @@ module.exports = {
|
|
|
16
16
|
// MySQL 集成测试依赖账号的 MySQL 开通白名单与 cynosdb 操作权限:
|
|
17
17
|
// 流水线账号调 createMySQL 返回「操作不支持,当前用户不在 MySQL 开通白名单内」,
|
|
18
18
|
// 属环境权限缺失而非代码缺陷,故整体跳过(本地需验证时用 --testPathIgnorePatterns 覆盖)
|
|
19
|
-
'test/mysql/.*\\.test\\.ts$'
|
|
19
|
+
'test/mysql/.*\\.test\\.ts$',
|
|
20
|
+
// 环境访问控制集成测试依赖企业版环境,流水线账号无企业版权限,默认跳过
|
|
21
|
+
'test/env/access-control\\.test\\.ts$'
|
|
20
22
|
],
|
|
21
23
|
// https://github.com/facebook/jest/issues/5164
|
|
22
24
|
globalSetup: './test/global-setup-hook.ts',
|
|
@@ -83,7 +83,10 @@ class FunctionDeployer {
|
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
85
|
* 配置 HTTP 函数匿名访问(public=true)
|
|
86
|
-
*
|
|
86
|
+
*
|
|
87
|
+
* 读改写 authz.user.rego 后整体覆盖写回,追加放通规则并保留已有规则内容。
|
|
88
|
+
* 规则仅在 authz_engine=opa 的环境生效,authpolicy 环境仍以网关策略条目为准。
|
|
89
|
+
* ⚠️ 整体覆盖写该 key,与并发部署或手工改策略同时发生会丢写。
|
|
87
90
|
*/
|
|
88
91
|
async ensurePublicAccess(functionName) {
|
|
89
92
|
const permissionService = this.environment.getPermissionService();
|
package/lib/env/index.js
CHANGED
|
@@ -20,6 +20,7 @@ const constant_1 = require("../constant");
|
|
|
20
20
|
const storage_config_1 = require("../utils/storage-config");
|
|
21
21
|
const billing_1 = require("../billing");
|
|
22
22
|
const uuid_1 = require("uuid");
|
|
23
|
+
const postgresql_1 = require("./postgresql");
|
|
23
24
|
class EnvService {
|
|
24
25
|
constructor(environment) {
|
|
25
26
|
this.environment = environment;
|
|
@@ -212,10 +213,9 @@ class EnvService {
|
|
|
212
213
|
* @returns 是否为 PG 环境
|
|
213
214
|
*/
|
|
214
215
|
async isPostgresqlEnv() {
|
|
215
|
-
var _a
|
|
216
|
+
var _a;
|
|
216
217
|
const response = await this.describeEnvInfo({ EnvId: this.envId });
|
|
217
|
-
|
|
218
|
-
return Array.isArray(postgresql) && postgresql.length > 0;
|
|
218
|
+
return (0, postgresql_1.isPostgresqlBaseInfo)((_a = response === null || response === void 0 ? void 0 : response.EnvInfo) === null || _a === void 0 ? void 0 : _a.EnvBaseInfo);
|
|
219
219
|
}
|
|
220
220
|
/**
|
|
221
221
|
* 修改环境名称
|
|
@@ -919,6 +919,64 @@ class EnvService {
|
|
|
919
919
|
Domain
|
|
920
920
|
});
|
|
921
921
|
}
|
|
922
|
+
/**
|
|
923
|
+
* 查询环境访问控制配置(域名来源)
|
|
924
|
+
* 返回指定环境下默认域名在公网(PUBLIC)、VPC、办公网(WOA)三种来源的当前访问策略
|
|
925
|
+
* @param {DescribeEnvAccessControlParams} params 查询参数
|
|
926
|
+
* @returns {Promise<DescribeEnvAccessControlRes>} 当前生效的配置
|
|
927
|
+
*/
|
|
928
|
+
async describeEnvAccessControl(params = {}) {
|
|
929
|
+
const EnvId = params.EnvId || this.envId;
|
|
930
|
+
if (!EnvId) {
|
|
931
|
+
(0, error_1.throwInvalidParam)('EnvId is required');
|
|
932
|
+
}
|
|
933
|
+
return this.cloudService.request('DescribeEnvAccessControl', {
|
|
934
|
+
EnvId
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* 修改环境访问控制配置(域名来源)
|
|
939
|
+
* 影响指定环境下默认域名的访问来源策略,Action 为 OPEN 放通、CLOSE 拦截:
|
|
940
|
+
* - SourceType = PUBLIC 时,控制公网请求(拦截后公网访问默认域名返回 403)
|
|
941
|
+
* - SourceType = VPC 时,可选通过 VPCWhiteList 配置 VPC 白名单,不传表示不修改
|
|
942
|
+
* 各来源是否可改以服务端为准,WX(微信)与 WOA(办公网)为产品内部来源,后端暂未开放
|
|
943
|
+
* @param {ModifyEnvAccessControlParams} params 修改参数
|
|
944
|
+
* @returns {Promise<ModifyEnvAccessControlRes>} 影响行数与修改后生效的配置
|
|
945
|
+
*/
|
|
946
|
+
async modifyEnvAccessControl(params) {
|
|
947
|
+
const { EnvId = this.envId, Sources } = params;
|
|
948
|
+
if (!EnvId) {
|
|
949
|
+
(0, error_1.throwInvalidParam)('EnvId is required');
|
|
950
|
+
}
|
|
951
|
+
if (!Array.isArray(Sources) || Sources.length === 0) {
|
|
952
|
+
(0, error_1.throwInvalidParam)('Sources is required and must be a non-empty array');
|
|
953
|
+
}
|
|
954
|
+
// 校验 Sources 内部字段的合法性
|
|
955
|
+
const validActions = ['OPEN', 'CLOSE'];
|
|
956
|
+
const validWoAAuths = ['FORCE_AUTH', 'NO_AUTH'];
|
|
957
|
+
for (const source of Sources) {
|
|
958
|
+
if (!source) {
|
|
959
|
+
(0, error_1.throwInvalidParam)('Sources must not contain empty item');
|
|
960
|
+
}
|
|
961
|
+
if (source.Action !== undefined && !validActions.includes(source.Action)) {
|
|
962
|
+
(0, error_1.throwInvalidParam)(`Action must be one of ${validActions.join(' | ')}`);
|
|
963
|
+
}
|
|
964
|
+
if (source.WOAAuth !== undefined && !validWoAAuths.includes(source.WOAAuth)) {
|
|
965
|
+
(0, error_1.throwInvalidParam)(`WOAAuth must be one of ${validWoAAuths.join(' | ')}`);
|
|
966
|
+
}
|
|
967
|
+
// WOAAuth 仅 SourceType 为 WOA 且 Action 为 OPEN 时生效,强制鉴权时必须传 AuthToken
|
|
968
|
+
if (source.SourceType === 'WOA' &&
|
|
969
|
+
source.Action === 'OPEN' &&
|
|
970
|
+
source.WOAAuth === 'FORCE_AUTH' &&
|
|
971
|
+
!source.AuthToken) {
|
|
972
|
+
(0, error_1.throwInvalidParam)('AuthToken is required when WOAAuth is FORCE_AUTH');
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
return this.cloudService.request('ModifyEnvAccessControl', {
|
|
976
|
+
EnvId,
|
|
977
|
+
Sources
|
|
978
|
+
});
|
|
979
|
+
}
|
|
922
980
|
// 获取 COS CORS 域名
|
|
923
981
|
async getCOSDomains() {
|
|
924
982
|
const cos = this.getCos();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isPostgresqlBaseInfo = isPostgresqlBaseInfo;
|
|
4
|
+
/**
|
|
5
|
+
* 判断环境基础信息是否属于 PostgreSQL 环境
|
|
6
|
+
* PostgreSQL 字段为数组且长度 > 0 时视为 PG 环境。
|
|
7
|
+
*
|
|
8
|
+
* 抽成纯函数供 EnvService 与 PermissionService 共用,避免两处各写一份判断而漂移。
|
|
9
|
+
* 放在独立叶子模块中(只依赖类型),避免 permission 反向 import 整个 env 造成循环依赖。
|
|
10
|
+
*/
|
|
11
|
+
function isPostgresqlBaseInfo(baseInfo) {
|
|
12
|
+
const postgresql = baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.PostgreSQL;
|
|
13
|
+
return Array.isArray(postgresql) && postgresql.length > 0;
|
|
14
|
+
}
|
package/lib/permission/index.js
CHANGED
|
@@ -7,6 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.PermissionService = void 0;
|
|
10
|
+
const postgresql_1 = require("../env/postgresql");
|
|
10
11
|
const utils_1 = require("../utils");
|
|
11
12
|
const error_1 = require("../error");
|
|
12
13
|
const PERMISSION_BY_RESOURCE = {
|
|
@@ -22,7 +23,8 @@ class PermissionService {
|
|
|
22
23
|
this.lowcodeService = new utils_1.CloudService(environment.cloudBaseContext, 'lowcode', '2021-01-08');
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
|
-
* @deprecated
|
|
26
|
+
* @deprecated 已废弃:authz_engine=opa 的环境改由 rego 策略鉴权,网关策略条目不参与决策;
|
|
27
|
+
* 该环境请用 modifyEnvAuthzConfig,authpolicy 环境仍以网关策略为准
|
|
26
28
|
*/
|
|
27
29
|
async modifyResourcePermission(options) {
|
|
28
30
|
const { EnvId } = this.environment.lazyEnvironmentConfig;
|
|
@@ -57,7 +59,8 @@ class PermissionService {
|
|
|
57
59
|
return this.tcbService.request('ModifyResourcePermission', reqData);
|
|
58
60
|
}
|
|
59
61
|
/**
|
|
60
|
-
* @deprecated
|
|
62
|
+
* @deprecated 已废弃:authz_engine=opa 的环境改由 rego 策略鉴权,网关策略条目不参与决策;
|
|
63
|
+
* 查询存量网关策略用 describeResourcePolicyList,查询实际生效的 rego 策略用 describeEnvAuthzConfig
|
|
61
64
|
*/
|
|
62
65
|
async describeResourcePermission(options) {
|
|
63
66
|
const { EnvId } = this.environment.lazyEnvironmentConfig;
|
|
@@ -302,30 +305,56 @@ class PermissionService {
|
|
|
302
305
|
RoleIds: roleIds
|
|
303
306
|
});
|
|
304
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
* 查询环境实际生效的鉴权引擎
|
|
310
|
+
*
|
|
311
|
+
* 只发一次 DescribeEnvInfo,同时产出 PostgreSQL 与 Meta.authz_engine 两个结论,
|
|
312
|
+
* 调用方无需自行解析环境 Meta。
|
|
313
|
+
*
|
|
314
|
+
* 注意:不做缓存 —— 引擎由环境 Meta 的 authz_engine 决定,可能在运行期被切换,
|
|
315
|
+
* 缓存会让切换后的查询拿到过期结论。
|
|
316
|
+
*/
|
|
317
|
+
async describeAuthzProfile() {
|
|
318
|
+
var _a;
|
|
319
|
+
const baseInfo = await this.getEnvBaseInfo();
|
|
320
|
+
const isPostgresql = (0, postgresql_1.isPostgresqlBaseInfo)(baseInfo);
|
|
321
|
+
const authzEngineMeta = Array.isArray(baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.Meta)
|
|
322
|
+
? (_a = baseInfo.Meta.find(tag => tag.Key === 'authz_engine')) === null || _a === void 0 ? void 0 : _a.Value
|
|
323
|
+
: undefined;
|
|
324
|
+
return {
|
|
325
|
+
// PG 环境不存在旧网关策略,统一视为 opa,避免与短路行为自相矛盾
|
|
326
|
+
engine: isPostgresql || authzEngineMeta === 'opa' ? 'opa' : 'authpolicy',
|
|
327
|
+
isPostgresql,
|
|
328
|
+
authzEngineMeta
|
|
329
|
+
};
|
|
330
|
+
}
|
|
305
331
|
/**
|
|
306
332
|
* 拉取环境下的所有用户自定义的网关鉴权策略列表
|
|
307
|
-
*
|
|
308
|
-
*
|
|
333
|
+
*
|
|
334
|
+
* 以下两种环境不会发起请求,直接按空列表处理,并在返回值顶层给出 SkippedReason:
|
|
335
|
+
* - PG 环境:无存量网关策略(postgresql_env)
|
|
336
|
+
* - authz_engine 为 opa:网关策略不生效(opa_authz_engine)
|
|
337
|
+
*
|
|
338
|
+
* ⚠️ SkippedReason 非空时,空列表**不代表「确实没有策略」**:
|
|
339
|
+
* 实际生效的策略请用 describeEnvAuthzConfig({ key: 'authz.user.rego' }) 查询。
|
|
309
340
|
*/
|
|
310
341
|
async describeResourcePolicyList(options = {}) {
|
|
311
342
|
const { resourceType } = options;
|
|
312
343
|
if (resourceType !== undefined && (typeof resourceType !== 'string' || resourceType.trim().length === 0)) {
|
|
313
344
|
(0, error_1.throwInvalidParam)('Invalid resourceType');
|
|
314
345
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
}
|
|
323
|
-
// authz_engine 为 opa 时网关策略不生效,无需调用,直接返回空策略列表
|
|
324
|
-
if (await this.isOpaAuthzEngine()) {
|
|
346
|
+
const profile = await this.describeAuthzProfile();
|
|
347
|
+
const skippedReason = profile.isPostgresql
|
|
348
|
+
? 'postgresql_env'
|
|
349
|
+
: profile.engine === 'opa'
|
|
350
|
+
? 'opa_authz_engine'
|
|
351
|
+
: undefined;
|
|
352
|
+
if (skippedReason) {
|
|
325
353
|
const emptyData = { PolicyList: [], Total: '0' };
|
|
326
354
|
return {
|
|
327
355
|
Data: emptyData,
|
|
328
|
-
RequestId: ''
|
|
356
|
+
RequestId: '',
|
|
357
|
+
SkippedReason: skippedReason
|
|
329
358
|
};
|
|
330
359
|
}
|
|
331
360
|
const { EnvId } = this.environment.lazyEnvironmentConfig;
|
|
@@ -339,20 +368,30 @@ class PermissionService {
|
|
|
339
368
|
* 拉取环境下的鉴权策略配置
|
|
340
369
|
* key: authz.platform.extension.rego - 单独为该环境配置的策略
|
|
341
370
|
* key: authz.user.rego - 用户配置的策略
|
|
371
|
+
*
|
|
372
|
+
* 未配置时云端不返回 Item(或返回空对象),此处统一归一化为 Key/Value 均为空串,
|
|
373
|
+
* 调用方无需再判空。
|
|
342
374
|
*/
|
|
343
375
|
async describeEnvAuthzConfig(options) {
|
|
376
|
+
var _a, _b;
|
|
344
377
|
const { key } = options;
|
|
345
378
|
if (!key || (key !== 'authz.platform.extension.rego' && key !== 'authz.user.rego')) {
|
|
346
379
|
(0, error_1.throwInvalidParam)('key must be "authz.platform.extension.rego" or "authz.user.rego"');
|
|
347
380
|
}
|
|
348
381
|
const { EnvId } = this.environment.lazyEnvironmentConfig;
|
|
349
|
-
|
|
382
|
+
const res = await this.tcbService.request('DescribeEnvConfig', {
|
|
350
383
|
EnvId,
|
|
351
384
|
Key: key
|
|
352
385
|
});
|
|
386
|
+
return Object.assign(Object.assign({}, res), { Item: {
|
|
387
|
+
Key: ((_a = res === null || res === void 0 ? void 0 : res.Item) === null || _a === void 0 ? void 0 : _a.Key) || '',
|
|
388
|
+
Value: ((_b = res === null || res === void 0 ? void 0 : res.Item) === null || _b === void 0 ? void 0 : _b.Value) || ''
|
|
389
|
+
} });
|
|
353
390
|
}
|
|
354
391
|
/**
|
|
355
|
-
* 保存用户编写的 rego
|
|
392
|
+
* 保存用户编写的 rego 策略(authz.user.rego)
|
|
393
|
+
*
|
|
394
|
+
* 仅在 authz_engine=opa 的环境参与鉴权;authpolicy 环境仍以网关策略条目为准。
|
|
356
395
|
*/
|
|
357
396
|
async modifyEnvAuthzConfig(options) {
|
|
358
397
|
const { EnvId } = this.environment.lazyEnvironmentConfig;
|
|
@@ -369,6 +408,28 @@ class PermissionService {
|
|
|
369
408
|
Value: value
|
|
370
409
|
});
|
|
371
410
|
}
|
|
411
|
+
/**
|
|
412
|
+
* 清空用户配置的 rego 策略(恢复「跟随平台默认」)
|
|
413
|
+
*
|
|
414
|
+
* 服务端语义:ModifyEnvConfig 的 Value 传空串 = 删除该 key。
|
|
415
|
+
* 单独提供本方法而不放宽 modifyEnvAuthzConfig 的空值校验 —— 后者会让
|
|
416
|
+
* 「变量未定义传了空串」静默清空生产策略,属高危误用。
|
|
417
|
+
*
|
|
418
|
+
* 注意:清空只删掉该 key,不会回退鉴权引擎 —— 环境 Meta 的 authz_engine
|
|
419
|
+
* 仍为 opa(已实测),旧网关鉴权策略不会因此复活。
|
|
420
|
+
*/
|
|
421
|
+
async clearEnvAuthzConfig(options) {
|
|
422
|
+
const { EnvId } = this.environment.lazyEnvironmentConfig;
|
|
423
|
+
const { key } = options;
|
|
424
|
+
if (key !== 'authz.user.rego') {
|
|
425
|
+
(0, error_1.throwInvalidParam)('key must be "authz.user.rego"');
|
|
426
|
+
}
|
|
427
|
+
return this.tcbService.request('ModifyEnvConfig', {
|
|
428
|
+
EnvId,
|
|
429
|
+
Key: key,
|
|
430
|
+
Value: ''
|
|
431
|
+
});
|
|
432
|
+
}
|
|
372
433
|
/**
|
|
373
434
|
* 获取完整的环境基础信息(含 PostgreSQL、Meta 等字段)
|
|
374
435
|
*/
|
|
@@ -379,25 +440,6 @@ class PermissionService {
|
|
|
379
440
|
const res = await this.environment.getEnvService().describeEnvInfo(params);
|
|
380
441
|
return ((_a = res === null || res === void 0 ? void 0 : res.EnvInfo) === null || _a === void 0 ? void 0 : _a.EnvBaseInfo) || {};
|
|
381
442
|
}
|
|
382
|
-
/**
|
|
383
|
-
* 判断当前环境是否为 PostgreSQL 环境
|
|
384
|
-
*/
|
|
385
|
-
async isPostgresqlEnv() {
|
|
386
|
-
return this.environment.getEnvService().isPostgresqlEnv();
|
|
387
|
-
}
|
|
388
|
-
/**
|
|
389
|
-
* 判断当前环境的 authz_engine 是否为 opa
|
|
390
|
-
* 从环境 Meta 中查找 Key 为 authz_engine 的标签,Value 为 opa 表示已切到 OPA
|
|
391
|
-
*/
|
|
392
|
-
async isOpaAuthzEngine() {
|
|
393
|
-
const envBaseInfo = await this.getEnvBaseInfo();
|
|
394
|
-
const meta = envBaseInfo === null || envBaseInfo === void 0 ? void 0 : envBaseInfo.Meta;
|
|
395
|
-
if (!Array.isArray(meta)) {
|
|
396
|
-
return false;
|
|
397
|
-
}
|
|
398
|
-
const authzEngineTag = meta.find(tag => tag.Key === 'authz_engine');
|
|
399
|
-
return (authzEngineTag === null || authzEngineTag === void 0 ? void 0 : authzEngineTag.Value) === 'opa';
|
|
400
|
-
}
|
|
401
443
|
}
|
|
402
444
|
exports.PermissionService = PermissionService;
|
|
403
445
|
__decorate([
|
|
@@ -418,6 +460,9 @@ __decorate([
|
|
|
418
460
|
__decorate([
|
|
419
461
|
(0, utils_1.preLazy)()
|
|
420
462
|
], PermissionService.prototype, "deleteRoles", null);
|
|
463
|
+
__decorate([
|
|
464
|
+
(0, utils_1.preLazy)()
|
|
465
|
+
], PermissionService.prototype, "describeAuthzProfile", null);
|
|
421
466
|
__decorate([
|
|
422
467
|
(0, utils_1.preLazy)()
|
|
423
468
|
], PermissionService.prototype, "describeResourcePolicyList", null);
|
|
@@ -427,3 +472,6 @@ __decorate([
|
|
|
427
472
|
__decorate([
|
|
428
473
|
(0, utils_1.preLazy)()
|
|
429
474
|
], PermissionService.prototype, "modifyEnvAuthzConfig", null);
|
|
475
|
+
__decorate([
|
|
476
|
+
(0, utils_1.preLazy)()
|
|
477
|
+
], PermissionService.prototype, "clearEnvAuthzConfig", null);
|
package/package.json
CHANGED
|
@@ -59,7 +59,10 @@ export declare class FunctionDeployer {
|
|
|
59
59
|
resolveStrategy(config: IFunctionDeployConfig): IFunctionDeployPlan['buildStrategy'];
|
|
60
60
|
/**
|
|
61
61
|
* 配置 HTTP 函数匿名访问(public=true)
|
|
62
|
-
*
|
|
62
|
+
*
|
|
63
|
+
* 读改写 authz.user.rego 后整体覆盖写回,追加放通规则并保留已有规则内容。
|
|
64
|
+
* 规则仅在 authz_engine=opa 的环境生效,authpolicy 环境仍以网关策略条目为准。
|
|
65
|
+
* ⚠️ 整体覆盖写该 key,与并发部署或手工改策略同时发生会丢写。
|
|
63
66
|
*/
|
|
64
67
|
ensurePublicAccess(functionName: string): Promise<void>;
|
|
65
68
|
/**
|
package/types/env/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Environment } from '../environment';
|
|
2
2
|
import { IResponseInfo, AuthDomain, EnvInfo, LoginConfigItem, ICheckTcbServiceRes, ICreatePostpayRes, EnvBillingInfoItem, PriceResult } from '../interfaces';
|
|
3
|
-
import { CalculatePackageCreatePriceParams, CalculatePackageRenewPriceParams, CalculatePackageModifyPriceParams, DescribeHttpServiceRouteParams, DescribeHttpServiceRouteRes, VerifyHttpServiceRouteParams, VerifyHttpServiceRouteRes, CreateHttpServiceRouteParams, CreateHttpServiceRouteRes, ModifyHttpServiceRouteParams, ModifyHttpServiceRouteRes, DeleteHttpServiceRouteParams, DeleteHttpServiceRouteRes, PurgeHttpServiceCacheParams, PurgeHttpServiceCacheRes, DescribeHttpServiceCachePurgeTaskParams, DescribeHttpServiceCachePurgeTaskRes, BindCustomDomainParams, BindCustomDomainRes, DeleteCustomDomainParams, DeleteCustomDomainRes, DescribeCertificatesParams, DescribeCertificatesRes } from './type';
|
|
3
|
+
import { CalculatePackageCreatePriceParams, CalculatePackageRenewPriceParams, CalculatePackageModifyPriceParams, DescribeHttpServiceRouteParams, DescribeHttpServiceRouteRes, VerifyHttpServiceRouteParams, VerifyHttpServiceRouteRes, CreateHttpServiceRouteParams, CreateHttpServiceRouteRes, ModifyHttpServiceRouteParams, ModifyHttpServiceRouteRes, DeleteHttpServiceRouteParams, DeleteHttpServiceRouteRes, PurgeHttpServiceCacheParams, PurgeHttpServiceCacheRes, DescribeHttpServiceCachePurgeTaskParams, DescribeHttpServiceCachePurgeTaskRes, BindCustomDomainParams, BindCustomDomainRes, DeleteCustomDomainParams, DeleteCustomDomainRes, DescribeCertificatesParams, DescribeCertificatesRes, ModifyEnvAccessControlParams, ModifyEnvAccessControlRes, DescribeEnvAccessControlParams, DescribeEnvAccessControlRes } from './type';
|
|
4
4
|
import { CreateBillingDealParams, CreateEnvParams, BaasPackageInfo, DescribeBaasPackageListParams, ModifyEnvPlanParams, RenewEnvParams, DestroyEnvParams, DescribeEnvsParams, DescribeEnvInfoParams, DescribeEnvInfoResponse, DescribeEnvAccountCircleParams, DescribeEnvAccountCircleRes, DescribeCreditsUsageDetailParams, DescribeCreditsUsageParams, DescribeCreditsUsageRes, EnvPkgCreditsUsage } from '../interfaces/tcb.interface';
|
|
5
5
|
type SOURCE = 'miniapp' | 'qcloud';
|
|
6
6
|
interface IDeleteDomainRes {
|
|
@@ -965,6 +965,23 @@ export declare class EnvService {
|
|
|
965
965
|
* @returns {Promise<DeleteCustomDomainRes>}
|
|
966
966
|
*/
|
|
967
967
|
deleteCustomDomain(params: DeleteCustomDomainParams): Promise<DeleteCustomDomainRes>;
|
|
968
|
+
/**
|
|
969
|
+
* 查询环境访问控制配置(域名来源)
|
|
970
|
+
* 返回指定环境下默认域名在公网(PUBLIC)、VPC、办公网(WOA)三种来源的当前访问策略
|
|
971
|
+
* @param {DescribeEnvAccessControlParams} params 查询参数
|
|
972
|
+
* @returns {Promise<DescribeEnvAccessControlRes>} 当前生效的配置
|
|
973
|
+
*/
|
|
974
|
+
describeEnvAccessControl(params?: DescribeEnvAccessControlParams): Promise<DescribeEnvAccessControlRes>;
|
|
975
|
+
/**
|
|
976
|
+
* 修改环境访问控制配置(域名来源)
|
|
977
|
+
* 影响指定环境下默认域名的访问来源策略,Action 为 OPEN 放通、CLOSE 拦截:
|
|
978
|
+
* - SourceType = PUBLIC 时,控制公网请求(拦截后公网访问默认域名返回 403)
|
|
979
|
+
* - SourceType = VPC 时,可选通过 VPCWhiteList 配置 VPC 白名单,不传表示不修改
|
|
980
|
+
* 各来源是否可改以服务端为准,WX(微信)与 WOA(办公网)为产品内部来源,后端暂未开放
|
|
981
|
+
* @param {ModifyEnvAccessControlParams} params 修改参数
|
|
982
|
+
* @returns {Promise<ModifyEnvAccessControlRes>} 影响行数与修改后生效的配置
|
|
983
|
+
*/
|
|
984
|
+
modifyEnvAccessControl(params: ModifyEnvAccessControlParams): Promise<ModifyEnvAccessControlRes>;
|
|
968
985
|
private getCOSDomains;
|
|
969
986
|
private modifyCosCorsDomain;
|
|
970
987
|
private getCos;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EnvBaseInfo } from '../interfaces/tcb.interface';
|
|
2
|
+
/**
|
|
3
|
+
* 判断环境基础信息是否属于 PostgreSQL 环境
|
|
4
|
+
* PostgreSQL 字段为数组且长度 > 0 时视为 PG 环境。
|
|
5
|
+
*
|
|
6
|
+
* 抽成纯函数供 EnvService 与 PermissionService 共用,避免两处各写一份判断而漂移。
|
|
7
|
+
* 放在独立叶子模块中(只依赖类型),避免 permission 反向 import 整个 env 造成循环依赖。
|
|
8
|
+
*/
|
|
9
|
+
export declare function isPostgresqlBaseInfo(baseInfo?: EnvBaseInfo): boolean;
|
package/types/env/type.d.ts
CHANGED
|
@@ -565,3 +565,97 @@ export interface DeleteCustomDomainParams {
|
|
|
565
565
|
export interface DeleteCustomDomainRes {
|
|
566
566
|
RequestId: string;
|
|
567
567
|
}
|
|
568
|
+
/**
|
|
569
|
+
* 访问来源类型
|
|
570
|
+
* - PUBLIC: 公网链路访问配置
|
|
571
|
+
* - VPC: VPC 链路访问配置
|
|
572
|
+
* - WX: 微信侧来源访问配置(产品内部来源,当前未对外开放,仅查询会返回)
|
|
573
|
+
* - WOA: 办公网链路访问配置(产品内部来源,当前未对外开放,仅查询会返回)
|
|
574
|
+
*/
|
|
575
|
+
export type EnvAccessSourceType = 'PUBLIC' | 'VPC' | 'WX' | 'WOA';
|
|
576
|
+
/**
|
|
577
|
+
* 开关动作
|
|
578
|
+
* - OPEN: 放通
|
|
579
|
+
* - CLOSE: 拦截
|
|
580
|
+
*/
|
|
581
|
+
export type EnvAccessControlAction = 'OPEN' | 'CLOSE';
|
|
582
|
+
/**
|
|
583
|
+
* 办公网(WOA)鉴权模式
|
|
584
|
+
* - FORCE_AUTH: 强制鉴权
|
|
585
|
+
* - NO_AUTH: 不鉴权
|
|
586
|
+
*/
|
|
587
|
+
export type EnvAccessWoAAuth = 'FORCE_AUTH' | 'NO_AUTH';
|
|
588
|
+
/**
|
|
589
|
+
* VPC 信息(对应数据结构 VPCInfo)
|
|
590
|
+
*/
|
|
591
|
+
export interface EnvAccessVpcItem {
|
|
592
|
+
UniqVpcId: string;
|
|
593
|
+
Region: string;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* VPC 白名单配置(对应数据结构 VPCWhiteListConfig)
|
|
597
|
+
* - Action = OPEN:开启白名单,VPCs 必填,覆盖写入
|
|
598
|
+
* - Action = CLOSE:关闭白名单,VPCs 填入时覆盖写入
|
|
599
|
+
*/
|
|
600
|
+
export interface EnvAccessVpcWhiteList {
|
|
601
|
+
Action?: EnvAccessControlAction;
|
|
602
|
+
VPCs?: EnvAccessVpcItem[];
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* 访问来源配置
|
|
606
|
+
* SourceType 决定实际生效的字段:
|
|
607
|
+
* - PUBLIC: 由 Action 控制公网请求放通/拦截
|
|
608
|
+
* - VPC: 由 Action 控制 VPC 请求放通/拦截,VPCWhiteList 控制白名单(不传表示不修改)
|
|
609
|
+
* - WOA / WX: 产品内部来源,后端暂未开放修改
|
|
610
|
+
*/
|
|
611
|
+
export interface EnvAccessSourceSetting {
|
|
612
|
+
SourceType: EnvAccessSourceType;
|
|
613
|
+
Action?: EnvAccessControlAction;
|
|
614
|
+
WOAAuth?: EnvAccessWoAAuth;
|
|
615
|
+
AuthToken?: string;
|
|
616
|
+
VPCWhiteList?: EnvAccessVpcWhiteList;
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* 当前生效的访问来源配置(DescribeEnvAccessControl / ModifyEnvAccessControl 的 Current)
|
|
620
|
+
* 未配置的枚举字段接口会返回空字符串,VPCWhiteList 也可能为 null,故此处按返回值放宽
|
|
621
|
+
*/
|
|
622
|
+
export type EnvAccessCurrentSetting = Array<{
|
|
623
|
+
SourceType: EnvAccessSourceType;
|
|
624
|
+
Action?: string;
|
|
625
|
+
WOAAuth?: string;
|
|
626
|
+
AuthToken?: string;
|
|
627
|
+
VPCWhiteList?: {
|
|
628
|
+
Action?: string;
|
|
629
|
+
VPCs?: EnvAccessVpcItem[] | null;
|
|
630
|
+
} | null;
|
|
631
|
+
}>;
|
|
632
|
+
/**
|
|
633
|
+
* DescribeEnvAccessControl 请求参数
|
|
634
|
+
* 查询环境的默认域名访问来源策略(公网、VPC、办公网)
|
|
635
|
+
*/
|
|
636
|
+
export interface DescribeEnvAccessControlParams {
|
|
637
|
+
EnvId?: string;
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* DescribeEnvAccessControl 返回结果
|
|
641
|
+
*/
|
|
642
|
+
export interface DescribeEnvAccessControlRes {
|
|
643
|
+
Current: EnvAccessCurrentSetting;
|
|
644
|
+
RequestId: string;
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* ModifyEnvAccessControl 请求参数
|
|
648
|
+
* 修改环境的默认域名访问来源策略(公网开关、VPC 白名单、办公网鉴权)
|
|
649
|
+
*/
|
|
650
|
+
export interface ModifyEnvAccessControlParams {
|
|
651
|
+
EnvId?: string;
|
|
652
|
+
Sources: EnvAccessSourceSetting[];
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* ModifyEnvAccessControl 返回结果
|
|
656
|
+
*/
|
|
657
|
+
export interface ModifyEnvAccessControlRes {
|
|
658
|
+
AffectedRows: number;
|
|
659
|
+
Current: EnvAccessCurrentSetting;
|
|
660
|
+
RequestId: string;
|
|
661
|
+
}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { Environment } from '../environment';
|
|
2
|
-
import { ModifyResourcePermissionOptions, ModifyResourcePermissionResp, DescribeResourcePermissionOptions, DescribeResourcePermissionResp, CreateRoleOptions, CreateRoleResp, DescribeRoleListOptions, DescribeRoleListResp, ModifyRoleOptions, ModifyRoleResp, DeleteRolesOptions, DeleteRolesResp, DescribeResourcePolicyListOptions,
|
|
2
|
+
import { ModifyResourcePermissionOptions, ModifyResourcePermissionResp, DescribeResourcePermissionOptions, DescribeResourcePermissionResp, CreateRoleOptions, CreateRoleResp, DescribeRoleListOptions, DescribeRoleListResp, ModifyRoleOptions, ModifyRoleResp, DeleteRolesOptions, DeleteRolesResp, DescribeResourcePolicyListOptions, DescribeResourcePolicyListResult, DescribeEnvAuthzConfigOptions, ModifyEnvAuthzConfigOptions, ClearEnvAuthzConfigOptions, AuthzProfile } from './types';
|
|
3
3
|
export declare class PermissionService {
|
|
4
4
|
private environment;
|
|
5
5
|
private tcbService;
|
|
6
6
|
private lowcodeService;
|
|
7
7
|
constructor(environment: Environment);
|
|
8
8
|
/**
|
|
9
|
-
* @deprecated
|
|
9
|
+
* @deprecated 已废弃:authz_engine=opa 的环境改由 rego 策略鉴权,网关策略条目不参与决策;
|
|
10
|
+
* 该环境请用 modifyEnvAuthzConfig,authpolicy 环境仍以网关策略为准
|
|
10
11
|
*/
|
|
11
12
|
modifyResourcePermission(options: ModifyResourcePermissionOptions): Promise<{
|
|
12
13
|
Data: ModifyResourcePermissionResp;
|
|
13
14
|
RequestId: string;
|
|
14
15
|
}>;
|
|
15
16
|
/**
|
|
16
|
-
* @deprecated
|
|
17
|
+
* @deprecated 已废弃:authz_engine=opa 的环境改由 rego 策略鉴权,网关策略条目不参与决策;
|
|
18
|
+
* 查询存量网关策略用 describeResourcePolicyList,查询实际生效的 rego 策略用 describeEnvAuthzConfig
|
|
17
19
|
*/
|
|
18
20
|
describeResourcePermission(options: DescribeResourcePermissionOptions): Promise<{
|
|
19
21
|
Data: DescribeResourcePermissionResp;
|
|
@@ -35,42 +37,67 @@ export declare class PermissionService {
|
|
|
35
37
|
Data: DeleteRolesResp;
|
|
36
38
|
RequestId: string;
|
|
37
39
|
}>;
|
|
40
|
+
/**
|
|
41
|
+
* 查询环境实际生效的鉴权引擎
|
|
42
|
+
*
|
|
43
|
+
* 只发一次 DescribeEnvInfo,同时产出 PostgreSQL 与 Meta.authz_engine 两个结论,
|
|
44
|
+
* 调用方无需自行解析环境 Meta。
|
|
45
|
+
*
|
|
46
|
+
* 注意:不做缓存 —— 引擎由环境 Meta 的 authz_engine 决定,可能在运行期被切换,
|
|
47
|
+
* 缓存会让切换后的查询拿到过期结论。
|
|
48
|
+
*/
|
|
49
|
+
describeAuthzProfile(): Promise<AuthzProfile>;
|
|
38
50
|
/**
|
|
39
51
|
* 拉取环境下的所有用户自定义的网关鉴权策略列表
|
|
40
|
-
*
|
|
41
|
-
*
|
|
52
|
+
*
|
|
53
|
+
* 以下两种环境不会发起请求,直接按空列表处理,并在返回值顶层给出 SkippedReason:
|
|
54
|
+
* - PG 环境:无存量网关策略(postgresql_env)
|
|
55
|
+
* - authz_engine 为 opa:网关策略不生效(opa_authz_engine)
|
|
56
|
+
*
|
|
57
|
+
* ⚠️ SkippedReason 非空时,空列表**不代表「确实没有策略」**:
|
|
58
|
+
* 实际生效的策略请用 describeEnvAuthzConfig({ key: 'authz.user.rego' }) 查询。
|
|
42
59
|
*/
|
|
43
|
-
describeResourcePolicyList(options?: DescribeResourcePolicyListOptions): Promise<
|
|
44
|
-
Data: DescribeResourcePolicyListResp;
|
|
45
|
-
RequestId: string;
|
|
46
|
-
}>;
|
|
60
|
+
describeResourcePolicyList(options?: DescribeResourcePolicyListOptions): Promise<DescribeResourcePolicyListResult>;
|
|
47
61
|
/**
|
|
48
62
|
* 拉取环境下的鉴权策略配置
|
|
49
63
|
* key: authz.platform.extension.rego - 单独为该环境配置的策略
|
|
50
64
|
* key: authz.user.rego - 用户配置的策略
|
|
65
|
+
*
|
|
66
|
+
* 未配置时云端不返回 Item(或返回空对象),此处统一归一化为 Key/Value 均为空串,
|
|
67
|
+
* 调用方无需再判空。
|
|
51
68
|
*/
|
|
52
69
|
describeEnvAuthzConfig(options: DescribeEnvAuthzConfigOptions): Promise<{
|
|
53
|
-
Item:
|
|
70
|
+
Item: {
|
|
71
|
+
Key: string;
|
|
72
|
+
Value: string;
|
|
73
|
+
};
|
|
54
74
|
RequestId: string;
|
|
55
75
|
}>;
|
|
56
76
|
/**
|
|
57
|
-
* 保存用户编写的 rego
|
|
77
|
+
* 保存用户编写的 rego 策略(authz.user.rego)
|
|
78
|
+
*
|
|
79
|
+
* 仅在 authz_engine=opa 的环境参与鉴权;authpolicy 环境仍以网关策略条目为准。
|
|
58
80
|
*/
|
|
59
81
|
modifyEnvAuthzConfig(options: ModifyEnvAuthzConfigOptions): Promise<{
|
|
60
82
|
AffectedRows: number;
|
|
61
83
|
RequestId: string;
|
|
62
84
|
}>;
|
|
63
85
|
/**
|
|
64
|
-
*
|
|
86
|
+
* 清空用户配置的 rego 策略(恢复「跟随平台默认」)
|
|
87
|
+
*
|
|
88
|
+
* 服务端语义:ModifyEnvConfig 的 Value 传空串 = 删除该 key。
|
|
89
|
+
* 单独提供本方法而不放宽 modifyEnvAuthzConfig 的空值校验 —— 后者会让
|
|
90
|
+
* 「变量未定义传了空串」静默清空生产策略,属高危误用。
|
|
91
|
+
*
|
|
92
|
+
* 注意:清空只删掉该 key,不会回退鉴权引擎 —— 环境 Meta 的 authz_engine
|
|
93
|
+
* 仍为 opa(已实测),旧网关鉴权策略不会因此复活。
|
|
65
94
|
*/
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
private isPostgresqlEnv;
|
|
95
|
+
clearEnvAuthzConfig(options: ClearEnvAuthzConfigOptions): Promise<{
|
|
96
|
+
AffectedRows: number;
|
|
97
|
+
RequestId: string;
|
|
98
|
+
}>;
|
|
71
99
|
/**
|
|
72
|
-
*
|
|
73
|
-
* 从环境 Meta 中查找 Key 为 authz_engine 的标签,Value 为 opa 表示已切到 OPA
|
|
100
|
+
* 获取完整的环境基础信息(含 PostgreSQL、Meta 等字段)
|
|
74
101
|
*/
|
|
75
|
-
private
|
|
102
|
+
private getEnvBaseInfo;
|
|
76
103
|
}
|
|
@@ -145,6 +145,18 @@ export interface DescribeResourcePolicyListResp {
|
|
|
145
145
|
PolicyList: ResourcePolicyItem[];
|
|
146
146
|
Total: string;
|
|
147
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* describeResourcePolicyList 未发起请求的原因
|
|
150
|
+
* - postgresql_env:PG 环境无存量网关策略
|
|
151
|
+
* - opa_authz_engine:环境已切到 OPA 引擎,旧网关策略不参与鉴权
|
|
152
|
+
*/
|
|
153
|
+
export type ResourcePolicyListSkippedReason = 'postgresql_env' | 'opa_authz_engine';
|
|
154
|
+
export interface DescribeResourcePolicyListResult {
|
|
155
|
+
Data: DescribeResourcePolicyListResp;
|
|
156
|
+
RequestId: string;
|
|
157
|
+
/** 本次未发起请求的原因;缺省表示真实查询结果 */
|
|
158
|
+
SkippedReason?: ResourcePolicyListSkippedReason;
|
|
159
|
+
}
|
|
148
160
|
export interface DescribeEnvAuthzConfigOptions {
|
|
149
161
|
key: 'authz.platform.extension.rego' | 'authz.user.rego';
|
|
150
162
|
}
|
|
@@ -159,3 +171,16 @@ export interface ModifyEnvAuthzConfigOptions {
|
|
|
159
171
|
export interface ModifyEnvAuthzConfigResp {
|
|
160
172
|
AffectedRows: number;
|
|
161
173
|
}
|
|
174
|
+
export interface ClearEnvAuthzConfigOptions {
|
|
175
|
+
key: 'authz.user.rego';
|
|
176
|
+
}
|
|
177
|
+
/** 网关鉴权引擎 */
|
|
178
|
+
export type AuthzEngine = 'authpolicy' | 'opa';
|
|
179
|
+
export interface AuthzProfile {
|
|
180
|
+
/** 实际生效的鉴权引擎(PG 环境一律视为 opa) */
|
|
181
|
+
engine: AuthzEngine;
|
|
182
|
+
/** 是否为 PostgreSQL 环境 */
|
|
183
|
+
isPostgresql: boolean;
|
|
184
|
+
/** Meta 中 authz_engine 的原始取值,便于排查 */
|
|
185
|
+
authzEngineMeta?: string;
|
|
186
|
+
}
|