]>
git.wh0rd.org - tt-rss.git/blob - plugins/auth_radius/init.php
3 Tiny Tiny RSS plugin for RADIUS authentication
4 @author alsvartr (me@taughtbycats.ru)
7 Requires php radius class (comes with plugin)
8 Put the following options in config.php:
10 define('RADIUS_AUTH_SERVER', 'radius_server_address');
11 define('RADIUS_AUTH_SECRET', 'radius_shared_secret');
16 define('RADIUS_AUTH_PORT', radius_auth_port);
19 class Auth_Radius
extends Plugin
implements IAuthModule
{
28 "Authenticates against an RADIUS server (configured in config.php)",
33 function init($host) {
34 $this->link
= $host->get_link();
36 $this->base
= new Auth_Base($this->link
);
39 $host->add_hook($host::HOOK_AUTH_USER
, $this);
42 private function _log($msg) {
43 if ($this->debug
) trigger_error($msg, E_USER_WARNING
);
46 function authenticate($login, $password) {
47 if (!require_once('php-radius/radius.php')) {
48 $this->_log('Cannot require radius class files!');
52 if ($login && $password) {
53 if ( (!defined('RADIUS_AUTH_SERVER')) OR (!defined('RADIUS_AUTH_SECRET')) ) {
54 $this->_log('Could not parse RADIUS_AUTH_ options from config.php!');
56 } elseif (!defined('RADIUS_AUTH_PORT'))
57 define('RADIUS_AUTH_PORT', 1812);
59 $radius = new Radius(RADIUS_AUTH_SERVER
, RADIUS_AUTH_SECRET
, '', 5, RADIUS_AUTH_PORT
);
60 $radius->SetNasIpAddress('1.2.3.4');
61 $auth = $radius->AccessRequest($login, $password);
64 return $this->base
->auto_create_user($login);
66 $this->_log('Radius authentication rejected!');