[java-idp-oidc] branch main updated: JOIDC-164 - Eliminate custom filter in favor of IdP header support
Scott Cantor
cantor.2 at osu.edu
Wed Aug 2 14:17:29 UTC 2023
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-idp-oidc.
View the commit online:
http://git.shibboleth.net/view/?p=java-idp-oidc.git;a=commit;h=7207b439a615b43de170c1a0c9a9ca5f76056bf6
The following commit(s) were added to refs/heads/main by this push:
new 7207b439 JOIDC-164 - Eliminate custom filter in favor of IdP header support
7207b439 is described below
commit 7207b439a615b43de170c1a0c9a9ca5f76056bf6
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Aug 2 10:17:26 2023 -0400
JOIDC-164 - Eliminate custom filter in favor of IdP header support
https://shibboleth.atlassian.net/browse/JOIDC-164
Remove OP filter and context initializer.
Add URLPrefix beans to auto-wire the plugin paths into IdP.
---
.../RegisterFilterServletContextInitializer.java | 95 ----------------------
.../idp/plugin/oidc/op/servlet/package-info.java | 16 ----
.../META-INF/net.shibboleth.idp/postconfig.xml | 7 +-
.../javax.servlet.ServletContainerInitializer | 1 -
4 files changed, 3 insertions(+), 116 deletions(-)
diff --git a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/servlet/RegisterFilterServletContextInitializer.java b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/servlet/RegisterFilterServletContextInitializer.java
deleted file mode 100644
index 901693d8..00000000
--- a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/servlet/RegisterFilterServletContextInitializer.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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.idp.plugin.oidc.op.servlet;
-
-import java.util.Set;
-
-import javax.annotation.Nonnull;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.web.filter.DelegatingFilterProxy;
-
-import jakarta.servlet.FilterRegistration;
-import jakarta.servlet.ServletContainerInitializer;
-import jakarta.servlet.ServletContext;
-import jakarta.servlet.ServletException;
-import net.shibboleth.shared.primitive.StringSupport;
-
-/**
- * A {@link ServletContainerInitializer} implementation that registers dynamic response header filter for enabling
- * configurable headers. The target bean name is {@link RegisterFilterServletContextInitializer#TARGET_BEAN_NAME}.
- *
- * The filter registration can be disabled by setting the system property
- * {@link RegisterFilterServletContextInitializer#SYSTEM_PROPERTY_ACTIVATION} to <pre>disabled</pre>.
- *
- * The filter mappings can be configured via space-separated list on the system property
- * {@link RegisterFilterServletContextInitializer#SYSTEM_PROPERTY_MAPPINGS}. By default the value is
- * <pre>/profile/oidc/* /profile/oauth2/</pre>.
- */
-public class RegisterFilterServletContextInitializer implements ServletContainerInitializer {
-
- /** System property name for the activation flag of this class. */
- public static final String SYSTEM_PROPERTY_ACTIVATION =
- RegisterFilterServletContextInitializer.class.getCanonicalName();
-
- /** System property name for configuring the filter mappings. */
- public static final String SYSTEM_PROPERTY_MAPPINGS =
- SYSTEM_PROPERTY_ACTIVATION + ".mappings";
-
- /** The filter name for the dynamic response header filter for the OP's flows. */
- public static final String FILTER_NAME_DYNAMIC_OIDC_RESPONSE_HEADER = "DynamicOidcResponseHeaderFilter";
-
- /** The target bean name for the dynamic response header filter. */
- public static final String TARGET_BEAN_NAME = "shibboleth.oidc.ResponseHeaderFilter";
-
- /** The value for the filter mappings, if no custom configuration is set. */
- public static final String DEFAULT_MAPPINGS = "/profile/oidc/* /profile/oauth2/*";
-
- /** Class logger. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(RegisterFilterServletContextInitializer.class);
-
- /** {@inheritDoc} */
- @Override
- public void onStartup(final Set<Class<?>> c, final ServletContext ctx) throws ServletException {
- final String flag = System.getProperty(SYSTEM_PROPERTY_ACTIVATION);
- log.debug("The value of the flag {}: {}", SYSTEM_PROPERTY_ACTIVATION, flag);
- if ("disabled".equalsIgnoreCase(flag)) {
- log.info("The filter registration is disabled according to the system properties");
- return;
- }
-
- log.debug("Attempting to register filter {}", FILTER_NAME_DYNAMIC_OIDC_RESPONSE_HEADER);
- final FilterRegistration.Dynamic headerFilter = ctx.addFilter(FILTER_NAME_DYNAMIC_OIDC_RESPONSE_HEADER,
- DelegatingFilterProxy.class);
- final String mappings;
- if (StringSupport.trimOrNull(System.getProperty(SYSTEM_PROPERTY_MAPPINGS)) == null) {
- mappings = DEFAULT_MAPPINGS;
- log.debug("Using default mappings: {}", DEFAULT_MAPPINGS);
- } else {
- mappings = System.getProperty(SYSTEM_PROPERTY_MAPPINGS);
- log.debug("Using custom mappings: {}", mappings);
- }
-
- for (final String mapping : mappings.split(" ")) {
- headerFilter.addMappingForUrlPatterns(null, false, mapping);
- log.debug("Mapping added for the following pattern: {}", mapping);
- }
- headerFilter.setInitParameter("targetBeanName", TARGET_BEAN_NAME);
-
- log.info("Registered the filter '{}'.", FILTER_NAME_DYNAMIC_OIDC_RESPONSE_HEADER);
-
- }
-}
diff --git a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/servlet/package-info.java b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/servlet/package-info.java
deleted file mode 100644
index 05132f7b..00000000
--- a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/servlet/package-info.java
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * 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.
- */
-
-/** Classes extending/exploiting the Java Servlet API. */
-package net.shibboleth.idp.plugin.oidc.op.servlet;
\ No newline at end of file
diff --git a/idp-oidc-extension-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml b/idp-oidc-extension-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml
index 9f1b7760..80f272ba 100644
--- a/idp-oidc-extension-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml
+++ b/idp-oidc-extension-impl/src/main/resources/META-INF/net.shibboleth.idp/postconfig.xml
@@ -309,11 +309,10 @@
</property>
</bean>
- <alias name="%{idp.oidc.ResponseHeaderFilter:shibboleth.oidc.EmptyResponseHeaderFilter}"
- alias="shibboleth.oidc.ResponseHeaderFilter" />
+ <!-- Path prefixes for IdP response header filter coverage. -->
+ <bean class="net.shibboleth.shared.spring.servlet.URLPrefix" c:_0="/profile/oidc/" />
+ <bean class="net.shibboleth.shared.spring.servlet.URLPrefix" c:_0="/profile/oauth2/" />
- <bean id="shibboleth.oidc.EmptyResponseHeaderFilter"
- class="net.shibboleth.shared.spring.servlet.impl.DynamicResponseHeaderFilter" />
<bean id="cacheFactory" class="net.shibboleth.oidc.metadata.cache.impl.MetadataCacheBuilder$Builder"/>
diff --git a/idp-oidc-extension-impl/src/main/resources/META-INF/services/javax.servlet.ServletContainerInitializer b/idp-oidc-extension-impl/src/main/resources/META-INF/services/javax.servlet.ServletContainerInitializer
deleted file mode 100644
index 7614630a..00000000
--- a/idp-oidc-extension-impl/src/main/resources/META-INF/services/javax.servlet.ServletContainerInitializer
+++ /dev/null
@@ -1 +0,0 @@
-net.shibboleth.idp.plugin.oidc.op.servlet.RegisterFilterServletContextInitializer
\ 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