When we opt a user into the SUL3 rollout, we'd like that to be consistent across wikis and authentication attempts. This is tricky because at the beginning of authentication, when we have to decide whether to start the SUL2 or SUL3 flow, we don't know who the user is. Getting it wrong is not the end of the world but we should minimize how often it happens.
We'll do that by relying on the UserName cookie (which is used by MediaWiki to pre-fill the username field, is set on login with 30 / 365 days expiry and does not get unset on logout):
- add a GlobalPreferences hidden preference for preferring SUL2 over SUL3;
- add some logic to SharedDomainUtils::isSul3Enabled() (as a new $wgCentralAuthEnableSul3 type) that checks the UserName cookie, looks up the global preference of the relevant user, and returns whether it is enabled;
- add an in-process cache since isSul3Enabled() is called a lot;
- add some helper method for setting the flag.
GlobalPreferences should be a soft dependency for CentralAuth, but can be a hard dependency for this feature (ie. wikis which don't have it just shouldn't set the relevant $wgCentralAuthEnableSul3 type).