[java-idp-oidc] branch maint-4.4 updated: JOIDC-324 - Perform mandatory checks for the logout URIs during registration
Codeberg
noreply at shibboleth.net
Fri Nov 27 09:50:36 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/2057f932603eb27c50e9dea268db0da8b17757dc
The following commit(s) were added to refs/heads/maint-4.4 by this push:
new 2057f932 JOIDC-324 - Perform mandatory checks for the logout URIs during registration
2057f932 is described below
commit 2057f932603eb27c50e9dea268db0da8b17757dc
Author: Henri Mikkonen <henri.mikkonen at iki.fi>
AuthorDate: Fri Nov 27 11:29:46 2026 +0200
JOIDC-324 - Perform mandatory checks for the logout URIs during registration
https://shibboleth.atlassian.net/browse/JOIDC-324
---
.../impl/AddLogoutParametersToClientMetadata.java | 122 ++++++++++++++++++++-
.../AddLogoutParametersToClientMetadataTest.java | 103 +++++++++++++++++
2 files changed, 220 insertions(+), 5 deletions(-)
diff --git a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/AddLogoutParametersToClientMetadata.java b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/AddLogoutParametersToClientMetadata.java
index 9ea79ddd..f0385487 100644
--- a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/AddLogoutParametersToClientMetadata.java
+++ b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/AddLogoutParametersToClientMetadata.java
@@ -14,26 +14,138 @@
package net.shibboleth.idp.plugin.oidc.op.profile.impl;
+import java.net.URI;
+import java.util.Set;
+
import javax.annotation.Nonnull;
+import org.opensaml.profile.action.ActionSupport;
+import org.opensaml.profile.action.EventIds;
import org.opensaml.profile.context.ProfileRequestContext;
+import org.slf4j.Logger;
import com.nimbusds.openid.connect.sdk.rp.OIDCClientMetadata;
+import net.shibboleth.shared.annotation.constraint.NotEmpty;
+import net.shibboleth.shared.net.SimpleURLCanonicalizer;
+import net.shibboleth.shared.primitive.LoggerFactory;
+import net.shibboleth.shared.primitive.StringSupport;
+
/**
- * Adds the parameters related to OIDC logout to the output {@link OIDCClientMetadata}. The values are expected to be
- * already validated.
+ * Adds the parameters related to OIDC logout to the output {@link OIDCClientMetadata}. It performs the validation of
+ * front- and back-channel logout URI values as mandated by their specifications. Both URIs are required to use
+ * https-scheme.
*/
public class AddLogoutParametersToClientMetadata extends AbstractOIDCClientMetadataPopulationAction {
+ /** Class logger. */
+ @Nonnull private final Logger log = LoggerFactory.getLogger(AddLogoutParametersToClientMetadata.class);
+
/** {@inheritDoc} */
@Override
protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
getOutputMetadata().setPostLogoutRedirectionURIs(getInputMetadata().getPostLogoutRedirectionURIs());
- getOutputMetadata().setBackChannelLogoutURI(getInputMetadata().getBackChannelLogoutURI());
- getOutputMetadata().setFrontChannelLogoutURI(getInputMetadata().getFrontChannelLogoutURI());
+ final URI backChannelLogoutUri = getInputMetadata().getBackChannelLogoutURI();
+ if (backChannelLogoutUri != null) {
+ if (!"https".equalsIgnoreCase(backChannelLogoutUri.getScheme())) {
+ log.warn("{} The back-channel logout URI {} is not in 'https' scheme", getLogPrefix(),
+ backChannelLogoutUri);
+ ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MESSAGE);
+ return;
+ }
+ if (backChannelLogoutUri.getFragment() != null) {
+ log.warn("{} The back-channel logout URI {} contains fragment", getLogPrefix(),
+ backChannelLogoutUri);
+ ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MESSAGE);
+ return;
+ }
+ if (backChannelLogoutUri.getHost() == null) {
+ log.warn("{} The back-channel logout URI {} has no host", getLogPrefix(),
+ backChannelLogoutUri);
+ ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MESSAGE);
+ return;
+ }
+ getOutputMetadata().setBackChannelLogoutURI(backChannelLogoutUri);
+ }
+ final URI frontChannelLogoutUri = getInputMetadata().getFrontChannelLogoutURI();
+ if (frontChannelLogoutUri != null) {
+ final String scheme = frontChannelLogoutUri.getScheme();
+ if (scheme == null || !"https".equalsIgnoreCase(scheme)) {
+ log.warn("{} The front-channel logout URI {} is not in 'https' scheme", getLogPrefix(),
+ frontChannelLogoutUri);
+ ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MESSAGE);
+ return;
+ }
+ if (frontChannelLogoutUri.getFragment() != null) {
+ log.warn("{} The front-channel logout URI {} contains fragment", getLogPrefix(),
+ frontChannelLogoutUri);
+ ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MESSAGE);
+ return;
+ }
+ final Set<URI> redirectionUris = getInputMetadata().getRedirectionURIs();
+ if (redirectionUris == null || redirectionUris.isEmpty()) {
+ log.warn("{} No redirection URIs found to validate front-channel URI {}", getLogPrefix(),
+ frontChannelLogoutUri);
+ ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MESSAGE);
+ return;
+ }
+ boolean validated = false;
+ for (final URI redirectionUri : redirectionUris) {
+ assert redirectionUri != null;
+ if (isSameOrigin(frontChannelLogoutUri, redirectionUri)) {
+ validated = true;
+ break;
+ }
+ }
+ if (!validated) {
+ log.warn("{} The front-channel logout URI {} is not from same origin with any redirect URIs {}",
+ getLogPrefix(), frontChannelLogoutUri, redirectionUris);
+ ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MESSAGE);
+ return;
+ }
+ getOutputMetadata().setFrontChannelLogoutURI(frontChannelLogoutUri);
+
+ }
getOutputMetadata().requiresBackChannelLogoutSession(getInputMetadata().requiresBackChannelLogoutSession());
getOutputMetadata().requiresFrontChannelLogoutSession(getInputMetadata().requiresFrontChannelLogoutSession());
}
-}
\ No newline at end of file
+ /**
+ * Verifies that the two given URIs match with scheme, host and port. The scheme and host must not be null and
+ * the effective port must not be -1. The scheme and host are compared in a case insensitive way.
+ *
+ * @param one first URI
+ * @param another another URI
+ * @return true if their origin match, false otherwise
+ */
+ private static boolean isSameOrigin(@Nonnull final URI one, @Nonnull final URI another) {
+ final String scheme = StringSupport.trimOrNull(one.getScheme());
+ final String anotherScheme = StringSupport.trimOrNull(another.getScheme());
+ if (scheme == null || anotherScheme == null || !scheme.equalsIgnoreCase(anotherScheme)) {
+ return false;
+ }
+ final String host = StringSupport.trimOrNull(one.getHost());
+ final String anotherHost = StringSupport.trimOrNull(another.getHost());
+ if (host == null || anotherHost == null || !host.equalsIgnoreCase(anotherHost)) {
+ return false;
+ }
+ final int port = getEffectivePort(one.getPort(), scheme);
+ final int anotherPort = getEffectivePort(another.getPort(), anotherScheme);
+ return port != -1 && port == anotherPort;
+ }
+
+ /**
+ * Gets effective port for the given scheme if default was found, or -1 if not.
+ *
+ * @param port port resolved via {@link URI#getPort()}
+ * @param scheme scheme resolved via {@link URI#getScheme()}
+ * @return effective port
+ */
+ private static int getEffectivePort(final int port, @Nonnull @NotEmpty final String scheme) {
+ if (port != -1) {
+ return port;
+ }
+ final Integer registeredPort = SimpleURLCanonicalizer.getRegisteredPort(scheme);
+ return registeredPort != null ? registeredPort : -1;
+ }
+}
diff --git a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/AddLogoutParametersToClientMetadataTest.java b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/AddLogoutParametersToClientMetadataTest.java
index 577524a1..d3c85594 100644
--- a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/AddLogoutParametersToClientMetadataTest.java
+++ b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/AddLogoutParametersToClientMetadataTest.java
@@ -18,12 +18,14 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.util.Set;
+import org.opensaml.profile.action.EventIds;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.nimbusds.openid.connect.sdk.rp.OIDCClientMetadata;
+import net.shibboleth.idp.profile.testing.ActionTestingSupport;
import net.shibboleth.shared.component.ComponentInitializationException;
/**
@@ -65,12 +67,14 @@ public class AddLogoutParametersToClientMetadataTest extends BaseOIDCClientMetad
final URI postLogout2 = new URI("https://example.org/postLogout2");
final URI frontChannel = new URI("https://example.org/frontChannel");
final URI backChannel = new URI("https://example.org/backChannel");
+ final Set<URI> redirectUris = Set.of(new URI("https://example.org/cb"));
final OIDCClientMetadata input = new OIDCClientMetadata();
input.setPostLogoutRedirectionURIs(Set.of(postLogout1, postLogout2));
input.setFrontChannelLogoutURI(frontChannel);
input.setBackChannelLogoutURI(backChannel);
input.requiresFrontChannelLogoutSession(true);
input.requiresBackChannelLogoutSession(true);
+ input.setRedirectionURIs(redirectUris);
final OIDCClientMetadata output = new OIDCClientMetadata();
setUpContext(input, output);
Assert.assertNull(action.execute(requestCtx));
@@ -81,4 +85,103 @@ public class AddLogoutParametersToClientMetadataTest extends BaseOIDCClientMetad
Assert.assertTrue(output.requiresBackChannelLogoutSession());
}
+ @Test
+ public void testBackChannelHttp() throws URISyntaxException, ComponentInitializationException {
+ final URI backChannel = new URI("http://example.org/backChannel");
+ final OIDCClientMetadata input = new OIDCClientMetadata();
+ input.setBackChannelLogoutURI(backChannel);
+ final OIDCClientMetadata output = new OIDCClientMetadata();
+ setUpContext(input, output);
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), EventIds.INVALID_MESSAGE);
+ }
+
+ @Test
+ public void testBackChannelHttpsFragment() throws URISyntaxException, ComponentInitializationException {
+ final URI backChannel = new URI("https://example.org/backChannel#invalid");
+ final OIDCClientMetadata input = new OIDCClientMetadata();
+ input.setBackChannelLogoutURI(backChannel);
+ final OIDCClientMetadata output = new OIDCClientMetadata();
+ setUpContext(input, output);
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), EventIds.INVALID_MESSAGE);
+ }
+
+ @Test
+ public void testFrontChannelHttp() throws URISyntaxException, ComponentInitializationException {
+ final URI frontChannel = new URI("http://example.org/frontChannel");
+ final OIDCClientMetadata input = new OIDCClientMetadata();
+ input.setFrontChannelLogoutURI(frontChannel);
+ final OIDCClientMetadata output = new OIDCClientMetadata();
+ setUpContext(input, output);
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), EventIds.INVALID_MESSAGE);
+ }
+
+ @Test
+ public void testFrontChannelHttpsFragment() throws URISyntaxException, ComponentInitializationException {
+ final URI frontChannel = new URI("https://example.org/frontChannel#invalid");
+ final OIDCClientMetadata input = new OIDCClientMetadata();
+ input.setFrontChannelLogoutURI(frontChannel);
+ final OIDCClientMetadata output = new OIDCClientMetadata();
+ setUpContext(input, output);
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), EventIds.INVALID_MESSAGE);
+ }
+
+ @Test
+ public void testFrontChannelNoRedirectUri() throws URISyntaxException, ComponentInitializationException {
+ final URI frontChannel = new URI("https://example.org/frontChannel");
+ final OIDCClientMetadata input = new OIDCClientMetadata();
+ input.setFrontChannelLogoutURI(frontChannel);
+ final OIDCClientMetadata output = new OIDCClientMetadata();
+ setUpContext(input, output);
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), EventIds.INVALID_MESSAGE);
+ }
+
+ @Test
+ public void testFrontChannelHttpsWrongScheme() throws URISyntaxException, ComponentInitializationException {
+ final URI frontChannel = new URI("https://example.org/frontChannel");
+ final Set<URI> redirectUris = Set.of(new URI("http://example.org/cb"));
+ final OIDCClientMetadata input = new OIDCClientMetadata();
+ input.setFrontChannelLogoutURI(frontChannel);
+ input.setRedirectionURIs(redirectUris);
+ final OIDCClientMetadata output = new OIDCClientMetadata();
+ setUpContext(input, output);
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), EventIds.INVALID_MESSAGE);
+ }
+
+ @Test
+ public void testFrontChannelHttpsWrongHost() throws URISyntaxException, ComponentInitializationException {
+ final URI frontChannel = new URI("https://example.org/frontChannel");
+ final Set<URI> redirectUris = Set.of(new URI("https://another.example.org/cb"));
+ final OIDCClientMetadata input = new OIDCClientMetadata();
+ input.setFrontChannelLogoutURI(frontChannel);
+ input.setRedirectionURIs(redirectUris);
+ final OIDCClientMetadata output = new OIDCClientMetadata();
+ setUpContext(input, output);
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), EventIds.INVALID_MESSAGE);
+ }
+
+ @Test
+ public void testFrontChannelHttpsWrongPort() throws URISyntaxException, ComponentInitializationException {
+ final URI frontChannel = new URI("https://example.org/frontChannel");
+ final Set<URI> redirectUris = Set.of(new URI("https://example.org:8443/cb"));
+ final OIDCClientMetadata input = new OIDCClientMetadata();
+ input.setFrontChannelLogoutURI(frontChannel);
+ input.setRedirectionURIs(redirectUris);
+ final OIDCClientMetadata output = new OIDCClientMetadata();
+ setUpContext(input, output);
+ ActionTestingSupport.assertEvent(action.execute(requestCtx), EventIds.INVALID_MESSAGE);
+ }
+
+ @Test
+ public void testFrontChannelHttpsExplicitPort() throws URISyntaxException, ComponentInitializationException {
+ final URI frontChannel = new URI("https://example.org/frontChannel");
+ final Set<URI> redirectUris = Set.of(new URI("https://example.org:443/cb"));
+ final OIDCClientMetadata input = new OIDCClientMetadata();
+ input.setFrontChannelLogoutURI(frontChannel);
+ input.setRedirectionURIs(redirectUris);
+ final OIDCClientMetadata output = new OIDCClientMetadata();
+ setUpContext(input, output);
+ Assert.assertNull(action.execute(requestCtx));
+ Assert.assertEquals(output.getFrontChannelLogoutURI(), frontChannel);
+ }
+
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list