Hello--I'm working on a web app that uses SSP configured as an SP.The app is being developed in the Zend framework.The client has the IdP.I can authenticate initially and everything works as expected.But once the default-sp session expires (90 secs), when I try to access aresource, the browser gets a 303.
The 303 is generated by the Utilities.php file that looks for thefollowing condition:if($_SERVER['SERVER_PROTOCOL'] === 'HTTP/1.1' &&$_SERVER['REQUEST_METHOD'] === 'POST') {
When this condition is encountered, SSP generates a simpleweb page with a redirect link.The event path seems to be this:1) the client tries to access a resource.2) SSP redirects the client to the login page.3) client authenticates.4) client tries to access a controller via AJAX.5) the controller uses curl to call a web-service.6) the web-service returns a JSON object.7) the controller returns an HTML string to the AJAX call in the client.8) the client displays the HTML.9) the world sings and is happy.10) default-sp session expires.11) client tries to access a controller via AJAX.12) SSP tries to redirect to the login page, but hangs and reports a 303.
As far as I can tell, everything I'm doing is HTTPS. How can it be that the protocol is HTTP? In fact, the same call will succeed and then (after about 90 seconds) fail with a 303.
I dumped the $_SERVER variable in php. It looks like this:([REDIRECT_HTTPS] => on
I've checked my controllers to make sure I don't have any stray blank lines that would make the headers choke.Can anyone point me in the right direction for resolving this?
But once the default-sp session expires (90 secs), when I try to access aresource, the browser gets a 303.Why setting the session so short?
The 303 is generated by the Utilities.php file that looks for thefollowing condition:if($_SERVER['SERVER_PROTOCOL'] === 'HTTP/1.1' &&$_SERVER['REQUEST_METHOD'] === 'POST') {That's standard behavior. HTTP 303 appears in HTTP/1.1 and is suitable to redirect a client when the request is a POST, hence both checks.
What does it mean "hangs and reports a 303"? A HTTP 303 status code is a redirection with a Location header. Therefore, the browser should redirect to the value contained in that header, but never "hang and report".
Indeed, there's nothing indicating that you are using plain HTTP. If you say that because of the previous code that generates the 303, bear in mind that the check is for the _version_ of HTTP, not whether it is secured inside SSL/TLS or not.
Everything looks correct. Your session is expired, therefore you need to go to the IdP to renew it (or re-authenticate the user, if the session in the IdP expired too).
My advise is to use firefox + SAML tracer extension or something analogous, capture all the messages required to login (fresh start, no cookies) and to trigger the error, save them to a file, and go through them to see the responses from SSP and why the browser is not following the redirection.
POST https://xxx.yyy.com/c-i/f-i/ HTTP/1.1 Host: xxx.yyy.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0 Accept: */* Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Content-Type: application/x-www-form-urlencoded; charset=UTF-8 X-Requested-With: XMLHttpRequest Referer: https://xxx.yyy.com/c-i
Content-Length: 13 Cookie: PHPSESSID=23f5b33356639297c6eaed04faa0e26a; SimpleSAMLAuthToken=_604ef0009fa0e991de803b11a42881815711246612 HTTP/?.? 303 See Other Date: Tue, 16 Jul 2013 13:47:42 GMT Server: Apache/2.2.23 (Unix) mod_ssl/2.2.23 OpenSSL/1.0.1c PHP/5.4.12 X-Powered-By: PHP/5.4.12 Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-cache, must-revalidate Pragma: no-cache Location: https://client.idp.com/saml2sso?SAMLRequest=123Lj9MwEP4rke95tkqK1VYqWyEqLVBtC4e9rBx73Fg4ttdjs%2FDvcZNFLAd6Gmnme8x8mjWyUTu6i2EwD%2FAcAUP2c9QG6TTYkOgNtQwVUsNGQBo4Pe0%2B3dOmqKjzNlhuNXlDuc1giOCDsoZkh%2F2GPLVysRJctvwd62HVNaLqG7ashaialey7FetWTdO1C9mS7Bt4TMwNSUKJjhjhYDAwE1Krqhd51eV1e64XdNnRZfNIsn26RhkWJtYQgkNalkq4XATD8pCmxTMrpAd1GYJWBnzB7VgyKV%2BgT4v%2BUBywdLHXipfX4xpES7LdnyPurME4gj%2FN0K8P939trhZD7IswKPOdM3%2Bxkzaq0Wm4apWjFVFD4QY3aZc41yZnHKeuAMmiDjk6kh1fo36vjFDmcjvlfgYh%2FXg%2BH%2FPjl9OZbNdXbTql5re3l1yXb7Hr%2BUM%2BJ5fD%2FmhTFL%2ByD9aPLPx%2Fibqop44SuZygNBp0wJVUIFKAWtuXOw8swIYEH4GU29n030%2Fc%2FgY%3D&RelayState=https%3A%2F%2Fxxx.yyy.com%2Fsimplesaml%2Fmodule.php%2Fcore%2Fpostredirect.php%3FRedirId%3D_b88dca1eafd2c27648d6641ab8b05e418ca25f2a23 Content-Length: 2946 Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Content-Type: text/html
The request decodes to this:
<samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="_6f38dcf6c9abe872d0b2a41dd028fb78a7822763f6"
Version="2.0" IssueInstant="2013-07-16T13:47:42Z" Destination="https://client.idp.com/saml2sso" AssertionConsumerServiceURL="https://xxx.yyy.com/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp" ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST">
<saml:Issuer>
https://xxx.yyy.com</saml:Issuer><samlp:NameIDPolicy
Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified" AllowCreate="true"/>
</samlp:AuthnRequest>
My impression is that your problem is related to the use of AJAX on resources unnecessarily protected by SSP.
Maybe you should manually capture the redirection and force a refresh of the page when that happens.
And, of course, raise the session time. 90 secs is just too short.
Why setting the session so short?I did not modify any timeout settings. I say the session expires in 90 seconds based only on my testing. If there's a way to lengthen that timeout, that's fine. But I did not change any default timeouts. This is simply the behavior I'm observing.
Everything looks correct. Your session is expired, therefore you need to go to the IdP to renew it (or re-authenticate the user, if the session in the IdP expired too).## Correct. It seems though that when it tries to go to the IdP, a 303 is reported and further processing stops.
POST https://xxx.yyy.com/c-i/f-i/ HTTP/1.1Host: xxx.yyy.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0 Accept: */* Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Content-Type: application/x-www-form-urlencoded; charset=UTF-8 X-Requested-With: XMLHttpRequest Referer: https://xxx.yyy.com/c-i
Content-Length: 13 Cookie: PHPSESSID=23f5b33356639297c6eaed04faa0e26a; SimpleSAMLAuthToken=_604ef0009fa0e991de803b11a42881815711246612 HTTP/?.? 303 See Other
Date: Tue, 16 Jul 2013 13:47:42 GMT Server: Apache/2.2.23 (Unix) mod_ssl/2.2.23 OpenSSL/1.0.1c PHP/5.4.12 X-Powered-By: PHP/5.4.12 Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-cache, must-revalidate Pragma: no-cache Location: https://client.idp.com/saml2sso?SAMLRequest=123Lj9MwEP4rke95tkqK1VYqWyEqLVBtC4e9rBx73Fg4ttdjs%2FDvcZNFLAd6Gmnme8x8mjWyUTu6i2EwD%2FAcAUP2c9QG6TTYkOgNtQwVUsNGQBo4Pe0%2B3dOmqKjzNlhuNXlDuc1giOCDsoZkh%2F2GPLVysRJctvwd62HVNaLqG7ashaialey7FetWTdO1C9mS7Bt4TMwNSUKJjhjhYDAwE1Krqhd51eV1e64XdNnRZfNIsn26RhkWJtYQgkNalkq4XATD8pCmxTMrpAd1GYJWBnzB7VgyKV%2BgT4v%2BUBywdLHXipfX4xpES7LdnyPurME4gj%2FN0K8P939trhZD7IswKPOdM3%2Bxkzaq0Wm4apWjFVFD4QY3aZc41yZnHKeuAMmiDjk6kh1fo36vjFDmcjvlfgYh%2FXg%2BH%2FPjl9OZbNdXbTql5re3l1yXb7Hr%2BUM%2BJ5fD%2FmhTFL%2ByD9aPLPx%2Fibqop44SuZygNBp0wJVUIFKAWtuXOw8swIYEH4GU29n030%2Fc%2FgY%3D&RelayState=https%3A%2F%2Fxxx.yyy.com%2Fsimplesaml%2Fmodule.php%2Fcore%2Fpostredirect.php%3FRedirId%3D_b88dca1eafd2c27648d6641ab8b05e418ca25f2a23 Content-Length: 2946 Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Content-Type: text/html
The request decodes to this:<samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="_6f38dcf6c9abe872d0b2a41dd028fb78a7822763f6"Version="2.0" IssueInstant="2013-07-16T13:47:42Z" Destination="https://client.idp.com/saml2sso" AssertionConsumerServiceURL="https://xxx.yyy.com/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp" ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"><saml:Issuer>https://xxx.yyy.com</saml:Issuer><samlp:NameIDPolicyFormat="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified" AllowCreate="true"/></samlp:AuthnRequest>
When I get this 303 response, the browser does not redirect.It just sits around smoking a cigarette and asking for another beer.
My impression is that your problem is related to the use of AJAX on resources unnecessarily protected by SSP.It is currently the case that every resource is protected by SSP. Thus, any time a user tries to access a resource (directly or by AJAX), we check his session. In what case would resources not be protected on a site for which every resource should only be accessible to users who have authenticated through SAML?
And, of course, raise the session time. 90 secs is just too short.I agree, but I didn't change any defaults. The 90 secs that I reported is based on my observations in using the system and reviewing the logs.
HTTP/?.? 303 See OtherYou didn't modify the HTTP version number, did you? Could you somehow verify if you are actually receiving that "HTTP/?.?" string? That sounds like a source of problems. But honestly, I have no idea on where that problem could come from...
Expires: Thu, 19 Nov 1981 08:52:00 GMTExcept for the problem in the status line, at first sight everything looks fine. The expiration date is weird though (1981?), but I guess it might be related to cache-control?