Last active
January 3, 2016 20:19
-
-
Save jamsyoung/8514607 to your computer and use it in GitHub Desktop.
MediaWiki Radius Authentication Extension - RadiusAuthPlugin - http://jamsyoung.com/2010/02/17/mediawiki-radius-authentication-extension-radiusauthplugin/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_once("./extensions/RadiusAuthPlugin.php"); | |
$wgAuth = new RadiusAuthPlugin(); | |
$wgGroupPermissions['*']['createaccount'] = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once('AuthPlugin.php'); | |
require_once('radius.class.php'); | |
error_reporting(E_ALL); | |
class RadiusAuthPlugin extends AuthPlugin | |
{ | |
function userExists($username) { return TRUE; } | |
function authenticate($username, $password) | |
{ | |
$username = strtolower($username); | |
$radius = new Radius('RADIUS_SERVER', 'SHARED_SECRET'); | |
$radius->SetNasIpAddress('NAS_IP_ADDRESS'); // Needed for some devices (not always auto-detected) | |
if ($radius->AccessRequest($username, $password)) | |
{ | |
return TRUE; | |
} | |
return FALSE; | |
} | |
function modifyUITemplate(&$template) | |
{ | |
$template->set('usedomain', FALSE); | |
$template->set('useemail', FALSE); | |
$template->set('create', FALSE); | |
} | |
function autoCreate() { return TRUE; } | |
function validDomain($domain) { return TRUE; } | |
function updateUser(&$user) { return TRUE; } | |
function allowPasswordChange() { return FALSE; } | |
function setPassword($password) { return FALSE; } | |
function updateExternalDB($user) { return FALSE; } | |
function canCreateAccounts() { return FALSE; } | |
function adduser($user, $password) { return FALSE; } | |
function strict() { return TRUE; } | |
function initUser(&$user) { } | |
} | |
$wgExtensionCredits['other'][] = array( | |
'name' => 'RadiusAuthPlugin', | |
'version' => '1.0.0', | |
'author' => 'Your-Name', | |
'description' => 'Automatic login with a RADIUS server' | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment