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 1 year 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
RUN cd "$WIKI_SOURCE/maintenance" && \
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'

# 12 August 2018: Messy hack to make "loss of session data"
# errors go away.
# TODO: Rewrite Auth_SMF.php to use MW 1.27+ SessionManager/AuthManager
# interface instead of legacy AuthPlugin interface.
RUN sed -i 's/$this->getEditTokenObject( $salt, $request )->match( $val, $maxage )/true/g' "$WIKI_SOURCE/includes/user/User.php"

# Add our scripts
ADD scripts scripts


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

@@ -1,45 +1,52 @@
<?php

$smf_session_data = [];

if (!defined("MW_NO_SESSION")) {
// Fix for SMF's sanitization breaking mediawiki page titles.
// Let mediawiki do its own security
// Fix for SMF's sanitization breaking mediawiki page titles.
// Let mediawiki do its own security

$tempGet = $_GET;

$tempGet = $_GET;
// 5 August 2016: This variable is used by Mediawiki's updater.
// Store it in a temp variable so we can restore it if we need to.
$oldMaintenance = null;

// 5 August 2016: This variable is used by Mediawiki's updater.
// Store it in a temp variable so we can restore it if we need to.
$oldMaintenance = null;
if (!empty($maintenance)) {
$oldMaintenance = $maintenance;
}

if (!empty($maintenance)) {
$oldMaintenance = $maintenance;
}
if(!require_once($wgSMFPathSSI)) {
die("Could not load the SMF SSI");
}

if(!require_once($wgSMFPathSSI)) {
die("Could not load the SMF SSI");
}
if(!require_once($wgSMFPathAPI)) {
die("Could not load the SMF API");
}

if(!require_once($wgSMFPathAPI)) {
die("Could not load the SMF API");
}
// Clear SMF session data before starting MW session
if (!empty($user_info) && $user_info['id']) {
$smf_session_data = $_SESSION;
print_r($smf_session_data);
session_destroy();
}

$_GET = $tempGet;
$_GET = $tempGet;

if (!empty($oldMaintenance)) {
$maintenance = $oldMaintenance;
}
if (!empty($oldMaintenance)) {
$maintenance = $oldMaintenance;
}
}

if(!empty($user_info)) {
$wgAuthRemoteuserUserName = $user_info['username'];

$wgAuthRemoteuserUserPrefs = [
'realname' => $user_info['name'],
'email' => $user_info['email']
];
$wgAuthRemoteuserUserName = $user_info['username'];

/*$wgAuthRemoteuserUserUrls = [
'logout' => $wgSMFPath."/index.php?action=logout;sesc=".$user_info['session_id']
];*/
$wgAuthRemoteuserUserPrefs = [
'realname' => $user_info['name'],
'email' => $user_info['email']
];

print_r($user_info);
$wgAuthRemoteuserUserUrls = [
'logout' => $wgSMFPath."/index.php?action=logout;sesc=" . session_id()
];
}

+ 6
- 4
configuration/MWSettings.php View File

@@ -27,6 +27,8 @@ set_include_path( implode( PATH_SEPARATOR, $path ) . PATH_SEPARATOR . get_includ

require_once( "$IP/includes/DefaultSettings.php" );

$wgDebugLogFile = "/tmp/mwdebug.log";

if ( $wgCommandLineMode ) {
if ( isset( $_SERVER ) && array_key_exists( 'REQUEST_METHOD', $_SERVER ) ) {
die( "This script must be run from the command line\n" );
@@ -127,7 +129,7 @@ $wgSecretKey = "15ca1701d1df9129320c037cc200e3fa8652ab4b255403eb276742d8b6a47398

## Default skin: you can change the default skin. Use the internal symbolic
## names, ie 'vector', 'monobook':
$wgDefaultSkin = 'monobook'; //'gcl3';
$wgDefaultSkin = 'gcl3';

## For attaching licensing metadata to pages, and displaying an
## appropriate copyright notice / icon. GNU Free Documentation
@@ -215,7 +217,7 @@ $wgUpgradeKey = 'ce338679bb42ab00';

wfLoadSkin("Vector");
wfLoadSkin("MonoBook");
//wfLoadSkin("GCL3");
wfLoadSkin("GCL3");

$wgCachePages = false;

@@ -227,5 +229,5 @@ $wgSMFPathAPI= "/application/forums/smf_api.php"; # The smf_api.php file can be
$wgSMFPathSSI= "/application/forums/SSI.php"; # The SSI.php file (watch capitals!) (normally in your rootdir of your forum)
$wgSMFPath = "/application/forums";

//require_once("{$IP}/extensions/Auth_SMF.php");
$wgAuthRemoteuserUserName = "Abwayax";
require_once("{$IP}/extensions/Auth_SMF.php");
//$wgAuthRemoteuserUserName = "Abwayax";

+ 6
- 0
configuration/supervisord.conf View File

@@ -26,6 +26,12 @@ stdout_events_enabled=true
stderr_events_enabled=true
autorestart=unexpected

[program:mwdebug-log]
command=tail -f /tmp/mwdebug.log
stdout_events_enabled=true
stderr_events_enabled=true
autorestart=unexpected

[program:nginx]
command=/usr/sbin/nginx
stdout_events_enabled=true

Loading…
Cancel
Save