PHP code example of ictsolutions / codeigniter-freeradius

1. Go to this page and download the library: Download ictsolutions/codeigniter-freeradius library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ictsolutions / codeigniter-freeradius example snippets


namespace IctSolutions\CodeIgniterFreeRadius\Enums;

enum Attribute: string
{
    case CleartextPassword = 'Cleartext-Password';
    case FallThrough = 'Fall-Through';
    case SimultaneousUse = 'Simultaneous-Use';
    case ServiceType = 'Service-Type';
    case FramedIPAddress = 'Framed-IP-Address';
    case FramedIPNetmask = 'Framed-IP-Netmask';
    case FramedProtocol = 'Framed-Protocol';
    case FramedMTU = 'Framed-MTU';
    case CiscoAVPair = 'Cisco-AVPair';
    case CiscoNASPort = 'Cisco-NAS-Port';
    case CiscoFramedRoute = 'Cisco-Framed-Route';
}

namespace IctSolutions\CodeIgniterFreeRadius\Enums;

enum Operator: string
{
    case Equals = '=';
    case Assign = ':=';
    case Check = '==';
    case Add = '+=';
    case NotEquals = '!=';
    case Greater = '>';
    case GreaterEquals = '>=';
    case Less = '<';
    case LessEquals = '<=';
    case Matches = '=~';
    case NotMatches = '!~';
    case Exists = '=*';
    case NotExists = '!*';
}

$freeRadiusLibrary = \IctSolutions\CodeIgniterFreeRadius\Config\Services::freeradius();

use IctSolutions\CodeIgniterFreeRadius\Enums\Operator;
use IctSolutions\CodeIgniterFreeRadius\Enums\Attribute;

// ... ...

$attributeValue = '192.0.2.1'; // Provided framed IP address for the user
$freeRadiusLibrary->bindUser(Attribute::FramedIPAddress, Operator::Equals, $attributeValue);

$status = $freeRadiusLibrary->checkUserBinding(Attribute::FramedIPAddress, $attributeValue);

$config = [
    Attribute::FallThrough => ['operator' => Operator::NotEquals, 'value' => 'YES'],
    Attribute::SimultaneousUse => ['operator' => Operator::LessEquals, 'value' => 1],
    Attribute::ServiceType => ['operator' => Operator::Equals, 'value' => 'Framed-User'],
];

$freeRadiusLibrary->applyConfigs($config);

use IctSolutions\CodeIgniterFreeRadius\Enums\Attribute;
use IctSolutions\CodeIgniterFreeRadius\Enums\Operator;

public function index(){
    $freeRadius = \IctSolutions\CodeIgniterFreeRadius\Config\Services::freeradius();

    // Let's bind a user 'john' with a Cleartext-Password
    $freeRadius->bindUser('john', Attribute::CleartextPassword, Operator::Equals, 'JohnsPassword123');
}
shell
php spark migrate