Skip to content

Commit f99115d

Browse files
committed
Filtering fapi allowed client authenticators
1 parent 2092614 commit f99115d

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

components/org.wso2.carbon.identity.oauth/src/main/java/org/wso2/carbon/identity/oauth2/client/authentication/OAuthClientAuthnService.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,17 @@ private void executeClientAuthenticators(HttpServletRequest request, OAuthClient
166166
}
167167
try {
168168
List<OAuthClientAuthenticator> configuredClientAuthMethods = getConfiguredClientAuthMethods(clientId);
169-
List<OAuthClientAuthenticator> authenticators = configuredClientAuthMethods;
169+
List<OAuthClientAuthenticator> applicableAuthenticators;
170170
if (OAuth2Util.isFapiConformantApp(clientId)) {
171-
authenticators = validateAndGetClientAuthenticatorsForFapi(configuredClientAuthMethods);
171+
applicableAuthenticators = filterClientAuthenticatorsForFapi(configuredClientAuthMethods);
172172
} else {
173173
if (configuredClientAuthMethods.isEmpty()) {
174-
authenticators = this.getClientAuthenticators();
174+
applicableAuthenticators = this.getClientAuthenticators();
175+
} else {
176+
applicableAuthenticators = configuredClientAuthMethods;
175177
}
176178
}
177-
if (authenticators.isEmpty()) {
179+
if (applicableAuthenticators.isEmpty()) {
178180
setErrorToContext(OAuth2ErrorCodes.INVALID_REQUEST, "No valid authenticators found for " +
179181
"the application.", oAuthClientAuthnContext);
180182
return;
@@ -371,22 +373,23 @@ private String extractClientId(HttpServletRequest request, Map<String, List> bod
371373
* @param configuredAuthenticators List of client authenticators configured for the application.
372374
* @return List of applicable client authentication methods for the application.
373375
*/
374-
private List<OAuthClientAuthenticator> validateAndGetClientAuthenticatorsForFapi(
376+
private List<OAuthClientAuthenticator> filterClientAuthenticatorsForFapi(
375377
List<OAuthClientAuthenticator> configuredAuthenticators) {
376378

377379
List<String> fapiAllowedAuthMethods = IdentityUtil.getPropertyAsList(FAPI_CLIENT_AUTH_METHOD_CONFIGURATION);
378380
if (configuredAuthenticators.isEmpty()) {
379381
return getApplicableClientAuthenticators(fapiAllowedAuthMethods);
380382
}
381383

384+
List<OAuthClientAuthenticator> filteredAuthenticators = new ArrayList<>();
382385
for (OAuthClientAuthenticator authenticator : configuredAuthenticators) {
383-
if (!fapiAllowedAuthMethods.stream().anyMatch(authenticator
386+
if (fapiAllowedAuthMethods.stream().anyMatch(authenticator
384387
.getSupportedClientAuthenticationMethods()::contains)) {
385-
return Collections.emptyList();
388+
filteredAuthenticators.add(authenticator);
386389
}
387390
}
388391

389-
return configuredAuthenticators;
392+
return filteredAuthenticators;
390393
}
391394

392395
/**

0 commit comments

Comments
 (0)