From b130627912a463bbf76c317cafb9adb754666bfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20P=C3=A9rez=20Crespo?= <jaime.perez@uninett.no> Date: Tue, 28 Aug 2012 08:34:09 +0000 Subject: [PATCH] Fix for username set from attributes received. Updated documentation. Port made optional again. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@3147 44740490-163a-0410-bde0-09ae8108e29a --- modules/radius/docs/radius.txt | 32 ++++++++++++----------- modules/radius/lib/Auth/Source/Radius.php | 7 +++-- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/modules/radius/docs/radius.txt b/modules/radius/docs/radius.txt index 4a7614404..1f2694714 100644 --- a/modules/radius/docs/radius.txt +++ b/modules/radius/docs/radius.txt @@ -18,22 +18,18 @@ authentication source which uses the `radius:Radius` module to 'radius:Radius', /* - * The hostname of the RADIUS server. - * Required. + * An array with the radius servers to use, up to 10. + * The options are: + * - hostname: the hostname of the radius server, or its IP address. Required. + * - port: the port of the radius server. Optional, defaults to 1812. + * - secret: the radius secret to use with this server. Required. */ - 'hostname' => 'radius.example.org', - - /* - * The port number of the radius server. - * Optional, defaults to 1812. - */ - 'port' => 1812, - - /* - * The shared secret which is used when contacting the RADUIS server. - * Required. - */ - 'secret' => 'topsecret', + 'servers' => array(array('hostname' => 'radius1.example.org', + 'port' => 1812, + 'secret' => 'topsecret'), + array('hostname' => 'radius2.example.org', + 'port' => 1812, + 'secret' => 'topsecret')), /* * The timeout for contacting the RADIUS server, in seconds. @@ -47,6 +43,12 @@ authentication source which uses the `radius:Radius` module to */ 'retries' => 3, + /* + * The NAS identifier to use when querying the radius server. + * Optional, defaults to the current host name. + */ + 'nas_identifier' => 'client.example.org', + /* * The attribute name we should store the username in. Ths username * will not be saved in any attribute if this is NULL. diff --git a/modules/radius/lib/Auth/Source/Radius.php b/modules/radius/lib/Auth/Source/Radius.php index 917b6c1f0..aa1d89a13 100644 --- a/modules/radius/lib/Auth/Source/Radius.php +++ b/modules/radius/lib/Auth/Source/Radius.php @@ -115,6 +115,9 @@ class sspmod_radius_Auth_Source_Radius extends sspmod_core_Auth_UserPassBase { /* Try to add all radius servers, trigger a failure if no one works. */ $success = false; foreach ($this->servers as $server) { + if (!isset($server['port'])) { + $server['port'] = 1812; + } if (!radius_add_server($radius, $server['hostname'], $server['port'], $server['secret'], $this->timeout, $this->retries)) { SimpleSAML_Logger::info("Could not connect to server: ".radius_strerror($radius)); @@ -173,8 +176,8 @@ class sspmod_radius_Auth_Source_Radius extends sspmod_core_Auth_UserPassBase { } /* Use the received user name */ - if ($attr_name == RADIUS_USER_NAME) { - $attributes[$this->usernameAttribute] = array($attr_value); + if ($resa['attr'] == RADIUS_USER_NAME) { + $attributes[$this->usernameAttribute] = array($resa['data']); continue; } -- GitLab