Bug #14458


Mapped domains result in unresolving login redirect on non-public sites

Added by Boone Gorges over 1 year ago. Updated over 1 year ago.

Priority name:
Category name:
Domain Mapping
Target version:
Start date:
Due date:
% Done:


Estimated time:


Here's the setup:

- A site is marked with blog_public < 0. Say, 3 (site administrators only)
You map a domain to it and set it to 'Active'
- Try to visit either the mapped or unmapped version
- You are redirected to[mappeddomain]. This happens even if you're logged in - the mapped domain cookie doesn't seem to be set
- Try logging in, and you end up back at the same login page.

The stack trace for the redirect is:

require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), do_action('template_redirect'), WP_Hook->do_action, WP_Hook->apply_filters, cac_mpo_adminsonly_die, cac_mpo_unauthenticated_redirect, auth_redirect, wp_redirect

Maybe the blog_public setting is preventing the asynchronous cookie setting? Ray, could you have a look?


splash-page.png (10.8 KB) splash-page.png Raymond Hoh, 2021-05-24 03:54 PM

Related issues

Related to CUNY Academic Commons - Support #14452: domain mapping - hilarieashton.comResolvedBoone Gorges2021-05-12

Actions #1

Updated by Boone Gorges over 1 year ago

Actions #2

Updated by Raymond Hoh over 1 year ago

Maybe the blog_public setting is preventing the asynchronous cookie setting? Ray, could you have a look?

That's correct.

The asynchronous cookie call happens on the mapped domain in the <head> of the document, which is later than the server-side blog privacy enforcement on the template_redirect hook.

One way to address this is to disable the mapped domain redirect if the site has a blog_public < 0 and if the user is logged-in. That means when a user logs into their private mapped domain site, no mapped domain redirect will occur and the navigation will take place on the subdomain.

This is kind of an edge-case, but does that sound like a good compromise? Any other method would require doing checks and redirects via javascript, which can be bypassed.

Actions #3

Updated by Raymond Hoh over 1 year ago

Okay, I've implemented a different method.

When you attempt to login to a private mapped domain, on successful login, you will now see a splash page saying "Please wait. Attempting authentication". On this page, I can load up Mercator's async JS cookie method so the SSO routine can complete. Once the SSO routine completes, the user is redirected back to the mapped domain and should be able to view the site.

I haven't committed these changes yet, but they are live on production. The downsides with this approach is javascript and 3rd-party cookies need to be enabled (or needs to be in the cookie exemption list in the browser) in order for SSO to complete. Otherwise, the user will be stuck on the splash page.

Boone, let me know what you think of this approach.

Actions #4

Updated by Boone Gorges over 1 year ago

Thanks for thinking about this, Ray.

My main concern is that we eliminate dead-ends. Prior to your change, there was really no way to access or log into these mapped domains. It sounds like now it should be seamless, unless the browser blocks third-party cookies. But most people won't need to log into mapped domains (just the administrators, and those who need access to a private site), and there's no dead-end for these users because they can simply add to their exemption list. Does this sound right to you? Do you think it warrants an addition to our documentation on mapped domains?

Actions #5

Updated by Raymond Hoh over 1 year ago

I've committed the second approach mentioned above here:

The splash page looks like this:

Let me know if anything needs to be changed on the splash page.

On the call last week, we briefly talked about the first option -- redirecting logged-in users back to the subdomain instead of the mapped domain -- but I decided to hold off on this since we would be changing the current mapped domain behavior between major releases. I've opened a new broader ticket to deal with this and the impending browser blocking of third-party cookies -- #14496.


Also available in: Atom PDF