Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 提供账号查询、创建、删除的APIGW接口 #2472 #2495

Merged
merged 3 commits into from
Oct 12, 2023

Conversation

jsonwan
Copy link
Collaborator

@jsonwan jsonwan commented Oct 10, 2023

增加接口文档

@jsonwan jsonwan force-pushed the github_feat/account branch from 7d64856 to 089672a Compare October 12, 2023 02:04
@jsonwan jsonwan force-pushed the github_feat/account branch from 089672a to e5b0a5e Compare October 12, 2023 02:14
| alias | string | 账号别名 |
| category | int | 账号用途(1:系统账号) |
| type | int | 账号类型(1:Linux,2:Windows)|
| db_system_account_id | long | 账号用途为数据库账号时该字段生效,表示数据库账号对应的系统账号ID |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个先去掉,这个 API 暂时还不支持 DB 账号的话

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已去除

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -62,3 +62,10 @@ validation.constraints.InvalidFileUploadSettingAmount.message=文件大小只能
validation.constraints.InvalidPort.message=端口号只能为1-65535之间的整数
validation.constraints.NotContainSpecialChar.message=不可包含 \\|/:*<>"? 特殊字符
validation.constraints.NotBlankField.message=不能为空
validation.constraints.AccountId_empty.message=账号ID不能为空
validation.constraints.AccountName_empty.message=账号名称[account]不能为空
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不建议在错误提示里边加入字段信息。

  1. 这个报错是给用户看的
  2. 关于字段校验报错的提示优化,后续在 API 整改的时候会按照蓝鲸新版规范,放到 details 里边,给开发看
{
    "error": {
        "code": "AuthFailure",
        "message": "The provided credentials could not be validated. Please check your signature is correct.",
        "system": "bkiam",
        "details": [{
            "code": "SignatureFailure",
            "message": "",
            # 其他字段, 不强制,可自由扩展(有助于定位问题/解决问题就行)
            "module": "auth",
            "links": "",
            "doc": ""
        }],
        "data": {}
    }
}
  1. 会导致报错信息不通用。比如 web/esb 的 API 可能用的是不同的字段名,但是在校验字段的时候却需要共享同一个报错信息

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@RequestHeader(value = JobCommonHeaders.APP_CODE) String appCode,
@RequestParam(value = "bk_scope_type", required = false) String scopeType,
@RequestParam(value = "bk_scope_id", required = false) String scopeId,
@RequestParam(value = "id") Long id
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete + query param 的设计比较奇怪。要不直接就使用标准的 DELETE /account/{accountID}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -65,4 +68,39 @@ EsbResp<EsbPageDataV3<EsbAccountV3DTO>> getAccountList(
@RequestParam(value = "start", required = false) Integer start,
@RequestParam(value = "length", required = false) Integer length);

@GetMapping("/search_account")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是不是直接扩展 get_account_list 就可以了?get_account_list 也是分页检索账号功能

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

/**
* 账号用途:1-系统账号,2-数据库账号
*/
@NotNull(message = "{validation.constraints.AccountCategory_empty.message}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有对类型的值进行校验。可以使用 @CheckEnum

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

* 账号类型:1-Linux,2-Windows,9-Mysql,10-Oracle,11-DB2
*/
@NotNull(message = "{validation.constraints.AccountType_empty.message}")
private Integer type;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有对类型的值进行校验。可以使用 @CheckEnum

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

* 帐号名称
*/
@NotEmpty(message = "{validation.constraints.AccountName_empty.message}")
private String account;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

账号长度是否有限制?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

具体规则在业务逻辑中根据账号命名规则校验。

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

/**
* 是否有权限使用
*/
@JsonProperty("can_use")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can_use 这个字段比较局限;建议改成 allow_action_ids = [use_account] 这种,后续其他的资源也可以统一。而且把预鉴权放到资源对象里边设计上也有点奇怪,看下是否有更好的方案

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已去除。

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@jsonwan jsonwan force-pushed the github_feat/account branch from e909183 to a50d4b1 Compare October 12, 2023 08:25
@jsonwan jsonwan force-pushed the github_feat/account branch from a50d4b1 to f62e4d3 Compare October 12, 2023 08:29
@wangyu096 wangyu096 merged commit cd6462a into TencentBlueKing:master Oct 12, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants