From b19e6925d10d437b33ef9cc30b676ac41ae87c90 Mon Sep 17 00:00:00 2001 From: Neha Farheen Date: Tue, 22 Aug 2023 13:53:44 +0530 Subject: [PATCH 1/2] Added the flag condition to check env --- .../service/validator/AuthRequestValidator.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/validator/AuthRequestValidator.java b/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/validator/AuthRequestValidator.java index e3e801d7b4a..c9261a717b9 100644 --- a/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/validator/AuthRequestValidator.java +++ b/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/validator/AuthRequestValidator.java @@ -17,6 +17,7 @@ import javax.annotation.PostConstruct; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; import org.springframework.validation.Errors; @@ -76,6 +77,9 @@ public class AuthRequestValidator extends BaseAuthRequestValidator { */ private List allowedDomainUris; + @Value("${mosip.ida.validate-allowed-env-enabled:true}") + private boolean isallowedEnabled; + @PostConstruct public void initialize() { allowedEnvironments = Arrays.stream(EnvUtil.getAllowedEnv().split((","))) @@ -475,6 +479,7 @@ private void validateEnv(AuthRequestDTO authRequestDto, Errors errors) { } // request env is not null and not matching with configurations + if (authRequestDto.getEnv() != null && !isValuesContainsIgnoreCase(allowedEnvironments, authRequestDto.getEnv())) { mosipLogger.error(IdAuthCommonConstants.SESSION_ID, this.getClass().getSimpleName(), @@ -645,9 +650,12 @@ private Date biometricTimestampParser(String timestamp) throws ParseException { * @return */ private boolean isValuesContainsIgnoreCase(List values, String value) { - if (value != null) { - return values.stream().anyMatch(value::equalsIgnoreCase); + if (isallowedEnabled) { + if (value != null) { + return values.stream().anyMatch(value::equalsIgnoreCase); + } + return false; } - return false; + return true; } } \ No newline at end of file From 8a5b189c7febb5e7523afe6c8dbb7e8e443381d2 Mon Sep 17 00:00:00 2001 From: Neha Farheen Date: Tue, 22 Aug 2023 16:12:10 +0530 Subject: [PATCH 2/2] Variable name changed --- .../common/service/validator/AuthRequestValidator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/validator/AuthRequestValidator.java b/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/validator/AuthRequestValidator.java index c9261a717b9..a3ae09e13d2 100644 --- a/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/validator/AuthRequestValidator.java +++ b/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/validator/AuthRequestValidator.java @@ -78,7 +78,7 @@ public class AuthRequestValidator extends BaseAuthRequestValidator { private List allowedDomainUris; @Value("${mosip.ida.validate-allowed-env-enabled:true}") - private boolean isallowedEnabled; + private boolean isAllowedEnvValidationEnabled; @PostConstruct public void initialize() { @@ -650,7 +650,7 @@ private Date biometricTimestampParser(String timestamp) throws ParseException { * @return */ private boolean isValuesContainsIgnoreCase(List values, String value) { - if (isallowedEnabled) { + if (isAllowedEnvValidationEnabled) { if (value != null) { return values.stream().anyMatch(value::equalsIgnoreCase); }