From 72dcec1f702877fa5d9bc63a2bd48d7bdeb13166 Mon Sep 17 00:00:00 2001 From: Ryan Liang Date: Tue, 22 Aug 2023 16:22:42 -0700 Subject: [PATCH] Some minor refactoring in obo authenticator Signed-off-by: Ryan Liang --- .../opensearch/security/http/OnBehalfOfAuthenticator.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/opensearch/security/http/OnBehalfOfAuthenticator.java b/src/main/java/org/opensearch/security/http/OnBehalfOfAuthenticator.java index bc43361617..77c6343c06 100644 --- a/src/main/java/org/opensearch/security/http/OnBehalfOfAuthenticator.java +++ b/src/main/java/org/opensearch/security/http/OnBehalfOfAuthenticator.java @@ -63,8 +63,8 @@ public class OnBehalfOfAuthenticator implements HTTPAuthenticator { private final EncryptionDecryptionUtil encryptionUtil; public OnBehalfOfAuthenticator(Settings settings, String clusterName) { - String oboEnabledSetting = settings.get("enabled"); - oboEnabled = oboEnabledSetting == null ? Boolean.TRUE : Boolean.valueOf(oboEnabledSetting); + String oboEnabledSetting = settings.get("enabled", "true"); + oboEnabled = Boolean.parseBoolean(oboEnabledSetting); encryptionKey = settings.get("encryption_key"); jwtParser = initParser(settings.get("signing_key")); this.clusterName = clusterName; @@ -151,7 +151,7 @@ private AuthCredentials extractCredentials0(final RestRequest request) { return null; } - if (!isAllowedRequest(request)) { + if (!isRequestAllowed(request)) { return null; } @@ -226,7 +226,7 @@ private void logDebug(String message, Object... args) { } } - public Boolean isAllowedRequest(final RestRequest request) { + public Boolean isRequestAllowed(final RestRequest request) { Matcher matcher = PATTERN_PATH_PREFIX.matcher(request.path()); final String suffix = matcher.matches() ? matcher.group(2) : null; if (request.method() == RestRequest.Method.POST && ON_BEHALF_OF_SUFFIX.equals(suffix)