title: Exclude Manager from Tomcat Single Sign On
body: <p>Using JAAS for SSO on a Tomcat server sans Apache. The SSO controls access to several related applications and works great. Recently I started migrating to Maven from Ant and in order to use the Tomcat plugin for Maven I needed to setup the Tomcat Manager application which I had no need to previously. I was able to get it up and running both with BASIC authentication, or CLIENT-CERT authentication, alongside the other webapps on the server.</p>
  
  <p>The problem that I am having is when the user authenticates in manager, the session gets dropped for the other webapps - IE login to webapp, login to Manager, refresh webapp, redirected to login page.</p>
  
  <p>I was able to mitigate this overlap by defining the SSO valve at the context level and the realm at the host level. This still allows the SSO to work when navigating between the webapps via the browser. However, cross context AJAX requests and whatnot return a "User Not Logged In" error, until I access the other webapp in question. Using this approach authentication for Manager was effectively isolated from the other webapps.</p>
  
  <p>In short, I'm looking for the best way to have SSO via SSL/Database Authentication available for my webapps using a JAAS authentication module, but force Tomcat to exclude Manager from the SSO. IE SSO via SSL for Webapps 1,2,3 but UN/PW authentication independent of the SSO for Manager, with authentication independent between the two.</p>
  
  <p>Is there a way to do this?</p>
  
  <p>Current config:</p>
  
  <pre><code>&lt;Engine name="Catalina" defaultHost="localhost"&gt;
  
    &lt;Host name="localhost" appBase="webapps"
          unpackWARs="true" autoDeploy="false"
          xmlValidation="false" xmlNamespaceAware="false"&gt;
  
      &lt;Realm className="org.apache.catalina.realm.JAASRealm" appName="CustomLogin"
             userClassNames="com.foo.bar.User" roleClassNames="com.foo.bar.Role"
             useContextClassLoader="true" debug="false"/&gt;
      &lt;Valve className="org.apache.catalina.authenticator.SingleSignOn"/&gt;
  
      &lt;Context path="/Webapp1" docBase="webapp1"&gt;
          &lt;ResourceLink name="jdbc/WEBAPP" global="jdbc/WEBAPP" type="java.sql.DataSource"/&gt;
      &lt;/Context&gt;
  
      &lt;Context path="/Webapp2" docBase="webapp2"&gt;
          &lt;ResourceLink name="jdbc/WEBAPP" global="jdbc/WEBAPP" type="java.sql.DataSource"/&gt;
      &lt;/Context&gt;
  
      &lt;Context path="/Webapp3" docBase="Webapp3"&gt;
          &lt;ResourceLink name="jdbc/WEBAPP" global="jdbc/WEBAPP" type="java.sql.DataSource"/&gt;
      &lt;/Context&gt;
  
      &lt;Context path="/manager" docBase="manager" AntiJARLocking="false" antiResourceLocking="false" privileged="true" reloadable="false"&gt;
          &lt;Realm className="org.apache.catalina.realm.MemoryRealm"&gt;&lt;/Realm&gt;
          &lt;Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="manager_access_log." suffix=".txt" pattern="common" resolveHosts="false"/&gt;
      &lt;/Context&gt;
    &lt;/Host&gt;
  &lt;/Engine&gt;
  </code></pre>
  
  <p>Using this config, all webapps and the Manager fall under the control of the SSO and the overlap outlined above occurs - IE login to webapp1 via SSL, then Manager via UN/PW, then refresh webapp1, redirected to login page.</p>
  
  <p>Moving the SSO valve to the contexts for the webapps resolves this issue but causes the "User not logged in" response for cross context AJAX requests.</p>