[java-idp-oidc] branch main updated: JOIDC-308 - Provide configurable rules for back-channel content fetching
Codeberg
noreply at shibboleth.net
Sat Nov 28 15:50:43 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch main
in repository java-idp-oidc.
View the commit online:
https://codeberg.org/Shibboleth/java-idp-oidc/commit/12ca8d77fb6e9c122668c763de17a1e960b1d761
The following commit(s) were added to refs/heads/main by this push:
new 12ca8d77 JOIDC-308 - Provide configurable rules for back-channel content fetching
12ca8d77 is described below
commit 12ca8d77fb6e9c122668c763de17a1e960b1d761
Author: Henri Mikkonen <henri.mikkonen at iki.fi>
AuthorDate: Sat Nov 28 17:49:53 2026 +0200
JOIDC-308 - Provide configurable rules for back-channel content fetching
https://shibboleth.atlassian.net/browse/JOIDC-308
- Unit testing for the uri validation condition
---
.../impl/ExecuteBackChannelLogoutRequestTest.java | 31 +++++++++
.../SetRequestObjectToResponseContextTest.java | 74 +++++++++++++++++++++-
.../profile/impl/AddJwksToClientMetadataTest.java | 41 ++++++++++++
.../op/profile/impl/CheckRedirectUrisTest.java | 29 ++++++++-
4 files changed, 173 insertions(+), 2 deletions(-)
diff --git a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/logout/profile/impl/ExecuteBackChannelLogoutRequestTest.java b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/logout/profile/impl/ExecuteBackChannelLogoutRequestTest.java
index 19ca0d7d..d901b07e 100644
--- a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/logout/profile/impl/ExecuteBackChannelLogoutRequestTest.java
+++ b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/logout/profile/impl/ExecuteBackChannelLogoutRequestTest.java
@@ -45,6 +45,7 @@ import net.shibboleth.idp.profile.testing.ActionTestingSupport;
import net.shibboleth.idp.session.context.LogoutPropagationContext;
import net.shibboleth.oidc.security.credential.BasicJWKCredentialFactoryBean;
import net.shibboleth.shared.component.ComponentInitializationException;
+import net.shibboleth.shared.logic.PredicateSupport;
/**
* Unit tests for {@link ExecuteBackChannelLogoutRequest}.
@@ -110,6 +111,36 @@ public class ExecuteBackChannelLogoutRequestTest
Assert.assertEquals(logoutPropagationContext.getResult(), LogoutPropagationContext.Result.Success);
}
+ @Test
+ public void testHttpClientReturningOK_uriValidationTrue() throws IOException, ComponentInitializationException {
+ populateMetadataContext();
+ populateResponseContext();
+ initializeMockClient(HttpStatus.SC_OK);
+ final ExecuteBackChannelLogoutRequest action = new ExecuteBackChannelLogoutRequest();
+ assert mockClient != null;
+ action.setHttpClient(mockClient);
+ action.setUriValidationCondition(PredicateSupport.alwaysTrue());
+ action.initialize();
+ oidcLogoutPropagationContext.setRevocationError(false);
+ ActionTestingSupport.assertProceedEvent(action.execute(requestContext));
+ Assert.assertEquals(logoutPropagationContext.getResult(), LogoutPropagationContext.Result.Success);
+ }
+
+ @Test
+ public void testHttpClientReturningOK_uriValidationFails() throws IOException, ComponentInitializationException {
+ populateMetadataContext();
+ populateResponseContext();
+ initializeMockClient(HttpStatus.SC_OK);
+ final ExecuteBackChannelLogoutRequest action = new ExecuteBackChannelLogoutRequest();
+ assert mockClient != null;
+ action.setHttpClient(mockClient);
+ action.setUriValidationCondition(PredicateSupport.alwaysFalse());
+ action.initialize();
+ oidcLogoutPropagationContext.setRevocationError(false);
+ ActionTestingSupport.assertProceedEvent(action.execute(requestContext));
+ Assert.assertEquals(logoutPropagationContext.getResult(), LogoutPropagationContext.Result.Failure);
+ }
+
@Test
public void testHttpClientReturningOK_withRevocationError() throws IOException {
populateMetadataContext();
diff --git a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/oauth2/profile/impl/SetRequestObjectToResponseContextTest.java b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/oauth2/profile/impl/SetRequestObjectToResponseContextTest.java
index 620caec1..297c65cd 100644
--- a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/oauth2/profile/impl/SetRequestObjectToResponseContextTest.java
+++ b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/oauth2/profile/impl/SetRequestObjectToResponseContextTest.java
@@ -20,6 +20,7 @@ import net.shibboleth.idp.profile.testing.ActionTestingSupport;
import net.shibboleth.oidc.profile.core.OidcEventIds;
import net.shibboleth.shared.httpclient.HttpClientBuilder;
import net.shibboleth.shared.httpclient.HttpClientSupport;
+import net.shibboleth.shared.logic.PredicateSupport;
import net.shibboleth.shared.spring.resource.ResourceHelper;
import java.io.IOException;
@@ -158,5 +159,76 @@ public class SetRequestObjectToResponseContextTest extends BaseOIDCResponseActio
Assert.assertNotNull(respCtx.getRequestObject());
Assert.assertTrue(respCtx.getRequestObject() instanceof SignedJWT);
}
-
+
+ @Test
+ public void testRequestURIWithValidationTrue() throws Exception {
+ action = new SetRequestObjectToResponseContext();
+ final HttpClientBuilder builder = new HttpClientBuilder();
+ builder.setTLSSocketFactory(HttpClientSupport.buildNoTrustTLSSocketFactory());
+ action.setHttpClient(builder.buildClient());
+ assert enforceRequestObjects != null;
+ action.setRequestObjectEnforcedPredicate(enforceRequestObjects);
+ action.setObjectMapper(new ObjectMapper());
+ action.setPushedAuthorizationRequestEnforcedPredicate(prc -> false);
+ action.setUriValidationCondition(PredicateSupport.alwaysTrue());
+ action.initialize();
+ final String uri = "https://localhost:8443/oidc-austhreq.json";
+ assert metadataCtx != null;
+ final OIDCClientInformation clientInformation = metadataCtx.getClientInformation();
+ assert clientInformation != null;
+ clientInformation.getOIDCMetadata().setRequestObjectURIs(Set.of(new URI(uri)));
+
+ setAuthenticationRequest(
+ AuthenticationRequest.parse("client_id=" + clientId +
+ "&request_uri=" + UrlEscapers.urlFormParameterEscaper().escape(uri)));
+
+ //TODO switch into EmbeddedJetty from java-shib-shared once IdP dependencies are bumped
+ try (final EmbeddedJetty jetty = new EmbeddedJetty()) {
+ jetty.startServer(new EmbeddedJetty.ResourceHandler(200, ResourceHelper.of(
+ new ClassPathResource("net/shibboleth/idp/oidc/profile/impl/oidc-authreq.json"))));
+ final Event event = action.execute(requestCtx);
+ ActionTestingSupport.assertProceedEvent(event);
+ jetty.stopServer();
+ } catch (final UnknownHostException | SocketException e) {
+ Assert.fail("Embedded Jetty failed", e);
+ }
+ Assert.assertNotNull(respCtx.getRequestObject());
+ Assert.assertTrue(respCtx.getRequestObject() instanceof SignedJWT);
+ }
+
+ @Test
+ public void testRequestURIWithValidationFalse() throws Exception {
+ action = new SetRequestObjectToResponseContext();
+ final HttpClientBuilder builder = new HttpClientBuilder();
+ builder.setTLSSocketFactory(HttpClientSupport.buildNoTrustTLSSocketFactory());
+ action.setHttpClient(builder.buildClient());
+ assert enforceRequestObjects != null;
+ action.setRequestObjectEnforcedPredicate(enforceRequestObjects);
+ action.setObjectMapper(new ObjectMapper());
+ action.setPushedAuthorizationRequestEnforcedPredicate(prc -> false);
+ action.setUriValidationCondition(PredicateSupport.alwaysFalse());
+ action.initialize();
+ final String uri = "https://localhost:8443/oidc-austhreq.json";
+ assert metadataCtx != null;
+ final OIDCClientInformation clientInformation = metadataCtx.getClientInformation();
+ assert clientInformation != null;
+ clientInformation.getOIDCMetadata().setRequestObjectURIs(Set.of(new URI(uri)));
+
+ setAuthenticationRequest(
+ AuthenticationRequest.parse("client_id=" + clientId +
+ "&request_uri=" + UrlEscapers.urlFormParameterEscaper().escape(uri)));
+
+ //TODO switch into EmbeddedJetty from java-shib-shared once IdP dependencies are bumped
+ try (final EmbeddedJetty jetty = new EmbeddedJetty()) {
+ jetty.startServer(new EmbeddedJetty.ResourceHandler(200, ResourceHelper.of(
+ new ClassPathResource("net/shibboleth/idp/oidc/profile/impl/oidc-authreq.json"))));
+ final Event event = action.execute(requestCtx);
+ ActionTestingSupport.assertEvent(event, OidcEventIds.INVALID_REQUEST_URI);
+ Assert.assertTrue(respCtx.isRequestObjectFailure());
+ jetty.stopServer();
+ } catch (final UnknownHostException | SocketException e) {
+ Assert.fail("Embedded Jetty failed", e);
+ }
+ }
+
}
\ No newline at end of file
diff --git a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/AddJwksToClientMetadataTest.java b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/AddJwksToClientMetadataTest.java
index d5dedd77..94d82632 100644
--- a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/AddJwksToClientMetadataTest.java
+++ b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/AddJwksToClientMetadataTest.java
@@ -40,6 +40,7 @@ import com.nimbusds.jose.jwk.JWKSet;
import com.nimbusds.openid.connect.sdk.rp.OIDCClientMetadata;
import net.shibboleth.idp.profile.testing.ActionTestingSupport;
+import net.shibboleth.shared.logic.PredicateSupport;
/**
* Unit tests for {@link AddJwksToClientMetadata}.
@@ -132,6 +133,46 @@ public class AddJwksToClientMetadataTest extends BaseOIDCClientMetadataPopulatio
Assert.assertEquals(result.getJWKSetURI(), MOCK_URI);
}
+ @Test
+ public void testValidJwksUriValidated() throws Exception {
+ String json = new String(Files.readAllBytes(Paths.get(getClass().getResource(
+ "/net/shibboleth/idp/oidc/metadata/impl/public_keys.jwks").toURI())));
+ AddJwksToClientMetadata action = new AddJwksToClientMetadata();
+ action.setHttpClient(buildMockHttpClient(json));
+ final HttpClientSecurityParameters params = new HttpClientSecurityParameters();
+ params.setTLSProtocols(Collections.singleton("TLSv1"));
+ action.setHttpClientSecurityParameters(params);
+ action.setUriValidationCondition(PredicateSupport.alwaysTrue());
+ action.initialize();
+ OIDCClientMetadata request = new OIDCClientMetadata();
+ request.setJWKSetURI(MOCK_URI);
+ OIDCClientMetadata result = new OIDCClientMetadata();
+ setUpContext(request, result);
+ Event event = action.execute(requestCtx);
+ ActionTestingSupport.assertProceedEvent(event);
+ Assert.assertEquals(result.getJWKSetURI(), MOCK_URI);
+ }
+
+ @Test
+ public void testValidJwksUriValidationFails() throws Exception {
+ String json = new String(Files.readAllBytes(Paths.get(getClass().getResource(
+ "/net/shibboleth/idp/oidc/metadata/impl/public_keys.jwks").toURI())));
+ AddJwksToClientMetadata action = new AddJwksToClientMetadata();
+ action.setHttpClient(buildMockHttpClient(json));
+ final HttpClientSecurityParameters params = new HttpClientSecurityParameters();
+ params.setTLSProtocols(Collections.singleton("TLSv1"));
+ action.setHttpClientSecurityParameters(params);
+ action.setUriValidationCondition(PredicateSupport.alwaysFalse());
+ action.initialize();
+
+ OIDCClientMetadata request = new OIDCClientMetadata();
+ request.setJWKSetURI(MOCK_URI);
+ OIDCClientMetadata result = new OIDCClientMetadata();
+ setUpContext(request, result);
+ Event event = action.execute(requestCtx);
+ ActionTestingSupport.assertEvent(event, EventIds.INVALID_MESSAGE);
+ }
+
@Test
public void testValidJwksWithPrivateKey() throws Exception {
String json = new String(Files.readAllBytes(Paths.get(getClass().getResource(
diff --git a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/CheckRedirectUrisTest.java b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/CheckRedirectUrisTest.java
index 426b2631..372332e0 100644
--- a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/CheckRedirectUrisTest.java
+++ b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/CheckRedirectUrisTest.java
@@ -45,6 +45,7 @@ import com.nimbusds.openid.connect.sdk.rp.OIDCClientRegistrationRequest;
import net.shibboleth.idp.profile.testing.ActionTestingSupport;
import net.shibboleth.oidc.profile.core.OidcEventIds;
import net.shibboleth.shared.component.ComponentInitializationException;
+import net.shibboleth.shared.logic.PredicateSupport;
/**
* Unit tests for {@link CheckRedirectURIs}.
@@ -142,7 +143,33 @@ public class CheckRedirectUrisTest extends BaseOIDCRegistrationRequestTest {
initializeActionWithClient(buildMockHttpClient("[ \"" + redirectUri1 + "\", \"" + redirectUri2 + "\" ]"));
assertEvent(null, metadata, redirectUri1);
}
-
+
+ @Test
+ public void testValidSectorIdUriContentsUriValidationTrue() throws Exception {
+ action = new CheckRedirectURIs();
+ action.setObjectMapper(new ObjectMapper());
+ action.setHttpClient(buildMockHttpClient("[ \"" + redirectUri1 + "\", \"" + redirectUri2 + "\" ]"));
+ action.setUriValidationCondition(PredicateSupport.alwaysTrue());
+ action.initialize();
+ redirectUri1 = new URI("https://example.org/cb1");
+ redirectUri2 = new URI("https://example.org/cb2");
+ final OIDCClientMetadata metadata = new OIDCClientMetadata();
+ metadata.setSectorIDURI(new URI("https://invalid.scheme.org/cb"));
+ assertEvent(null, metadata, redirectUri1);
+ }
+
+ @Test
+ public void testValidSectorIdUriContentsUriValidationFalse() throws Exception {
+ action = new CheckRedirectURIs();
+ action.setObjectMapper(new ObjectMapper());
+ action.setHttpClient(buildMockHttpClient("[ \"" + redirectUri1 + "\", \"" + redirectUri2 + "\" ]"));
+ action.setUriValidationCondition(PredicateSupport.alwaysFalse());
+ action.initialize();
+ final OIDCClientMetadata metadata = new OIDCClientMetadata();
+ metadata.setSectorIDURI(new URI("https://invalid.scheme.org/cb"));
+ assertEvent(EventIds.INVALID_MESSAGE, metadata, redirectUri1);
+ }
+
@Test
public void testCheckForbiddenHostname() throws Exception {
Assert.assertFalse(action.checkForbiddenHostname(Collections.singleton(new URI("custom.test:/testing")),
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list