[java-identity-provider] branch main updated: IDP-1506 - Stop SLF4JMDCServletFilter from always creating HTTP session
Scott Cantor
cantor.2 at osu.edu
Thu Feb 18 19:17:37 UTC 2021
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=52537664df55ce9a25e79a0fa6b690a27e859a7d
The following commit(s) were added to refs/heads/main by this push:
new 52537664d IDP-1506 - Stop SLF4JMDCServletFilter from always creating HTTP session
52537664d is described below
commit 52537664df55ce9a25e79a0fa6b690a27e859a7d
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Feb 18 14:17:33 2021 -0500
IDP-1506 - Stop SLF4JMDCServletFilter from always creating HTTP session
https://issues.shibboleth.net/jira/browse/IDP-1506
Add filter parameter to skip session creation.
---
.../java/net/shibboleth/idp/log/SLF4JMDCServletFilter.java | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/idp-core/src/main/java/net/shibboleth/idp/log/SLF4JMDCServletFilter.java b/idp-core/src/main/java/net/shibboleth/idp/log/SLF4JMDCServletFilter.java
index 1ce6fbb3e..85256a5a6 100644
--- a/idp-core/src/main/java/net/shibboleth/idp/log/SLF4JMDCServletFilter.java
+++ b/idp-core/src/main/java/net/shibboleth/idp/log/SLF4JMDCServletFilter.java
@@ -54,6 +54,9 @@ public class SLF4JMDCServletFilter implements Filter {
/** MDC attribute name for container session ID. */
@Nonnull @NotEmpty public static final String JSESSIONID_MDC_ATTRIBUTE = "idp.jsessionid";
+ /** Whether to create a session if it doesn't already exist. */
+ private boolean createSession;
+
/** {@inheritDoc} */
@Override
public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain)
@@ -64,7 +67,7 @@ public class SLF4JMDCServletFilter implements Filter {
MDC.put(SERVER_ADDRESS_MDC_ATTRIBUTE, request.getServerName());
MDC.put(SERVER_PORT_MDC_ATTRIBUTE, Integer.toString(request.getServerPort()));
if (request instanceof HttpServletRequest) {
- final HttpSession session = ((HttpServletRequest) request).getSession();
+ final HttpSession session = ((HttpServletRequest) request).getSession(createSession);
if (session != null) {
MDC.put(JSESSIONID_MDC_ATTRIBUTE, session.getId());
}
@@ -79,7 +82,12 @@ public class SLF4JMDCServletFilter implements Filter {
/** {@inheritDoc} */
@Override
public void init(final FilterConfig filterConfig) throws ServletException {
- // nothing to do
+ final String param = filterConfig.getInitParameter("createSession");
+ if (param != null) {
+ createSession = Boolean.valueOf(param);
+ } else {
+ createSession = true;
+ }
}
/** {@inheritDoc} */
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list