Search code examples
apacheauthenticationhttpsaemhsts

AEM infinite redirect loop after Author login via https


I have an AEM author that sits behind a dispatcher, my apache server is configured to use a cert/key for SSL encryption. When I go to my project's https url which goes to the Author instance via the Dispatcher instance I am prompted with the usual Author login page. If I type in my credentials and click submit I then get stuck in a infinite redirect loop.

The first thing I did to troubleshoot this issue was to analyse my apache access logs to see if any 301s or 302s were occurring there, but after examination I see nothing of the sort, all I see are 200s.

"GET /libs/granite/csrf/token.json HTTP/1.1" 200 123 "https://bla.bla.bla/libs/granite/core/content/login.html?resource=%2F&$$login$$=%24%24login%24%24&j_reason=unknown&j_reason_code=unknown" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36"

I then went back to my browser and tried this again and dug into my browser developer tools. From this it seems like AEM Author after authentication uses javascript to redirect you / => /index.html => /aem/start.html.

I then replaced my correct cert/key in my apache configuration with one that did not correspond to my domain (which renders it invalid). After a restart of apache I visited my https url (accepted the browser https exception) and this time when I was prompted with the Author login page I was able to input my credentials and login without an infinite redirect loop, normal Author behavior incurs.

From this troubleshooting I believe something involving the cert/key setup perhaps HSTS is creating this infinite redirect loop but I can't figure out what exactly is happening.

Any input on this issue is welcomed.

Thanks


Solution

  • When I look at the headers that were being set on that request for authentication I noticed the header Cache-Control: max-age:=3600. Digging more into my apache configurations I noticed that I was setting expire headers ExpiresDefault "access plus 1 hour". Once I removed that from the Author's Vhost configuration the infinite redirect loop went away.