title: Shibboleth SP passing wrong user identity to application
body: <p>I have a Rails app that I've Shibbolized using Shibboleth SP (latest version - 2.4.2).  I'm using it with Apache 2.2.  My IdP is an MS AD FS 2.0 server.</p>
  
  <p>Everything seems to work well - users hit the site, are redirected to AD FS, get authenticated and then come back and are logged into the site.</p>
  
  <p>The problem is that once you've done that, it's almost impossible to log in as a different user in a timely fashion.  You can clear all your cookies (I'm trying this with Safari and Chrome on Mac) and restart the browser, but if I'm first authenticated as Alice and then try to log in as Carol I'll still get logged into the application as Alice.</p>
  
  <p>The SAML response received by shibd after clearing cookies has the correct identity in it:</p>
  
  <pre><code>&lt;AttributeStatement&gt;
    &lt;Attribute Name="http://schemas.xmlsoap.org/claims/CommonName"&gt;
      &lt;AttributeValue&gt;Carol&lt;/AttributeValue&gt;
    &lt;/Attribute&gt;
    &lt;Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"&gt;
      &lt;AttributeValue&gt;carol@dev.REDACTED.com&lt;/AttributeValue&gt;
    &lt;/Attribute&gt;
    &lt;Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn"&gt;
      &lt;AttributeValue&gt;carol@dev.REDACTED.com&lt;/AttributeValue&gt;
    &lt;/Attribute&gt;
  &lt;/AttributeStatement&gt;
  </code></pre>
  
  <p>But when Shibboleth SP passes environment variables to my app, it instead sends the wrong credentials:</p>
  
  <pre><code>[DEBUG 05/19 16:30:09]   ENV:  Shib-Session-ID =&gt; _615014991ed1b7dcc43f647ceb1f4944
  [DEBUG 05/19 16:30:09]   ENV:  Shib-Identity-Provider =&gt; http://REDACTED/adfs/services/trust
  [DEBUG 05/19 16:30:09]   ENV:  Shib-Authentication-Instant =&gt; 2011-05-19T21:17:23.861Z
  [DEBUG 05/19 16:30:09]   ENV:  Shib-Authentication-Method =&gt; urn:federation:authentication:windows
  [DEBUG 05/19 16:30:09]   ENV:  Shib-AuthnContext-Class =&gt; urn:federation:authentication:windows
  [DEBUG 05/19 16:30:09]   ENV:  Shib-Session-Index =&gt; _cadfb4e6-ffb2-45f9-aab5-6bce8c3bc17a
  [DEBUG 05/19 16:30:09]   ENV:  cn =&gt; alice
  [DEBUG 05/19 16:30:09]   ENV:  email =&gt; alice@dev.REDACTED.com
  [DEBUG 05/19 16:30:09]   ENV:  principal =&gt; alice@dev.READACTED.com
  </code></pre>
  
  <p>Despite having nuked all cookies, the Shib-Session-ID will be the same.  Somehow it seems to be associating the two interactions and re-establishing the existing session rather than making a new session with the account info from the SAML response.</p>
  
  <p>I've set all the cache timeout values I can find to 60 seconds, but waiting 2-3 minutes with browser closed isn't enough to get it to make a new session.</p>
  
  <pre><code>&lt;StorageService type="Memory" id="mem" cleanupInterval="60"/&gt;
  &lt;SessionCache type="StorageService" StorageService="mem" cacheTimeout="60" 
     inprocTimeout="60" cleanupInterval="60" /&gt;
  </code></pre>
  
  <p>...        </p>
  
  <pre><code>&lt;Sessions lifetime="60" timeout="60" checkAddress="false" relayState="ss:mem"
      handlerSSL="false"&gt;
  </code></pre>
  
  <p>Restarting apache and shibd works, as does closing the browser and letting it sit for a long time (10-15 minutes?)  I don't have a solid read on exactly how long it takes.</p>
  
  <p>What am I missing?  What other avenues should I pursue?</p>