-
Notifications
You must be signed in to change notification settings - Fork 8k
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
Improve the ACL checking mechanism of Sentinel dashboard #1042
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1042 +/- ##
============================================
- Coverage 43.03% 42.67% -0.37%
+ Complexity 1568 1473 -95
============================================
Files 337 317 -20
Lines 9877 9286 -591
Branches 1332 1267 -65
============================================
- Hits 4251 3963 -288
+ Misses 5097 4831 -266
+ Partials 529 492 -37
Continue to review full report at Codecov.
|
@@ -69,7 +69,9 @@ | |||
@RequestParam String ip, | |||
@RequestParam Integer port) { | |||
AuthUser authUser = authService.getAuthUser(request); | |||
authUser.authTarget(app, PrivilegeType.READ_RULE); | |||
if (!authUser.authTarget(app, PrivilegeType.READ_RULE)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Writing the duplicate boilerplate code in every controller handler is tedious :(
Maybe we need a unified, simplified filter or other mechanisms to achieve this. See #745 for more discussions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I try to improve it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Writing the duplicate boilerplate code in every controller handler is tedious :(
Maybe we need a unified, simplified filter or other mechanisms to achieve this. See #745 for more discussions.
I have pushed the new implementation.
Use AuthInterceptor to intercept the AuthAction annotation
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Target({ElementType.METHOD})
public @interface AuthAction {
AuthService.PrivilegeType value();
String targetName() default "app";
String message() default "No privilege";
}
Value is the privilege.
TargetName is the auth target, from the request parameter(post or get), usually app or ip, default app.
Message is the response message when do action without privilege.
Any ideas about this PR? @jasonjoo2010 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
brief: EL expression to support JSON format requests.
...ard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AuthorityRuleController.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter in JSON type would be improved later.
Now everything LGTM except it.
Nice work. Thanks for contributing! |
* Add `@AuthAction` annotation support
Describe what this PR does / why we need it
Fix the dashboard privileges check bug, from the interface AuthService, there is a comment on the authTarget function
but in the dashboard controllers, there is not check on the authTarget's return value to verify privileges.
and update the fastjson version because of the security, see https://github.com/alibaba/fastjson/releases
Does this pull request fix one issue?
NONE
Describe how you did it
Add checks for every authTarget's return.
refer #1035