/radiustar

Ruby Radius Library

Primary LanguageRuby

RADIUSTAR

Pretend this is ascii art of the “the more you know” star thing —=====*

by pjdavis github.com/pjdavis/radiustar

DESCRIPTION:

Ruby Radius Library

FEATURES

  • Import your own radius dictionaries

  • Authentication

  • Accounting

SYNOPSIS:

require 'rubygems'
require 'radiustar'

# Load dictionaries from freeradius directory
# NOTICE: here the Dictionary.new() only accept a parameter of "folder name" but not the dictionary file
dict = Radiustar::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 = Radiustar::Request.new('127.0.0.1', { :dict => dict })
reply = req.authenticate('John Doe', 'hello', 'testing123', auth_custom_attr)

if reply[:code] == 'Access-Accept'
  req = Radiustar::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

REQUIREMENTS:

  • Ruby 1.8

INSTALL:

gem install radiustar

Thanks:

Thanks to everyone who has contributed to this project. Without your help and support, this would not have been possible.

  • charl

  • Mark Bryars

  • jamesotron

  • dguerri

  • gderosa

  • mkocher

  • bwlang

  • cbascom

  • Paulche

LICENSE:

Copyright © 2010 [PJ Davis], released under the CC0 1.0 Universal license.