From 2d0e78c1576b2311bf209461dbd554bccc2f8369 Mon Sep 17 00:00:00 2001
From: Andreas Fink <af@andreasfink.com>
Date: Wed, 26 Oct 2016 17:27:42 +0200
Subject: [PATCH] Made envrionment variable configurable #5

---
 AuthRemoteuser.body.php | 5 +++--
 README.md               | 5 +++++
 extension.json          | 5 +++--
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/AuthRemoteuser.body.php b/AuthRemoteuser.body.php
index 9635a0d..2941ad6 100644
--- a/AuthRemoteuser.body.php
+++ b/AuthRemoteuser.body.php
@@ -167,10 +167,11 @@ class AuthRemoteuser extends MediaWiki\Session\ImmutableSessionProviderWithCooki
      */
     protected function getRemoteUsername()
     {
+        global $wgAuthRemoteuserEnvVariable;
         global $wgAuthRemoteuserDomain;
 
-        if (isset($_SERVER['REMOTE_USER'])) {
-            $username = $_SERVER['REMOTE_USER'];
+        if (isset($_SERVER[$wgAuthRemoteuserEnvVariable])) {
+            $username = $_SERVER[$wgAuthRemoteuserEnvVariable];
 
             if ($wgAuthRemoteuserDomain) {
                 $username = str_replace("$wgAuthRemoteuserDomain\\",
diff --git a/README.md b/README.md
index 83d54ca..7f4e26c 100644
--- a/README.md
+++ b/README.md
@@ -30,6 +30,11 @@ It will be appended to the username and should form a valid email address. If
 i.e. your username to login (==`REMOTE_USER`) is `jdoe`, the email of the user
 will be `jdoe@example.com`.
 
+If your environment uses a different variable then `REMOTE_USER`
+you can adjust this like so:
+
+    $wgAuthRemoteuserEnvVariable = 'HTTP_X_REMOTE_USER';
+
 ## Implementation
 The constructor of AuthRemoteuser registers a hook to do the automatic login.
 Storing the AuthRemoteuser object in $wgAuth tells MediaWiki that instead of the
diff --git a/extension.json b/extension.json
index 051176e..c059779 100644
--- a/extension.json
+++ b/extension.json
@@ -1,7 +1,7 @@
 {
   "name": "AuthRemoteuser",
   "namemsg": "authremoteuser-extensionname",
-  "version": "1.3.0",
+  "version": "1.3.1",
   "author": ["Otheus Shelling", "Rusty Burchfield", "James Kinsman", "Daniel Thomas", "Ian Ward Comfort", "[[mw:User:MarkAHershberger|Mark A. Hershberger]]", "Jonas Gröger", "Andreas Fink"],
   "url": "https://www.mediawiki.org/wiki/Extension:AuthRemoteuser",
   "descriptionmsg": "authremoteuser-desc",
@@ -25,7 +25,8 @@
     "_prefix": "",
     "wgAuthRemoteuserDomain": "",
     "wgAuthRemoteuserMailDomain": "example.wiki",
-    "wgAuthRemoteuserNotify": false
+    "wgAuthRemoteuserNotify": false,
+    "wgAuthRemoteuserEnvVariable" : "REMOTE_USER"
   },
   "manifest_version": 1
 }
\ No newline at end of file
-- 
GitLab