From bb39aae12cdabb0cedd36346d189a0d8b528f4fa Mon Sep 17 00:00:00 2001 From: bhagyasakalanka Date: Wed, 26 Jun 2024 11:26:43 +0530 Subject: [PATCH] Fix jdbc scope validator invalid scope issue --- .../identity/oauth2/validators/JDBCScopeValidator.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/org.wso2.carbon.identity.oauth/src/main/java/org/wso2/carbon/identity/oauth2/validators/JDBCScopeValidator.java b/components/org.wso2.carbon.identity.oauth/src/main/java/org/wso2/carbon/identity/oauth2/validators/JDBCScopeValidator.java index f099945bf60..53fe7945776 100644 --- a/components/org.wso2.carbon.identity.oauth/src/main/java/org/wso2/carbon/identity/oauth2/validators/JDBCScopeValidator.java +++ b/components/org.wso2.carbon.identity.oauth/src/main/java/org/wso2/carbon/identity/oauth2/validators/JDBCScopeValidator.java @@ -93,6 +93,11 @@ public class JDBCScopeValidator extends OAuth2ScopeValidator { private static final String SCOPE_VALIDATOR_NAME = "Role based scope validator"; private static final String OPENID = "openid"; private static final String PRESERVE_CASE_SENSITIVITY = "preservedCaseSensitive"; + private static final String SCOPE_VALIDATOR_PRESERVE_CASE_SENSITIVITY_CONFIG = + "OAuth.ScopeValidationPreserveCaseSensitivity"; + + private static final boolean SCOPE_VALIDATOR_PRESERVE_CASE_SENSITIVITY = + Boolean.parseBoolean(IdentityUtil.getProperty(SCOPE_VALIDATOR_PRESERVE_CASE_SENSITIVITY_CONFIG)); private static final Log log = LogFactory.getLog(JDBCScopeValidator.class); @@ -411,7 +416,7 @@ private boolean isUserAuthorizedForScope(String scopeName, String[] userRoles, i //Check if the user still has a valid role for this scope. Set scopeRoles = new HashSet<>(rolesOfScope); - if (preservedCaseSensitive) { + if (preservedCaseSensitive || SCOPE_VALIDATOR_PRESERVE_CASE_SENSITIVITY) { rolesOfScope.retainAll(Arrays.asList(userRoles)); } else { Set rolesOfScopeLowerCase = new HashSet<>();