You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2020/04/01 12:46:26 UTC

[tomcat] branch master updated: Add SSO cookieName configuration attribute

This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
     new a41c2a4  Add SSO cookieName configuration attribute
a41c2a4 is described below

commit a41c2a4710200d7fc99078ab17232f1fcaa16788
Author: remm <re...@apache.org>
AuthorDate: Wed Apr 1 14:46:04 2020 +0200

    Add SSO cookieName configuration attribute
---
 .../catalina/authenticator/AuthenticatorBase.java  |  2 +-
 .../apache/catalina/authenticator/Constants.java   |  1 +
 .../catalina/authenticator/SingleSignOn.java       | 23 +++++++++++++++++++++-
 webapps/docs/changelog.xml                         |  4 ++++
 webapps/docs/config/valve.xml                      |  5 +++++
 5 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/authenticator/AuthenticatorBase.java b/java/org/apache/catalina/authenticator/AuthenticatorBase.java
index 00a02a8..183b575 100644
--- a/java/org/apache/catalina/authenticator/AuthenticatorBase.java
+++ b/java/org/apache/catalina/authenticator/AuthenticatorBase.java
@@ -1179,7 +1179,7 @@ public abstract class AuthenticatorBase extends ValveBase
         if (ssoId == null) {
             // Construct a cookie to be returned to the client
             ssoId = sessionIdGenerator.generateSessionId();
-            Cookie cookie = new Cookie(Constants.SINGLE_SIGN_ON_COOKIE, ssoId);
+            Cookie cookie = new Cookie(sso.getCookieName(), ssoId);
             cookie.setMaxAge(-1);
             cookie.setPath("/");
 
diff --git a/java/org/apache/catalina/authenticator/Constants.java b/java/org/apache/catalina/authenticator/Constants.java
index 7977d55..f7c1b71 100644
--- a/java/org/apache/catalina/authenticator/Constants.java
+++ b/java/org/apache/catalina/authenticator/Constants.java
@@ -17,6 +17,7 @@
 package org.apache.catalina.authenticator;
 
 public class Constants {
+
     // Authentication methods for login configuration
     // Servlet spec schemes are defined in HttpServletRequest
     // Vendor specific schemes
diff --git a/java/org/apache/catalina/authenticator/SingleSignOn.java b/java/org/apache/catalina/authenticator/SingleSignOn.java
index 0233dd8..18f8791 100644
--- a/java/org/apache/catalina/authenticator/SingleSignOn.java
+++ b/java/org/apache/catalina/authenticator/SingleSignOn.java
@@ -94,6 +94,10 @@ public class SingleSignOn extends ValveBase {
      */
     private String cookieDomain;
 
+    /**
+     * SSO cookie name, the default value is <code>JSESSIONIDSSO</code>.
+     */
+    private String cookieName = Constants.SINGLE_SIGN_ON_COOKIE;
 
     // ------------------------------------------------------------- Properties
 
@@ -123,6 +127,23 @@ public class SingleSignOn extends ValveBase {
 
 
     /**
+     * @return the cookie name
+     */
+    public String getCookieName() {
+        return cookieName;
+    }
+
+
+    /**
+     * Set the cookie name that will be used for the SSO cookie.
+     * @param cookieName the cookieName to set
+     */
+    public void setCookieName(String cookieName) {
+        this.cookieName = cookieName;
+    }
+
+
+    /**
      * Gets whether each request needs to be reauthenticated (by an
      * Authenticator downstream in the pipeline) to the security
      * <code>Realm</code>, or if this Valve can itself bind security info
@@ -227,7 +248,7 @@ public class SingleSignOn extends ValveBase {
         Cookie cookies[] = request.getCookies();
         if (cookies != null) {
             for (int i = 0; i < cookies.length; i++) {
-                if (Constants.SINGLE_SIGN_ON_COOKIE.equals(cookies[i].getName())) {
+                if (cookieName.equals(cookies[i].getName())) {
                     cookie = cookies[i];
                     break;
                 }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index c6ebff4..05fe60e 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -121,6 +121,10 @@
         <bug>64265</bug>: Fix ETag comparison performed by the default servlet.
         The default servley always uses weak comparison. (markt)
       </fix>
+      <update>
+        Add <code>cookieName</code> attribute to the SSO valve to configure the
+        SSO cookie name. (remm)
+      </update>
     </changelog>
   </subsection>
   <subsection name="Coyote">
diff --git a/webapps/docs/config/valve.xml b/webapps/docs/config/valve.xml
index 4afdbc0..fe97f8e 100644
--- a/webapps/docs/config/valve.xml
+++ b/webapps/docs/config/valve.xml
@@ -1166,6 +1166,11 @@
         <p>Sets the host domain to be used for sso cookies.</p>
       </attribute>
 
+      <attribute name="cookieName" required="false">
+        <p>Sets the cookie name to be used for sso cookies. The default value
+        is <code>JSESSIONIDSSO</code></p>
+      </attribute>
+
     </attributes>
 
   </subsection>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org