-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix][authorization] Fix multiple roles authorization #16645
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
Conversation
...c/main/java/org/apache/pulsar/broker/authorization/MultiRolesTokenAuthorizationProvider.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
0d67b5d to
224ca1b
Compare
...ker/src/test/java/org/apache/pulsar/client/api/MultiRolesTokenAuthorizationProviderTest.java
Show resolved
Hide resolved
| throw new RestException(Response.Status.NOT_FOUND, "Tenant does not exist"); | ||
| } | ||
| log.error("Failed to get tenant {}", tenantName, cause); | ||
| throw new RestException(cause); |
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.
If line 129 throws RestException, will here wrap to new RestException(RestException ...) ?
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.
RestException can get the real exception.
public RestException(Throwable t) {
super(getResponse(t));
}
private static Response getResponse(Throwable t) {
if (t instanceof WebApplicationException) {
WebApplicationException e = (WebApplicationException) t;
return e.getResponse();
} else {
return Response
.status(Status.INTERNAL_SERVER_ERROR)
.entity(getExceptionData(t))
.type(MediaType.TEXT_PLAIN)
.build();
}
}|
This PR relies on the |
|
@BewareMyPower Done. |
(cherry picked from commit d8483d4)
(cherry picked from commit d8483d4)
(cherry picked from commit d8483d4)
Fixes #16574
Motivation
The
MultiRolesTokenAuthorizationProvidercannot handle the superuser and tenant admin correctly. It only checks if the role passed in is a superuser, which is incorrect. The correct way is to get a role list from authentication data and then check if the role list contains a superuser.Modifications
isSuperAdminvalidateTenantAdminAccessMultiRolesTokenAuthorizationProviderDocumentation
doc-not-needed