Page MenuHomePhabricator

Add a configuration variable that allows Session Backend and Session manager share sessions across multiple wikis.
Closed, ResolvedPublic

Description

Hi all,

I am running a wiki farm. Pre-MediaWiki 1.27, we used php session save path as a central session repo, and users could navigate through multiple wikis without logging out. now that sessions are stored in object cache, somehow the cache key are unconditionally determined by wfMemcKey, thus preventing us from sharing sessions. Although we can use shared cookie domain to keep user feeling logged in from client side, the sessions on the server side are, in fact, different in every wiki.

As a consequence, if users open an edit tab on wiki Foo, then click any page on wiki Bar in another browser tab, and then again hit the save button on wiki Foo, they will be alerted with loss of session.

Is it possible to add a configuration variable that allows us to customize session cache key, or at least allow us to use wfGlobalCacheKey as the key builder?

Event Timeline

Reasno created this task.Oct 31 2016, 2:34 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptOct 31 2016, 2:34 PM
Reasno updated the task description. (Show Details)Oct 31 2016, 2:50 PM
Reasno rescinded a token.
Reasno awarded a token.
Tgr added a subscriber: Tgr.Jan 24 2017, 7:36 PM

We should use the session cache object's makeKey method instead of the wfMemcKey global. That way you can set the session cache to your own object that does not differentiate between wikis.

Do you want to write a patch for it?

I will give it a try

  • Original ------------------

From: "Tgr"<no-reply@phabricator.wikimedia.org>
Date: Wed, Jan 25, 2017 03:36 AM
To: "gx"<gx@huiji.wiki>;
Subject: [Maniphest] [Commented On] T149573: add a configuration variable that allows Session Backend and Session manager share sessions across multiple wikis.

Tgr added a comment.

We should use the session cache object's makeKey method instead of the wfMemcKey global. That way you can set the session cache to your own object that does not differentiate between wikis.

Do you want to write a patch for it?

TASK DETAILhttps://phabricator.wikimedia.org/T149573

EMAIL PREFERENCEShttps://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Tgr
Cc: Tgr, MediaWiki-Authentication-and-authorization, Aklapper, Reasno, JJMC89, Jay8g

Restricted Application added a subscriber: TerraCodes. · View Herald TranscriptFeb 2 2017, 6:42 PM
Nemo_bis renamed this task from add a configuration variable that allows Session Backend and Session manager share sessions across multiple wikis. to Add a configuration variable that allows Session Backend and Session manager share sessions across multiple wikis..Feb 14 2017, 8:48 PM
Nemo_bis triaged this task as Normal priority.

https://gerrit.wikimedia.org/r/#/c/337803/ mentions this task in its commit message.

Change 337803 had a related patch set uploaded (by Krinkle; owner: Toma.luca95):
[mediawiki/core@master] Fix $wgCookieDomain sharing session

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

Framawiki moved this task from Backlog to Doing on the good first bug board.Dec 2 2017, 1:30 PM

Is there any progress for this bug fix? https://gerrit.wikimedia.org/r/#/c/mediawiki/core/+/337803/ were submitted in Feb 2107, and seems to stay in "Cannot Merge" status till now.

@Zoglun: Someone needs to make the patch pass verification and address the -1 code review comments. If you are interested, see https://www.mediawiki.org/wiki/Gerrit/Tutorial#Amending_a_change_.28your_own_or_someone_else.27s.29

Change 337803 abandoned by Gergő Tisza:
Fix $wgCookieDomain sharing session

Reason:
This was fixed a while ago in I4d77c2c52ef43cbc54878ce920595befd270a28e.

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

Change 506890 had a related patch set uploaded (by Gergő Tisza; owner: Gergő Tisza):
[mediawiki/core@master] Add keyspaceIsGlobal flag to BagOStuff

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

Krinkle moved this task from Backlog to libs/objectcache on the MediaWiki-Cache board.
Krinkle added a project: Performance-Team.

Change 506890 abandoned by Gergő Tisza:
Add keyspaceIsGlobal flag to BagOStuff

Reason:
can be achieved by using the 'keyspace' option

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

Tgr closed this task as Resolved.May 6 2019, 10:55 PM
Tgr claimed this task.

Sharing sessions between wikis is somewhat unsafe (as applications on one wiki might clobber another wiki's data) and we are not going to officially support it. But unofficially it should be possible (since the merging of 7e48fdd), to the extent it was before 1.27. Just set something like

$wgSessionCacheType = 'session-cache';
$wgObjectCaches['session-cache'] = [ 'factory' => 'ObjectCache::newAnything', 'keyspace' => 'shared-session' ];

Use at your own risk etc.

(In case someone is wondering, the safe but complicated way would be a CookieSessionProvider subclass, more or less along the lines of what CentralAuthSessionProvider does with the CentralAuthUtils::get/setCentralSession calls.)