Skip to content

Commit

Permalink
Remove getUser from examples (#91123)
Browse files Browse the repository at this point in the history
#91069 removed this method. This commit removes the usage from the examples.
  • Loading branch information
jakelandis authored Oct 25, 2022
1 parent e5cdf69 commit 4a575e7
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ public void resolveAuthorizationInfo(RequestInfo requestInfo, ActionListener<Aut
if (authentication.isRunAs()) {
final CustomAuthorizationInfo authenticatedUserAuthzInfo =
new CustomAuthorizationInfo(authentication.getAuthenticatingSubject().getUser().roles(), null);
listener.onResponse(new CustomAuthorizationInfo(authentication.getUser().roles(), authenticatedUserAuthzInfo));
listener.onResponse(new CustomAuthorizationInfo(authentication.getEffectiveSubject().getUser().roles(),
authenticatedUserAuthzInfo));
} else {
listener.onResponse(new CustomAuthorizationInfo(authentication.getUser().roles(), null));
listener.onResponse(new CustomAuthorizationInfo(authentication.getEffectiveSubject().getUser().roles(), null));
}
}

Expand All @@ -73,7 +74,7 @@ public void authorizeRunAs(RequestInfo requestInfo, AuthorizationInfo authorizat
@Override
public void authorizeClusterAction(RequestInfo requestInfo, AuthorizationInfo authorizationInfo,
ActionListener<AuthorizationResult> listener) {
if (isSuperuser(requestInfo.getAuthentication().getUser())) {
if (isSuperuser(requestInfo.getAuthentication().getEffectiveSubject().getUser())) {
listener.onResponse(AuthorizationResult.granted());
} else {
listener.onResponse(AuthorizationResult.deny());
Expand All @@ -85,7 +86,7 @@ public void authorizeIndexAction(RequestInfo requestInfo, AuthorizationInfo auth
AsyncSupplier<ResolvedIndices> indicesAsyncSupplier,
Map<String, IndexAbstraction> aliasOrIndexLookup,
ActionListener<IndexAuthorizationResult> listener) {
if (isSuperuser(requestInfo.getAuthentication().getUser())) {
if (isSuperuser(requestInfo.getAuthentication().getEffectiveSubject().getUser())) {
indicesAsyncSupplier.getAsync(ActionListener.wrap(resolvedIndices -> {
Map<String, IndexAccessControl> indexAccessControlMap = new HashMap<>();
for (String name : resolvedIndices.getLocal()) {
Expand All @@ -103,7 +104,7 @@ public void authorizeIndexAction(RequestInfo requestInfo, AuthorizationInfo auth
@Override
public void loadAuthorizedIndices(RequestInfo requestInfo, AuthorizationInfo authorizationInfo,
Map<String, IndexAbstraction> indicesLookup, ActionListener<Set<String>> listener) {
if (isSuperuser(requestInfo.getAuthentication().getUser())) {
if (isSuperuser(requestInfo.getAuthentication().getEffectiveSubject().getUser())) {
listener.onResponse(indicesLookup.keySet());
} else {
listener.onResponse(Collections.emptySet());
Expand All @@ -114,7 +115,7 @@ public void loadAuthorizedIndices(RequestInfo requestInfo, AuthorizationInfo aut
public void validateIndexPermissionsAreSubset(RequestInfo requestInfo, AuthorizationInfo authorizationInfo,
Map<String, List<String>> indexNameToNewNames,
ActionListener<AuthorizationResult> listener) {
if (isSuperuser(requestInfo.getAuthentication().getUser())) {
if (isSuperuser(requestInfo.getAuthentication().getEffectiveSubject().getUser())) {
listener.onResponse(AuthorizationResult.granted());
} else {
listener.onResponse(AuthorizationResult.deny());
Expand Down

0 comments on commit 4a575e7

Please sign in to comment.