> For the complete documentation index, see [llms.txt](https://prosbcdocs.telcobridges.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://prosbcdocs.telcobridges.com/tmedia-documentation/configuration/configuring-radius-authorization.md).

# Configuring RADIUS Authorization

> **Applies to:** Tmedia 3.0, 3.2, 3.3; SBC 3.1, 3.3

This article describes how to configure RADIUS authentication and authorization.

1- Click **Routing script** in the navigation panel.

![ConfigureRadiusAuthorization 0](https://docs.telcobridges.com/w/images/0/08/ConfigureRadiusAuthorization_0.png)

2- **Edit** your main script

![ConfigureRadiusAuthorization 1](https://docs.telcobridges.com/w/images/4/47/ConfigureRadiusAuthorization_1.png)

3- Do the following operations in your script:

* **At the top of the page** require 'radius\_authorization'
* **Following your main class definition** include RadiusAuthorization
* **Add before filter in your main class** before\_filter :method => :radius\_authorization
* **Optional: add the&#x20;*****fill\_authorization\_attributes*****&#x20;method** def fill\_authorization\_attributes(params, auth) auth\[:"User-Name"] = "bob" ... end
* \*'Optional: add the \*requires\_radius\_authorization?'' method to reduce the scope of the authorization: def requires\_radius\_authorization?(params) case params\[:call]\[:called] when /^123/ true ... else false end end
* **Optional: add methods to handle the possible results of authorization:&#x20;*****on\_radius\_authorization\_accept*****,&#x20;*****on\_radius\_authorization\_challenge*****,&#x20;*****on\_radius\_authorization\_reject*****&#x20;and&#x20;*****on\_radius\_authorization\_timeout*****:** def 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 end

4- Click 'Save'

### Example

The following script configures RADIUS authorization with the default attributes (*User-Name*, *Calling-Station-Id* and *Called-Station-Id*):

```
require 'base_routing'
require 'radius_authorization'                                                    # <- 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
end
```

### Advanced example

The following script configures RADIUS authorization with user-defined attributes, and prints attributes found in the Access-Accept message if it is received:

```
require 'base_routing'
require 'radius_authorization'                                                    # <- 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
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://prosbcdocs.telcobridges.com/tmedia-documentation/configuration/configuring-radius-authorization.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
