From 87646d7d662f6281e495e18262b162878b323f49 Mon Sep 17 00:00:00 2001 From: Peter Nied Date: Mon, 2 Oct 2023 21:44:20 +0000 Subject: [PATCH] Fix merging from main changes Signed-off-by: Peter Nied --- .../opensearch/security/http/OnBehalfOfAuthenticator.java | 1 - .../java/org/opensearch/security/util/AuthTokenUtils.java | 4 ++-- .../security/authtoken/jwt/AuthTokenUtilsTest.java | 7 ++++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/opensearch/security/http/OnBehalfOfAuthenticator.java b/src/main/java/org/opensearch/security/http/OnBehalfOfAuthenticator.java index 3e54e325db..1499afa0ea 100644 --- a/src/main/java/org/opensearch/security/http/OnBehalfOfAuthenticator.java +++ b/src/main/java/org/opensearch/security/http/OnBehalfOfAuthenticator.java @@ -33,7 +33,6 @@ import org.opensearch.SpecialPermission; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; -import org.opensearch.rest.RestRequest; import org.opensearch.security.auth.HTTPAuthenticator; import org.opensearch.security.authtoken.jwt.EncryptionDecryptionUtil; import org.opensearch.security.filter.SecurityRequestChannel; diff --git a/src/main/java/org/opensearch/security/util/AuthTokenUtils.java b/src/main/java/org/opensearch/security/util/AuthTokenUtils.java index 30f331d3a7..a938375a9e 100644 --- a/src/main/java/org/opensearch/security/util/AuthTokenUtils.java +++ b/src/main/java/org/opensearch/security/util/AuthTokenUtils.java @@ -12,7 +12,7 @@ package org.opensearch.security.util; import org.opensearch.common.settings.Settings; -import org.opensearch.rest.RestRequest; +import org.opensearch.security.filter.SecurityRequestChannel; import static org.opensearch.rest.RestRequest.Method.POST; import static org.opensearch.rest.RestRequest.Method.PUT; @@ -21,7 +21,7 @@ public class AuthTokenUtils { private static final String ON_BEHALF_OF_SUFFIX = "api/generateonbehalfoftoken"; private static final String ACCOUNT_SUFFIX = "api/account"; - public static Boolean isAccessToRestrictedEndpoints(final RestRequest request, final String suffix) { + public static Boolean isAccessToRestrictedEndpoints(final SecurityRequestChannel request, final String suffix) { if (suffix == null) { return false; } diff --git a/src/test/java/org/opensearch/security/authtoken/jwt/AuthTokenUtilsTest.java b/src/test/java/org/opensearch/security/authtoken/jwt/AuthTokenUtilsTest.java index d563308e31..1db187e7b6 100644 --- a/src/test/java/org/opensearch/security/authtoken/jwt/AuthTokenUtilsTest.java +++ b/src/test/java/org/opensearch/security/authtoken/jwt/AuthTokenUtilsTest.java @@ -14,6 +14,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.rest.RestRequest; +import org.opensearch.security.filter.SecurityRequestFactory; import org.opensearch.security.util.AuthTokenUtils; import org.opensearch.test.rest.FakeRestRequest; import org.junit.Test; @@ -33,7 +34,7 @@ public void testIsAccessToRestrictedEndpointsForOnBehalfOfToken() { .withMethod(RestRequest.Method.POST) .build(); - assertTrue(AuthTokenUtils.isAccessToRestrictedEndpoints(request, "api/generateonbehalfoftoken")); + assertTrue(AuthTokenUtils.isAccessToRestrictedEndpoints(SecurityRequestFactory.from(request, null), "api/generateonbehalfoftoken")); } @Test @@ -44,7 +45,7 @@ public void testIsAccessToRestrictedEndpointsForAccount() { .withMethod(RestRequest.Method.PUT) .build(); - assertTrue(AuthTokenUtils.isAccessToRestrictedEndpoints(request, "api/account")); + assertTrue(AuthTokenUtils.isAccessToRestrictedEndpoints(SecurityRequestFactory.from(request, null), "api/account")); } @Test @@ -55,7 +56,7 @@ public void testIsAccessToRestrictedEndpointsFalseCase() { .withMethod(RestRequest.Method.GET) .build(); - assertFalse(AuthTokenUtils.isAccessToRestrictedEndpoints(request, "api/someotherendpoint")); + assertFalse(AuthTokenUtils.isAccessToRestrictedEndpoints(SecurityRequestFactory.from(request, null), "api/someotherendpoint")); } @Test