Skip to content

Commit

Permalink
Forward port supportsImpersonation check for http auth backend
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Liang <jiallian@amazon.com>
  • Loading branch information
RyanL1997 committed Oct 19, 2023
1 parent 40588e6 commit 5251e28
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
import org.opensearch.security.filter.SecurityRequest;
import org.opensearch.security.filter.SecurityRequestChannel;
import org.opensearch.security.filter.SecurityResponse;
import org.opensearch.security.http.OnBehalfOfAuthenticator;
import org.opensearch.security.http.XFFResolver;
import org.opensearch.security.securityconf.DynamicConfigModel;
import org.opensearch.security.support.ConfigConstants;
Expand Down Expand Up @@ -619,8 +618,7 @@ private User impersonate(final SecurityRequest request, final User originalUser)
for (final AuthDomain authDomain : restAuthDomains) {
final AuthenticationBackend authenticationBackend = authDomain.getBackend();

// Skip over the OnBehalfOfAuthenticator since it is not compatible for user impersonation
if (authDomain.getHttpAuthenticator() instanceof OnBehalfOfAuthenticator) {
if (!authDomain.getHttpAuthenticator().supportsImpersonation()) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,13 @@ public interface HTTPAuthenticator {
* @return Optional response if is not supported/necessary, response object otherwise.
*/
Optional<SecurityResponse> reRequestAuthentication(final SecurityRequest request, AuthCredentials credentials);

/**
* Indicates whether this authenticator supports user impersonation.
*
* @return true if impersonation is supported, false otherwise.
*/
default boolean supportsImpersonation() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,8 @@ public String getType() {
return "onbehalfof_jwt";
}

@Override
public boolean supportsImpersonation() {
return false;
}
}

0 comments on commit 5251e28

Please sign in to comment.