Browse Source

Destroy SMF session to work around MW/SMF collision issue. Coincidentally, this also seems to actually resolve "loss of session data" errors.

auth_remoteuser
Adrian Malacoda 9 months ago
parent
commit
83f36080e3
4 changed files with 48 additions and 39 deletions
  1. 0
    6
      Dockerfile
  2. 36
    29
      application/w/extensions/Auth_SMF.php
  3. 6
    4
      configuration/MWSettings.php
  4. 6
    0
      configuration/supervisord.conf

+ 0
- 6
Dockerfile View File

@@ -30,12 +30,6 @@ RUN chown -R www-data:www-data $SOURCE_ROOT
30 30
 RUN cd "$WIKI_SOURCE/maintenance" && \
31 31
     sh -c 'for TOOL in *.php; do LINK="/usr/bin/$(basename $TOOL .php)"; echo "#!/bin/sh\nphp $WIKI_SOURCE/maintenance/$TOOL \$@" > $LINK; chmod +x $LINK; done'
32 32
 
33
-# 12 August 2018: Messy hack to make "loss of session data"
34
-# errors go away.
35
-# TODO: Rewrite Auth_SMF.php to use MW 1.27+ SessionManager/AuthManager
36
-# interface instead of legacy AuthPlugin interface.
37
-RUN sed -i 's/$this->getEditTokenObject( $salt, $request )->match( $val, $maxage )/true/g' "$WIKI_SOURCE/includes/user/User.php"
38
-
39 33
 # Add our scripts
40 34
 ADD scripts scripts
41 35
 

+ 36
- 29
application/w/extensions/Auth_SMF.php View File

@@ -1,45 +1,52 @@
1 1
 <?php
2 2
 
3
+$smf_session_data = [];
4
+
3 5
 if (!defined("MW_NO_SESSION")) {
4
-		// Fix for SMF's sanitization breaking mediawiki page titles.
5
-		// Let mediawiki do its own security
6
+    // Fix for SMF's sanitization breaking mediawiki page titles.
7
+    // Let mediawiki do its own security
8
+
9
+    $tempGet = $_GET;
6 10
 
7
-		$tempGet = $_GET;
11
+    // 5 August 2016: This variable is used by Mediawiki's updater.
12
+    // Store it in a temp variable so we can restore it if we need to.
13
+    $oldMaintenance = null;
8 14
 
9
-		// 5 August 2016: This variable is used by Mediawiki's updater.
10
-		// Store it in a temp variable so we can restore it if we need to.
11
-		$oldMaintenance = null;
15
+    if (!empty($maintenance)) {
16
+        $oldMaintenance = $maintenance;
17
+    }
12 18
 
13
-		if (!empty($maintenance)) {
14
-			 $oldMaintenance = $maintenance;
15
-		}
19
+    if(!require_once($wgSMFPathSSI)) {
20
+        die("Could not load the SMF SSI");
21
+    }
16 22
 
17
-		if(!require_once($wgSMFPathSSI)) {
18
-				die("Could not load the SMF SSI");
19
-		}
23
+    if(!require_once($wgSMFPathAPI)) {
24
+        die("Could not load the SMF API");
25
+    }
20 26
 
21
-		if(!require_once($wgSMFPathAPI)) {
22
-				die("Could not load the SMF API");
23
-		}
27
+    // Clear SMF session data before starting MW session
28
+    if (!empty($user_info) && $user_info['id']) {
29
+        $smf_session_data = $_SESSION;
30
+        print_r($smf_session_data);
31
+        session_destroy();
32
+    }
24 33
 
25
-		$_GET = $tempGet;
34
+    $_GET = $tempGet;
26 35
 
27
-		if (!empty($oldMaintenance)) {
28
-			 $maintenance = $oldMaintenance;
29
-		}
36
+    if (!empty($oldMaintenance)) {
37
+        $maintenance = $oldMaintenance;
38
+    }
30 39
 }
31 40
 
32 41
 if(!empty($user_info)) {
33
-		$wgAuthRemoteuserUserName = $user_info['username'];
34
-
35
-		$wgAuthRemoteuserUserPrefs = [
36
-				'realname' => $user_info['name'],
37
-				'email' => $user_info['email']
38
-		];
42
+    $wgAuthRemoteuserUserName = $user_info['username'];
39 43
 
40
-		/*$wgAuthRemoteuserUserUrls = [
41
-				'logout' => $wgSMFPath."/index.php?action=logout;sesc=".$user_info['session_id']
42
-		];*/
44
+    $wgAuthRemoteuserUserPrefs = [
45
+        'realname' => $user_info['name'],
46
+        'email' => $user_info['email']
47
+    ];
43 48
 
44
-		print_r($user_info);
49
+    $wgAuthRemoteuserUserUrls = [
50
+        'logout' => $wgSMFPath."/index.php?action=logout;sesc=" . session_id()
51
+    ];
45 52
 }

+ 6
- 4
configuration/MWSettings.php View File

@@ -27,6 +27,8 @@ set_include_path( implode( PATH_SEPARATOR, $path ) . PATH_SEPARATOR . get_includ
27 27
 
28 28
 require_once( "$IP/includes/DefaultSettings.php" );
29 29
 
30
+$wgDebugLogFile = "/tmp/mwdebug.log";
31
+
30 32
 if ( $wgCommandLineMode ) {
31 33
 	if ( isset( $_SERVER ) && array_key_exists( 'REQUEST_METHOD', $_SERVER ) ) {
32 34
 		die( "This script must be run from the command line\n" );
@@ -127,7 +129,7 @@ $wgSecretKey = "15ca1701d1df9129320c037cc200e3fa8652ab4b255403eb276742d8b6a47398
127 129
 
128 130
 ## Default skin: you can change the default skin. Use the internal symbolic
129 131
 ## names, ie 'vector', 'monobook':
130
-$wgDefaultSkin = 'monobook'; //'gcl3';
132
+$wgDefaultSkin = 'gcl3';
131 133
 
132 134
 ## For attaching licensing metadata to pages, and displaying an
133 135
 ## appropriate copyright notice / icon. GNU Free Documentation
@@ -215,7 +217,7 @@ $wgUpgradeKey = 'ce338679bb42ab00';
215 217
 
216 218
 wfLoadSkin("Vector");
217 219
 wfLoadSkin("MonoBook");
218
-//wfLoadSkin("GCL3");
220
+wfLoadSkin("GCL3");
219 221
 
220 222
 $wgCachePages = false;
221 223
 
@@ -227,5 +229,5 @@ $wgSMFPathAPI= "/application/forums/smf_api.php";  # The smf_api.php file can be
227 229
 $wgSMFPathSSI= "/application/forums/SSI.php";      # The SSI.php file (watch capitals!) (normally in your rootdir of your forum)
228 230
 $wgSMFPath = "/application/forums";
229 231
 
230
-//require_once("{$IP}/extensions/Auth_SMF.php");
231
-$wgAuthRemoteuserUserName = "Abwayax";
232
+require_once("{$IP}/extensions/Auth_SMF.php");
233
+//$wgAuthRemoteuserUserName = "Abwayax";

+ 6
- 0
configuration/supervisord.conf View File

@@ -26,6 +26,12 @@ stdout_events_enabled=true
26 26
 stderr_events_enabled=true
27 27
 autorestart=unexpected
28 28
 
29
+[program:mwdebug-log]
30
+command=tail -f /tmp/mwdebug.log
31
+stdout_events_enabled=true
32
+stderr_events_enabled=true
33
+autorestart=unexpected
34
+
29 35
 [program:nginx]
30 36
 command=/usr/sbin/nginx
31 37
 stdout_events_enabled=true

Loading…
Cancel
Save