[java-oidc-common] branch main updated: JCOMOIDC-184 - Move OAuth2Client authentication flow from OP to oidc-common
Codeberg
noreply at shibboleth.net
Tue Nov 24 08:50:57 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch main
in repository java-oidc-common.
View the commit online:
https://codeberg.org/Shibboleth/java-oidc-common/commit/0b4c9b374deae99e3dd05260540076d37f980f6e
The following commit(s) were added to refs/heads/main by this push:
new 0b4c9b37 JCOMOIDC-184 - Move OAuth2Client authentication flow from OP to oidc-common
0b4c9b37 is described below
commit 0b4c9b374deae99e3dd05260540076d37f980f6e
Author: Henri Mikkonen <henri.mikkonen at iki.fi>
AuthorDate: Tue Nov 24 10:49:05 2026 +0200
JCOMOIDC-184 - Move OAuth2Client authentication flow from OP to oidc-common
https://shibboleth.atlassian.net/browse/JCOMOIDC-184
Add 'supportedAuthMethodsLookupStrategy' as described in JOIDC-315
---
.../impl/ValidateClientAuthenticationType.java | 63 ++++++++++++++++++----
1 file changed, 54 insertions(+), 9 deletions(-)
diff --git a/oidc-common-crypto-impl/src/main/java/net/shibboleth/oidc/authn/impl/ValidateClientAuthenticationType.java b/oidc-common-crypto-impl/src/main/java/net/shibboleth/oidc/authn/impl/ValidateClientAuthenticationType.java
index e83fdb02..ea54d20c 100644
--- a/oidc-common-crypto-impl/src/main/java/net/shibboleth/oidc/authn/impl/ValidateClientAuthenticationType.java
+++ b/oidc-common-crypto-impl/src/main/java/net/shibboleth/oidc/authn/impl/ValidateClientAuthenticationType.java
@@ -15,8 +15,10 @@
package net.shibboleth.oidc.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));
}
/**
@@ -110,9 +122,22 @@ public class ValidateClientAuthenticationType extends AbstractAuthenticationActi
tokenEndpointAuthMethodsLookupStrategy = Constraint.isNotNull(strategy,
"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.0.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,
@@ -128,12 +153,15 @@ 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 +233,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
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list