[java-idp-oidc] branch maint-4.4 updated: JOIDC-315 - Reject TLS client auth method in OAuth2Client before it's supported
Codeberg
noreply at shibboleth.net
Tue Nov 24 10:37:53 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch maint-4.4
in repository java-idp-oidc.
View the commit online:
https://codeberg.org/Shibboleth/java-idp-oidc/commit/22c2d098be77d949663902699c22e1a86e9e73d9
The following commit(s) were added to refs/heads/maint-4.4 by this push:
new 22c2d098 JOIDC-315 - Reject TLS client auth method in OAuth2Client before it's supported
22c2d098 is described below
commit 22c2d098be77d949663902699c22e1a86e9e73d9
Author: Henri Mikkonen <henri.mikkonen at iki.fi>
AuthorDate: Tue Nov 24 12:35:08 2026 +0200
JOIDC-315 - Reject TLS client auth method in OAuth2Client before it's supported
https://shibboleth.atlassian.net/browse/JOIDC-315
ValidateClientAuthenticationType: new supportedAuthMethodsLookupStrategy provides a hook to configure which methods are supported
- Defaults to constant set: client_secret_basic, client_secret_post, client_secret_jwt, private_key_jwt and none
- Configurable via shibboleth.authn.OAuth2Client.SupportedClientAuthenticationMethodsLookupStrategy (Function<ProfileRequestContext,Set<ClientAuthenticationMethod>>)
---
.../impl/ValidateClientAuthenticationType.java | 58 +++++++++++++++++++---
.../authn/OAuth2Client/OAuth2Client-beans.xml | 15 +++++-
2 files changed, 66 insertions(+), 7 deletions(-)
diff --git a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/authn/impl/ValidateClientAuthenticationType.java b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/authn/impl/ValidateClientAuthenticationType.java
index b9539ffd..29c6b300 100644
--- a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/authn/impl/ValidateClientAuthenticationType.java
+++ b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/authn/impl/ValidateClientAuthenticationType.java
@@ -15,8 +15,10 @@
package net.shibboleth.idp.plugin.oidc.op.authn.impl;
import java.util.Collections;
+import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
+import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -40,7 +42,9 @@ import net.shibboleth.oidc.authn.context.OAuth2ClientAuthenticationContext;
import net.shibboleth.oidc.metadata.context.OIDCMetadataContext;
import net.shibboleth.oidc.profile.config.navigate.TokenEndpointAuthMethodLookupFunction;
import net.shibboleth.shared.annotation.constraint.NonnullElements;
+import net.shibboleth.shared.collection.CollectionSupport;
import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.logic.FunctionSupport;
import net.shibboleth.shared.primitive.LoggerFactory;
/**
@@ -65,7 +69,11 @@ public class ValidateClientAuthenticationType extends AbstractAuthenticationActi
/** Strategy to obtain enabled token endpoint authentication methods. */
@Nonnull private Function<ProfileRequestContext,Set<ClientAuthenticationMethod>>
tokenEndpointAuthMethodsLookupStrategy;
-
+
+ /** Strategy to obtain supported token endpoint authentication methods. */
+ @Nonnull private Function<ProfileRequestContext,Set<ClientAuthenticationMethod>>
+ supportedAuthMethodsLookupStrategy;
+
/** The attached OIDC metadata context. */
@Nullable private OIDCMetadataContext oidcMetadataContext;
@@ -85,6 +93,10 @@ public class ValidateClientAuthenticationType extends AbstractAuthenticationActi
assert omcls != null;
oidcMetadataContextLookupStrategy = omcls;
tokenEndpointAuthMethodsLookupStrategy = new TokenEndpointAuthMethodLookupFunction();
+ supportedAuthMethodsLookupStrategy = FunctionSupport.constant(
+ CollectionSupport.setOf(ClientAuthenticationMethod.CLIENT_SECRET_BASIC,
+ ClientAuthenticationMethod.CLIENT_SECRET_JWT, ClientAuthenticationMethod.CLIENT_SECRET_POST,
+ ClientAuthenticationMethod.NONE, ClientAuthenticationMethod.PRIVATE_KEY_JWT));
}
/**
@@ -112,7 +124,21 @@ public class ValidateClientAuthenticationType extends AbstractAuthenticationActi
"Strategy to obtain enabled token endpoint authentication methods cannot be null");
}
-
+
+ /**
+ * Set strategy to obtain supported token endpoint authentication methods.
+ *
+ * @param strategy What to set.
+ * @since 4.4.0
+ */
+ public void setSupportedAuthMethodsLookupStrategy(@Nonnull final Function<ProfileRequestContext,
+ Set<ClientAuthenticationMethod>> strategy) {
+ checkSetterPreconditions();
+
+ supportedAuthMethodsLookupStrategy = Constraint.isNotNull(strategy,
+ "Strategy to obtain supported token endpoint authentication methods cannot be null");
+ }
+
/** {@inheritDoc} */
@Override
protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext,
@@ -129,10 +155,13 @@ public class ValidateClientAuthenticationType extends AbstractAuthenticationActi
oidcMetadataContext = oidcMetadataContextLookupStrategy.apply(profileRequestContext);
- enabledMethods = tokenEndpointAuthMethodsLookupStrategy.apply(profileRequestContext);
- if (enabledMethods == null) {
- enabledMethods = Collections.emptySet();
- }
+ final Set<ClientAuthenticationMethod> supportedMethods =
+ Optional.ofNullable(supportedAuthMethodsLookupStrategy.apply(profileRequestContext))
+ .orElse(Collections.emptySet());
+ enabledMethods = Optional.ofNullable(tokenEndpointAuthMethodsLookupStrategy.apply(profileRequestContext))
+ .orElse(Collections.emptySet()).stream()
+ .filter(method -> isSupportedMethod(method, supportedMethods))
+ .collect(Collectors.toSet());
return true;
}
@@ -205,4 +234,21 @@ public class ValidateClientAuthenticationType extends AbstractAuthenticationActi
@Nullable private String getClientIDValue(@Nullable final ClientID clientId) {
return clientId == null ? null : clientId.getValue();
}
+
+ /**
+ * Checks if the given method is in the given set of supported method.
+ *
+ * @param method method to check
+ * @param supportedMethods set of supported methods
+ * @return true if exists, false otherwise or if any input value is null
+ */
+ private boolean isSupportedMethod(@Nullable final ClientAuthenticationMethod method,
+ @Nullable final Set<ClientAuthenticationMethod> supportedMethods) {
+ if (method != null && supportedMethods != null && supportedMethods.contains(method)) {
+ return true;
+ } else {
+ log.debug("{} Ignoring unsupported client authentication method {}", getLogPrefix(), method);
+ return false;
+ }
+ }
}
\ No newline at end of file
diff --git a/idp-oidc-extension-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/OAuth2Client/OAuth2Client-beans.xml b/idp-oidc-extension-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/OAuth2Client/OAuth2Client-beans.xml
index 797fcb55..957e27db 100644
--- a/idp-oidc-extension-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/OAuth2Client/OAuth2Client-beans.xml
+++ b/idp-oidc-extension-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/OAuth2Client/OAuth2Client-beans.xml
@@ -104,7 +104,20 @@
<bean id="ValidateClientAuthenticationType"
- class="net.shibboleth.idp.plugin.oidc.op.authn.impl.ValidateClientAuthenticationType" scope="prototype" />
+ class="net.shibboleth.idp.plugin.oidc.op.authn.impl.ValidateClientAuthenticationType" scope="prototype"
+ p:supportedAuthMethodsLookupStrategy="#{getObject('shibboleth.authn.OAuth2Client.SupportedClientAuthenticationMethodsLookupStrategy') ?: getObject('DefaultSupportedClientAuthenticationMethodsLookupStrategy')}" />
+
+ <bean parent="shibboleth.Functions.Constant" id="DefaultSupportedClientAuthenticationMethodsLookupStrategy">
+ <constructor-arg>
+ <util:set>
+ <util:constant static-field="com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod.CLIENT_SECRET_BASIC"/>
+ <util:constant static-field="com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod.CLIENT_SECRET_POST"/>
+ <util:constant static-field="com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod.CLIENT_SECRET_JWT"/>
+ <util:constant static-field="com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod.PRIVATE_KEY_JWT"/>
+ <util:constant static-field="com.nimbusds.oauth2.sdk.auth.ClientAuthenticationMethod.NONE"/>
+ </util:set>
+ </constructor-arg>
+ </bean>
<bean id="DefaultCleanupHook"
class="net.shibboleth.idp.authn.impl.ValidateCredentials.UsernamePasswordCleanupHook" />
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list