Page MenuHomePhabricator

Client preferences not applied during SUL3 authentication
Closed, ResolvedPublic

Description

@Tacsipacsi pointed out that the SUL 3 switch from the normal domain to auth.wikimedia.org for login/signup will mean that the client preference cookies (used for things like dark mode and font size) are not going to be present during login/signup.

If there is some attempt to convert the cookies into user preferences during signup (not sure if that's the case), that might also be affected (although probably by the point it happens, the user is back on the normal domain, but we should check this).

Not sure if this is a big deal, but also doesn't seem to fix conceptually - the tricky thing about client preferences is that they need to be compatible with edge caching, but login/signup pages aren't cached, so we can just read the cookie values when we start login, pass them along to the authentication domain with the various other data that need to be transferred, and apply the settings when rendering the page. But, there would have to be some mechanism with which an extension can interact with client preferences (read them, and change them without actually setting the cookies), and I don't think that exists today.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Thanks for creating the task!

Not sure if this is a big deal

As I wrote, not migrating the dark mode can causing an eye-straining white flash. I think it is a big deal (even if not nearly as big that it would outweigh the benefits of SUL3).

A FOUC is annoying but most people wouldn't see it much (since logins last a year; some features require reauthentication before use, but that's uncommon).

It’s not a real FOUC in that the unstyled content doesn’t “flash”, but stays there (so you can’t just close your eyes or do whatever else until it becomes dark). And while most people will indeed not see it much (except for those who use private browsing or new devices regularly), this is true for the whole SUL3 infrastructure: once you’re logged in, you don’t have to care about setting login cookies either.

We could potentially do something like this:

  • When following the local "Log in" or "Create account" link, we currently do some local processing, and then redirect to the central domain. As part of the local processing, the PHP code can take a copy of the clientpref cookies sent by the browser, and store them in a server-side session object that the local domain can write, and that the central domain knows the key for (I believe we have one of these in-use already and could probably be added to that?).
  • When server-rendering the central domain page after that redirect, the PHP code can read out that session object and set those cookies so that they're picked up by the browser.

This should allow these to transfer without any FOUC, and without any JavaScript code.

Izno moved this task from Android to Web (MediaWiki) on the dark-mode board.

Change #1149741 had a related patch set uploaded (by D3r1ck01; author: Derick Alangi):

[mediawiki/extensions/CentralAuth@master] Apply anonymous user preference on the shared domain

https://gerrit.wikimedia.org/r/1149741

• DAlangi_WMF changed the task status from Open to In Progress.May 23 2025, 8:08 PM
• DAlangi_WMF claimed this task.

Change #1150689 had a related patch set uploaded (by D3r1ck01; author: Derick Alangi):

[mediawiki/core@master] auth: Introduce const for applying prefs across domains

https://gerrit.wikimedia.org/r/1150689

Change #1150689 merged by jenkins-bot:

[mediawiki/core@master] resourceloader: Add cookie name for anon client preferences

https://gerrit.wikimedia.org/r/1150689

Change #1149741 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@master] SUL3: Apply anonymous client preferences on the shared domain

https://gerrit.wikimedia.org/r/1149741