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

[ISSUE #70] The rocketmq-dashboard supports ACL configuration #71

Merged
merged 8 commits into from
Mar 5, 2022

Conversation

xxd763795151
Copy link
Contributor

@xxd763795151 xxd763795151 commented Jan 30, 2022

What is the purpose of the change

#70

The rocketmq-dashboard supports ACL configuration, such as following:
image
Or
image

Feature descirbe:

  • the 'CRUD operation' of topic permission for an accessKey
  • the 'CRUD operation' of group permission for an accessKey
  • add/delete host white list
  • the acl info can be synchronized in the cluster from a broker to all broker when it is inconsistent(Why it may be inconsistent? For example, the acl info is add by manual in all brokers, one broker config error or forget to config; when we config acl, one broker is down in the cluster.)

**Note: the Acl menu only appears when the accessKey and secretKey is not empty in the application.yml. **

By the way, the last topic or group permission can not be deleted if there is only one topic or group permission for an access key because of the rocketmq`s implemention.

Brief changelog

XXXX

Verifying this change

XXXX

Follow this checklist to help us incorporate your contribution quickly and easily. Notice, it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR.

  • Make sure there is a Github issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test(over 80% coverage) to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in test module.
  • Run mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle to make sure basic checks pass. Run mvn clean install -DskipITs to make sure unit-test pass. Run mvn clean test-compile failsafe:integration-test to make sure integration-test pass.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

@xxd763795151
Copy link
Contributor Author

Sorry, I forget unit tests. I need spend a little time to add some unit tests.

@StyleTang
Copy link
Member

@xxd763795151
Thanks for your contribution, I have some urgent things to do recently, will review your PR later.

@vongosling
Copy link
Member

Security key should be hidden by asterisks :-)

@vongosling
Copy link
Member

NIce job ~~~ I'd like to add another reviewer @zhangjidi2016 for this feature :-)


@PostMapping("/add.do")
public Object addAclConfig(@RequestBody PlainAccessConfig config) {
Preconditions.checkArgument(config.getAccessKey() != null && !config.getAccessKey().isEmpty(), "accessKey is null");
Copy link
Contributor

Choose a reason for hiding this comment

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

Use StringUtils.isNotEmpty(config.getAccessKey()) instead


@RestController
@RequestMapping("/acl")
public class AclController {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add permission control for ACL-related operation interfaces for different login role

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, oh, okay. I will make some adjustments according to your suggestions later.
@zhangjidi2016

confirmed-click="deleteAclConfig(item.accessKey)">{{'DELETE' | translate}}
</button>
<button class="btn btn-raised btn-sm btn-danger" type="button"
ng-click="synchronizeData(item)">{{'SYNCHRONIZE' | translate}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Hide action buttons based on login roles

@xxd763795151
Copy link
Contributor Author

Security key should be hidden by asterisks :-)

About this, I hope you could think it about more. If it is necessary, I will adjust later. Such as , it will show '********' , that hidden by asterisks, and there is a button on the side, click visible. Or hide this column , and add a 'Secret key ' button.

@codecov-commenter
Copy link

codecov-commenter commented Feb 17, 2022

Codecov Report

❗ No coverage uploaded for pull request base (master@6da21f4). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #71   +/-   ##
=========================================
  Coverage          ?   76.94%           
  Complexity        ?      821           
=========================================
  Files             ?       91           
  Lines             ?     2837           
  Branches          ?      278           
=========================================
  Hits              ?     2183           
  Misses            ?      500           
  Partials          ?      154           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6da21f4...5ed049c. Read the comment docs.

@xxd763795151
Copy link
Contributor Author

Now, when enable login controle, different roles are treated differently, as following:
the admin role:
image
image

the normal role:
image
image

@zhangjidi2016 @vongosling
Please review code again, thanks.

@vongosling
Copy link
Member

Security key should be hidden by asterisks :-)

About this, I hope you could think it about more. If it is necessary, I will adjust later. Such as , it will show '********' , that hidden by asterisks, and there is a button on the side, click visible. Or hide this column, and add a 'Secret key ' button.

As I said, Open Source projects also consider the common safety problem. Do you really see the downside of displaying security keys in clear text by default?

@xxd763795151
Copy link
Contributor Author

Security key should be hidden by asterisks :-)

About this, I hope you could think it about more. If it is necessary, I will adjust later. Such as , it will show '********' , that hidden by asterisks, and there is a button on the side, click visible. Or hide this column, and add a 'Secret key ' button.

As I said, Open Source projects also consider the common safety problem. Do you really see the downside of displaying security keys in clear text by default?

@vongosling Yeah, u are right. I just made some adjustments for it. Such as following:
image

Preconditions.checkArgument(StringUtils.isNotEmpty(config.getAccessKey()), "accessKey is null");
Preconditions.checkArgument(StringUtils.isNotEmpty(config.getSecretKey()), "secretKey is null");
aclService.addAclConfig(config);
return new JsonResult(0, "");
Copy link
Member

Choose a reason for hiding this comment

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

We can just return true.

return true;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will adjust it later. When I optimize code first time, I try return true, but it occur json error. So I use this style as return value. But using this style, it doesn't seem to be a problem right now, I will optimize these code again.

public Object deleteAclConfig(@RequestBody PlainAccessConfig config) {
Preconditions.checkArgument(StringUtils.isNotEmpty(config.getAccessKey()), "accessKey is null");
aclService.deleteAclConfig(config);
return new JsonResult(0, "");
Copy link
Member

Choose a reason for hiding this comment

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

ditto

Comment on lines 88 to 89
for (String addr :
masterSet) {
Copy link
Member

Choose a reason for hiding this comment

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

can be on the same line.

@StyleTang StyleTang merged commit 4269879 into apache:master Mar 5, 2022
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.

5 participants