Skip to content
Snippets Groups Projects
Commit 2d0e78c1 authored by Andreas Fink's avatar Andreas Fink
Browse files

Made envrionment variable configurable #5

parent 3d189457
No related branches found
No related tags found
No related merge requests found
...@@ -167,10 +167,11 @@ class AuthRemoteuser extends MediaWiki\Session\ImmutableSessionProviderWithCooki ...@@ -167,10 +167,11 @@ class AuthRemoteuser extends MediaWiki\Session\ImmutableSessionProviderWithCooki
*/ */
protected function getRemoteUsername() protected function getRemoteUsername()
{ {
global $wgAuthRemoteuserEnvVariable;
global $wgAuthRemoteuserDomain; global $wgAuthRemoteuserDomain;
if (isset($_SERVER['REMOTE_USER'])) { if (isset($_SERVER[$wgAuthRemoteuserEnvVariable])) {
$username = $_SERVER['REMOTE_USER']; $username = $_SERVER[$wgAuthRemoteuserEnvVariable];
if ($wgAuthRemoteuserDomain) { if ($wgAuthRemoteuserDomain) {
$username = str_replace("$wgAuthRemoteuserDomain\\", $username = str_replace("$wgAuthRemoteuserDomain\\",
......
...@@ -30,6 +30,11 @@ It will be appended to the username and should form a valid email address. If ...@@ -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 i.e. your username to login (==`REMOTE_USER`) is `jdoe`, the email of the user
will be `jdoe@example.com`. 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 ## Implementation
The constructor of AuthRemoteuser registers a hook to do the automatic login. The constructor of AuthRemoteuser registers a hook to do the automatic login.
Storing the AuthRemoteuser object in $wgAuth tells MediaWiki that instead of the Storing the AuthRemoteuser object in $wgAuth tells MediaWiki that instead of the
......
{ {
"name": "AuthRemoteuser", "name": "AuthRemoteuser",
"namemsg": "authremoteuser-extensionname", "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"], "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", "url": "https://www.mediawiki.org/wiki/Extension:AuthRemoteuser",
"descriptionmsg": "authremoteuser-desc", "descriptionmsg": "authremoteuser-desc",
...@@ -25,7 +25,8 @@ ...@@ -25,7 +25,8 @@
"_prefix": "", "_prefix": "",
"wgAuthRemoteuserDomain": "", "wgAuthRemoteuserDomain": "",
"wgAuthRemoteuserMailDomain": "example.wiki", "wgAuthRemoteuserMailDomain": "example.wiki",
"wgAuthRemoteuserNotify": false "wgAuthRemoteuserNotify": false,
"wgAuthRemoteuserEnvVariable" : "REMOTE_USER"
}, },
"manifest_version": 1 "manifest_version": 1
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment