[fix][authorization] Fix multiple roles authorization - #16645
Merged
Conversation
Technoboy-
reviewed
Jul 18, 2022
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
nodece
force-pushed
the
fix-multiple-roles-authz
branch
from
July 18, 2022 10:35
0d67b5d to
224ca1b
Compare
RobertIndie
requested changes
Jul 19, 2022
RobertIndie
approved these changes
Jul 19, 2022
coderzc
approved these changes
Jul 19, 2022
Technoboy-
reviewed
Jul 25, 2022
| throw new RestException(Response.Status.NOT_FOUND, "Tenant does not exist"); | ||
| } | ||
| log.error("Failed to get tenant {}", tenantName, cause); | ||
| throw new RestException(cause); |
Contributor
There was a problem hiding this comment.
If line 129 throws RestException, will here wrap to new RestException(RestException ...) ?
Member
Author
There was a problem hiding this comment.
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();
}
}
Contributor
|
This PR relies on the |
Member
Author
|
@BewareMyPower Done. |
BewareMyPower
pushed a commit
that referenced
this pull request
Aug 5, 2022
(cherry picked from commit d8483d4)
codelipenghui
pushed a commit
that referenced
this pull request
Aug 8, 2022
(cherry picked from commit d8483d4)
mattisonchao
pushed a commit
that referenced
this pull request
Aug 10, 2022
(cherry picked from commit d8483d4)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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