Skip to content

Commit

Permalink
Add it back to OBO and take away from api token
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Ho <[email protected]>
  • Loading branch information
derek-ho committed Dec 20, 2024
1 parent 09018dc commit 7ab4a2a
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ public ExpiringBearerAuthToken issueOnBehalfOfToken(final Subject subject, final
}

final User user = threadPool.getThreadContext().getTransient(ConfigConstants.OPENDISTRO_SECURITY_USER);
if (user == null) {
throw new OpenSearchSecurityException("Unsupported user to generate OnBehalfOfToken");
}

final TransportAddress callerAddress = null; /* OBO tokens must not roles based on location from network address */
final Set<String> mappedRoles = configModel.mapSecurityRoles(user, callerAddress);
Expand Down Expand Up @@ -145,9 +148,6 @@ public ExpiringBearerAuthToken issueApiToken(
final List<ApiToken.IndexPermission> indexPermissions
) {
final User user = threadPool.getThreadContext().getTransient(ConfigConstants.OPENDISTRO_SECURITY_USER);
if (user == null) {
throw new OpenSearchSecurityException("Unsupported user to generate Api Token");
}

try {
return apiTokenJwtVendor.createJwt(cs.getClusterName().value(), name, name, expiration, clusterPermissions, indexPermissions);
Expand Down

0 comments on commit 7ab4a2a

Please sign in to comment.