[java-oidc-common] branch maint-3.4 updated: JCOMOIDC-204 - Default URI validation condition for backend calls
Codeberg
noreply at shibboleth.net
Sat Nov 28 16:46:42 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch maint-3.4
in repository java-oidc-common.
View the commit online:
https://codeberg.org/Shibboleth/java-oidc-common/commit/c473f64b4b03152187ee3eb402d2fa57c65ab176
The following commit(s) were added to refs/heads/maint-3.4 by this push:
new c473f64b JCOMOIDC-204 - Default URI validation condition for backend calls
c473f64b is described below
commit c473f64b4b03152187ee3eb402d2fa57c65ab176
Author: Henri Mikkonen <henri.mikkonen at iki.fi>
AuthorDate: Sat Nov 28 18:45:24 2026 +0200
JCOMOIDC-204 - Default URI validation condition for backend calls
https://shibboleth.atlassian.net/browse/JCOMOIDC-204
- Add unit tests
---
...faultBackChannelUriValidationConditionTest.java | 165 +++++++++++++++++++++
1 file changed, 165 insertions(+)
diff --git a/oidc-common-crypto-impl/src/test/java/net/shibboleth/oidc/security/impl/DefaultBackChannelUriValidationConditionTest.java b/oidc-common-crypto-impl/src/test/java/net/shibboleth/oidc/security/impl/DefaultBackChannelUriValidationConditionTest.java
new file mode 100644
index 00000000..1466126c
--- /dev/null
+++ b/oidc-common-crypto-impl/src/test/java/net/shibboleth/oidc/security/impl/DefaultBackChannelUriValidationConditionTest.java
@@ -0,0 +1,165 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.oidc.security.impl;
+
+import java.net.URI;
+import java.util.Collection;
+
+import javax.annotation.Nonnull;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import net.shibboleth.shared.collection.CollectionSupport;
+import net.shibboleth.shared.component.ComponentInitializationException;
+import net.shibboleth.shared.net.IPRange;
+
+/**
+ * Unit tests for {@link DefaultBackChannelUriValidationCondition}.
+ */
+public class DefaultBackChannelUriValidationConditionTest {
+
+ @Nonnull public static final Collection<IPRange> DEFAULT_DISALLOWED_RANGE = CollectionSupport.listOf(
+ IPRange.parseCIDRBlock("127.0.0.0/8"), IPRange.parseCIDRBlock("::1/128"),
+ IPRange.parseCIDRBlock("0.0.0.0/8"), IPRange.parseCIDRBlock("::/128"),
+ IPRange.parseCIDRBlock("169.254.0.0/16"), IPRange.parseCIDRBlock("fe80::/10"),
+ IPRange.parseCIDRBlock("224.0.0.0/4"), IPRange.parseCIDRBlock("ff00::/8"),
+ IPRange.parseCIDRBlock("::/96"));
+
+ DefaultBackChannelUriValidationCondition condition;
+
+ public void setup(final boolean https) {
+ setup(https, DEFAULT_DISALLOWED_RANGE);
+ }
+
+ public void setup(final boolean https, @Nonnull final Collection<IPRange> ranges) {
+ condition = new DefaultBackChannelUriValidationCondition();
+ condition.setRequireHttps(https);
+ condition.setDisallowedRanges(ranges);
+ condition.setId("mockId");
+ try {
+ condition.initialize();
+ } catch (ComponentInitializationException e) {
+ Assert.fail("Initialization failed", e);
+ }
+ }
+
+ @Test
+ public void testLoopback() {
+ setup(false);
+ Assert.assertFalse(condition.test(URI.create("http://localhost/mock")));
+ Assert.assertFalse(condition.test(URI.create("http://127.0.0.1/mock")));
+ Assert.assertFalse(condition.test(URI.create("http://[::1]/mock")));
+ Assert.assertFalse(condition.test(URI.create("http://[::ffff:127.0.0.1]/mock")));
+ Assert.assertFalse(condition.test(URI.create("http://[::127.0.0.1]/mock")));
+ Assert.assertFalse(condition.test(URI.create("https://localhost/mock")));
+ Assert.assertFalse(condition.test(URI.create("https://127.0.0.1/mock")));
+ Assert.assertFalse(condition.test(URI.create("https://[::1]/mock")));
+ Assert.assertFalse(condition.test(URI.create("https://[::ffff:127.0.0.1]/mock")));
+ Assert.assertFalse(condition.test(URI.create("https://[::127.0.0.1]/mock")));
+ }
+
+ @Test
+ public void testAny() {
+ setup(false);
+ Assert.assertFalse(condition.test(URI.create("http://0.0.0.0/mock")));
+ Assert.assertFalse(condition.test(URI.create("http://[::]/mock")));
+ Assert.assertFalse(condition.test(URI.create("https://0.0.0.0/mock")));
+ Assert.assertFalse(condition.test(URI.create("https://[::]/mock")));
+ }
+
+ @Test
+ public void testLinkLocal() {
+ setup(false);
+ Assert.assertFalse(condition.test(URI.create("http://169.254.169.254/mock")));
+ Assert.assertFalse(condition.test(URI.create("http://[fe80::1]/mock")));
+ Assert.assertFalse(condition.test(URI.create("https://169.254.169.254/mock")));
+ Assert.assertFalse(condition.test(URI.create("https://[fe80::1]/mock")));
+ }
+
+ @Test
+ public void testMulticast() {
+ setup(false);
+ Assert.assertFalse(condition.test(URI.create("http://224.0.0.1/mock")));
+ Assert.assertFalse(condition.test(URI.create("http://[ff02::1]/mock")));
+ Assert.assertFalse(condition.test(URI.create("https://224.0.0.1/mock")));
+ Assert.assertFalse(condition.test(URI.create("https://[ff02::1]/mock")));
+ }
+
+ @Test
+ public void testNoHostHttp() {
+ setup(false);
+ Assert.assertFalse(condition.test(URI.create("http:///mock")));
+ }
+
+ @Test
+ public void testNoHostHttps() {
+ setup(false);
+ Assert.assertFalse(condition.test(URI.create("https:///mock")));
+ }
+
+ @Test
+ public void testPublicLiteralsHttp() {
+ setup(false);
+ Assert.assertTrue(condition.test(URI.create("http://192.0.2.10/mock")));
+ Assert.assertTrue(condition.test(URI.create("https://192.0.2.10/mock")));
+ Assert.assertTrue(condition.test(URI.create("http://[2001:db8::10]/mock")));
+ Assert.assertTrue(condition.test(URI.create("https://[2001:db8::10]/mock")));
+ }
+
+ @Test
+ public void testPublicLiteralsHttpsRequired() {
+ setup(true);
+ Assert.assertFalse(condition.test(URI.create("http://192.0.2.10/mock")));
+ Assert.assertTrue(condition.test(URI.create("https://192.0.2.10/mock")));
+ Assert.assertFalse(condition.test(URI.create("http://[2001:db8::10]/mock")));
+ Assert.assertTrue(condition.test(URI.create("https://[2001:db8::10]/mock")));
+ }
+
+ @Test
+ public void testEmptyDisallowedRangesHttpAllowed() {
+ setup(false, CollectionSupport.emptyList());
+ Assert.assertTrue(condition.test(URI.create("http://localhost/mock")));
+ Assert.assertTrue(condition.test(URI.create("http://127.0.0.1/mock")));
+ Assert.assertTrue(condition.test(URI.create("http://[::1]/mock")));
+ Assert.assertTrue(condition.test(URI.create("http://[::ffff:127.0.0.1]/mock")));
+ Assert.assertTrue(condition.test(URI.create("http://[::127.0.0.1]/mock")));
+ Assert.assertTrue(condition.test(URI.create("http://169.254.169.254/mock")));
+
+ Assert.assertFalse(condition.test(URI.create("http:///mock")));
+ Assert.assertFalse(condition.test(URI.create("https:///mock")));
+ }
+
+ @Test
+ public void testEmptyDisallowedRangesHttpsRequired() {
+ setup(true, CollectionSupport.emptyList());
+ Assert.assertFalse(condition.test(URI.create("http://localhost/mock")));
+ Assert.assertFalse(condition.test(URI.create("http://127.0.0.1/mock")));
+ Assert.assertFalse(condition.test(URI.create("http://[::1]/mock")));
+ Assert.assertFalse(condition.test(URI.create("http://[::ffff:127.0.0.1]/mock")));
+ Assert.assertFalse(condition.test(URI.create("http://[::127.0.0.1]/mock")));
+ Assert.assertFalse(condition.test(URI.create("http://169.254.169.254/mock")));
+
+ Assert.assertFalse(condition.test(URI.create("http:///mock")));
+ Assert.assertFalse(condition.test(URI.create("https:///mock")));
+
+ Assert.assertTrue(condition.test(URI.create("https://localhost/mock")));
+ Assert.assertTrue(condition.test(URI.create("https://127.0.0.1/mock")));
+ Assert.assertTrue(condition.test(URI.create("https://[::1]/mock")));
+ Assert.assertTrue(condition.test(URI.create("https://[::ffff:127.0.0.1]/mock")));
+ Assert.assertTrue(condition.test(URI.create("https://[::127.0.0.1]/mock")));
+ Assert.assertTrue(condition.test(URI.create("https://169.254.169.254/mock")));
+ }
+}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list