Note that there are some explanatory texts on larger screens.

plurals
  1. PO Browser doesn't follow redirect from an AJAX response (PHP-generated response is using CAS authentication)
    primarykey
    data
    text
    <p>Ok, It looks like I made a mistake with my initial question. So, here are some corrections. The answer still applies, because the second redirect is stopped when there is a change in protocol to HTTPS (SSL).</p> <p>In my case, I have a redirect occurring multiple times, and the browser doesn't follow the second redirect. <strong>The first redirect is followed but returns an error.</strong></p> <p>I keep reading that JavaScript AJAX responses containing redirects are followed automatically, but it look like not in my case. The first redirect is automatically followed by the browser, and the first redirect is returned without following the second redirect in the header. My problem is that I want all the redirects to be automatically followed by the browser.</p> <p>The redirects are part of the phpCAS library. I have an API written in PHP which checks the user authentication, each time, before returning the results.</p> <p>Here is the sequence. The main thing to note is that the browser returns the second response, after following 1 redirect. I would prefer it went all the way and returned the last response when I make an AJAX call to <code>localhost/example/api</code>.</p> <p><strong>localhost/example</strong></p> <ul> <li>Calls <code>localhost/example/api</code> using jQuery.ajax()</li> </ul> <p><strong>Response 1: localhost/example/api</strong></p> <ul> <li>Redirects to <code>https://localhost/accounts/cas/login?service=api.example.com&amp;gateway=true</code> (using SSL).</li> </ul> <p><strong>Response 2: (SSL) localhost/accounts/cas/login?service=api.example.com&amp;gateway=true</strong></p> <ul> <li>When the query key 'gateway' is present, the login simply redirects back to the URL provided by the 'service' key with or without a ticket (to signal to service that the user is either logged in or not).</li> </ul> <p><strong>Response 3: localhost/api?ticket=TICKET</strong></p> <ul> <li>Verifies the ticket and redirects back to itself without the ticket.</li> </ul> <p><strong>Response 4: localhost/api</strong></p> <ul> <li>This time the CAS client looks at the $_SESSION to remember what the ticket was, and then processes the API request returning JSONP.</li> </ul> <p>There's no particular reason I'm using CAS over OpenID or OpenAuth(orization). CAS was just the first authentication module I was able to get working in WordPress. I am open to suggestions in terms of using a different authentication library, CMS, framework, etc. Although, my hope is to just get this project finished. So the less re-tooling the better.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload