BlockBox-Radius
A simple pure PHP RADIUS client supporting Standard and Vendor-Specific Attributes in single file
Author:
- Daren Yeh [email protected]
- Tiffany Liu [email protected]
- Albert Yeh [email protected]
- Santa Yeh [email protected]
Description:
BlockBox-Radius is a simple pure PHP RADIUS client for authenticating users against a RADIUS server following the RFC 2865 rules (http://www.ietf.org/rfc/rfc2865.txt) The current branch is tested to work with the following RADIUS servers:
- Microsoft Windows Server Network Policy Server
- FreeRADIUS 2 and above
- WinRadius
System Requirements:
PHP 5.x - 8.x
Installation:
Just download the release archive and extract to a location on your server. In your application, require_once 'b2radius.inc';
and then you can use the class.
Usage:
require_once('b2radius.inc');
$radius = new Radius($ip_radius_server = 'radius_server_ip_address', $shared_secret = 'radius_shared_secret'[, $radius_suffix = 'optional_radius_suffix'[, $udp_timeout = udp_timeout_in_seconds[, $authentication_port = 1812]]]);
$result = $radius->Access_Request($username = 'username', $password = 'password'[, $udp_timeout = udp_timeout_in_seconds]);
require_once('b2radius.inc'); Examples:
$radius = new Radius('127.0.0.1', 'testing123');
$radius->SetNasPort(0);
$radius->SetNasIpAddress('1.2.3.4');
$radius->SetAttribute(NAS_Identifier,'CPSwitch');
// SetVendorAttribute($vendor, $type, $case, $value);
// $case : T - Text, S - String, A - IPv4, I - Integer 32 bit unsigned value
$radius->SetVendorAttribute(2636,50,'S',"test");
// 2636 vendor juniper, 50 type Juniper-CWA-Redirect, 'S' case String, "test"
$radius->SetVendorAttribute(14823,2,'I',98);
// 14823 vendor aruba, 2 type Aruba-User-Vlan, 'I' case int32, 98
if ($radius->AccessRequest('darenyeh', 'yhdgteHi')) {
echo "Authentication accepted.\n";
} else {
echo "Authentication rejected.\n";
}
echo $radius->GetReadableReceivedAttributes();
?>
Roadmap:
- RADIUS Accounting
- RADIUS CoA Disconnect
- RADIUS CoA Request