Configuring RADIUS Authorization
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
require 'radius_authorization' unless defined?(RadiusAuthorization)include RadiusAuthorizationbefore_filter :method => :radius_authorizationdef fill_authorization_attributes(params, auth)
auth[:"User-Name"] = "bob"
...
enddef requires_radius_authorization?(params)
case params[:call][:called]
when /^123/
true
...
else
false
end
enddef on_radius_authorization_accept(params, auth)
log_trace :always, "Access-Accept: #{auth.inspect}"
end
def on_radius_authorization_challenge(params, auth)
log_trace :always, "Access-Challenge: #{auth.inspect}"
raise RoutingException, :call_rejected
end
def on_radius_authorization_reject(params, auth)
log_trace :always, "Access-Reject: #{auth.inspect}"
raise RoutingException, :call_rejected
end
def on_radius_authorization_timeout(params, auth)
log_trace :always, "Authorization Timeout"
raise RoutingException, :call_rejected
endrequire 'base_routing'
require 'radius_authorization' unless defined?(RadiusAuthorization) # <- Add this line here
class MyScript < BaseRouting
include RadiusAuthorization # <- Add this line here
before_filter :method => :radius_authorization # <- Add this line here
route_match :call_field_name => :called
route_match :call_field_name => :calling
route_match :call_field_name => :nap
route_remap :call_field_name => :called, :route_field_name => :remapped_called
route_remap :call_field_name => :calling, :route_field_name => :remapped_calling
route_remap :call_field_name => :nap, :route_field_name => :remapped_nap
end
@@routing = MyScript.new
def init_routes( routes )
@@routing.init routes
end
def route( call, nap_list )
@@routing.route call, nap_list
endrequire 'base_routing'
require 'radius_authorization' unless defined?(RadiusAuthorization) # <- Add this line here
class MyScript < BaseRouting
include RadiusAuthorization # <- Add this line here
before_filter :method => :radius_authorization # <- Add this line here
def fill_authorization_attributes(params, auth) # <- Add this line here
call = params[:call] # <- Add this line here
auth[:"User-Name"] = "bob" # <- Add this line here
auth[:"User-Password"] = "hello" # <- Add this line here
auth[:"Calling-Station-Id"] = call[:calling] # <- Add this line here
auth[:"Called-Station-Id"] = call[:called] # <- Add this line here
end # <- Add this line here
def on_radius_authorization_accept(params, auth) # <- Add this line here
log_trace :always, "Access-Accept: #{auth.inspect}" # <- Add this line here
end # <- Add this line here
route_match :call_field_name => :called
route_match :call_field_name => :calling
route_match :call_field_name => :nap
route_remap :call_field_name => :called, :route_field_name => :remapped_called
route_remap :call_field_name => :calling, :route_field_name => :remapped_calling
route_remap :call_field_name => :nap, :route_field_name => :remapped_nap
end
@@routing = MyScript.new
def init_routes( routes )
@@routing.init routes
end
def route( call, nap_list )
@@routing.route call, nap_list
end