first commit

This commit is contained in:
2025-07-18 16:20:14 +07:00
commit 98af45c018
16382 changed files with 3148096 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
<?php
/**
* RADIUS client example using PAP password.
*/
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once __DIR__ . '/../autoload.php';
$radius = new \Dapphp\Radius\Radius();
$radius->setServer('127.0.0.1') // IP or hostname of RADIUS server
->setSecret('testing123') // RADIUS shared secret
->setNasIpAddress('127.0.0.1') // IP or hostname of NAS (device authenticating user)
->setAttribute(32, 'vpn') // NAS identifier
->setDebug(); // Enable debug output to screen/console
// Send access request for a user with username = 'username' and password = 'password!'
$response = $radius->accessRequest('username', 'password!');
if ($response === false) {
// false returned on failure
echo sprintf("Access-Request failed with error %d (%s).\n",
$radius->getErrorCode(),
$radius->getErrorMessage()
);
} else {
// access request was accepted - client authenticated successfully
echo "Success! Received Access-Accept response from RADIUS server.\n";
}

View File

@@ -0,0 +1,37 @@
<?php
/**
* RADIUS client example using EAP-MS-CHAP-V2.
*
* Tested on Windows Server 2012 R2, 2016, and 2019 Standard Network Policy Server.
*/
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once __DIR__ . '/../autoload.php';
$server = (getenv('RADIUS_SERVER_ADDR')) ?: '192.168.0.20';
$user = (getenv('RADIUS_USER')) ?: 'nemo';
$pass = (getenv('RADIUS_PASS')) ?: 'arctangent';
$secret = (getenv('RADIUS_SECRET')) ?: 'xyzzy5461';
$radius = new \Dapphp\Radius\Radius();
$radius->setServer($server) // IP or hostname of RADIUS server
->setSecret($secret) // RADIUS shared secret
->setNasIpAddress('127.0.0.1') // IP or hostname of NAS (device authenticating user)
->setNasPort(20); // NAS port
// Send access request for user nemo
$response = $radius->accessRequestEapMsChapV2($user, $pass);
if ($response === false) {
// false returned on failure
echo sprintf("Access-Request failed with error %d (%s).\n",
$radius->getErrorCode(),
$radius->getErrorMessage()
);
} else {
// access request was accepted - client authenticated successfully
echo "Success! Received Access-Accept response from RADIUS server.\n";
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* RADIUS client example using MS-CHAPv1.
*
* Tested with Windows Server 2012 R2 Network Policy Server
*/
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once __DIR__ . '/../autoload.php';
$radius = new \Dapphp\Radius\Radius();
$radius->setServer('192.168.0.20') // IP or hostname of RADIUS server
->setSecret('xyzzy5461') // RADIUS shared secret
->setNasIpAddress('127.0.0.1') // IP or hostname of NAS (device authenticating user)
->setNasPort(20); // NAS port
$radius->setMSChapPassword('arctangent123$'); // set mschapv1 password for user
// Send access request for user nemo
$response = $radius->accessRequest('nemo');
if ($response === false) {
// false returned on failure
echo sprintf("Access-Request failed with error %d (%s).\n",
$radius->getErrorCode(),
$radius->getErrorMessage()
);
} else {
// access request was accepted - client authenticated successfully
echo "Success! Received Access-Accept response from RADIUS server.\n";
}