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..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 @@ -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 isAllowedEnvValidationEnabled; + @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 (isAllowedEnvValidationEnabled) { + if (value != null) { + return values.stream().anyMatch(value::equalsIgnoreCase); + } + return false; } - return false; + return true; } } \ No newline at end of file