diff --git a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/authorization/PathMatcher.java b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/authorization/PathMatcher.java index 8e83de1887..8bec8408fd 100644 --- a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/authorization/PathMatcher.java +++ b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/authorization/PathMatcher.java @@ -95,7 +95,9 @@ class PathMatcher { } if (WILDCARD == expectedUri.charAt(expectedUri.length() - 1)) { - matchingAnyPath = entry; + if (matchingAnyPath == null || matchingAnyPath.getPath().length() < matchingUri.length()) { + matchingAnyPath = entry; + } } else { int suffixIndex = expectedUri.indexOf(WILDCARD + ".");