RadiusRB
¶ ↑
A ruby RADIUS client library that supports:
-
Authentication
-
Accounting
-
Custom dictionaries
-
Vendor Specific Attributes (Thanks to James Harton aka jamesotron)
RadiusRB
is derived from from PJ Davis’s Radiustar library (github.com/pjdavis/radiustar).
Installation¶ ↑
Via Github, for development¶ ↑
~# git clone git://github.com/dguerri/radiusrb.git ~# cd radiusrb ~# bundle install ~# rake install
Via Rubygems¶ ↑
~# gem install radiusrb
Bundler¶ ↑
gem "radiusrb", "~> 1.0.2"
Usage¶ ↑
require 'rubygems' require 'radiusrb' # Load dictionaries from freeradius directory dict = RadiusRB::Dictionary.new('/usr/share/freeradius/') # Lets get authenticated auth_custom_attr = { 'Framed-Address' => '127.0.0.1', 'NAS-Port' => 0, 'NAS-Port-Type' => 'Ethernet' } req = RadiusRB::Request.new('127.0.0.1', { :dict => dict }) reply = req.authenticate('John Doe', 'hello', 'testing123', auth_custom_attr) if reply[:code] == 'Access-Accept' req = RadiusRB::Request.new('127.0.0.1:1813', { :dict => dict }) acct_custom_attr = { 'Framed-Address' => '127.0.0.1', 'NAS-Port' => 0, 'NAS-Port-Type' => 'Ethernet', 'Acct-Session-Time' => 0 } timings = Time.now reply = req.accounting_start('John Doe', 'testing123', '123456', acct_custom_attr) sleep(rand 5) acct_custom_attr['Acct-Session-Time'] = Time.now - timings reply = req.accounting_update('John Doe', 'testing123', '123456', acct_custom_attr) sleep(rand 5) acct_custom_attr['Acct-Session-Time'] = Time.now - timings reply = req.accounting_stop('John Doe', 'testing123', '123456', acct_custom_attr) end
Copyright¶ ↑
Copyright © 2011 Davide Guerri <davide.guerri@gmail.com>. See LICENSE.txt for further details.