Miklos
Tirpak

    		    mtirpak@sztaki.hu

Juha
Heinanen

    		    jh@tutpro.com

2003
Miklos Tirpak
Juha Heinanen
2006
iptelorg GmbH
$Revision: 1.4 $
$Date: 2007/01/08 14:58:38 $

# Permissions Module

## Overview

### Call Routing

The module can be used to determine if a call has appropriate permission to be established. Permission rules are stored in plaintext configuration files similar to `hosts.allow` and `hosts.deny` files used by tcpd.

When `allow_routing` function is called it tries to find a rule that matches selected fields of the message.

SER is a forking proxy and therefore a single message can be sent to different destinations simultaneously. When checking permissions all the destinations must be checked and if one of them fails, the forwarding will fail.

The matching algorithm is as follows, first match wins:

- Create a set of pairs of form (From, R-URI of branch 1), (From, R-URI of branch 2), etc.

- Routing will be allowed when all pairs match an entry in the allow file.

- Otherwise routing will be denied when one of pairs matches an entry in the deny file.

- Otherwise, routing will be allowed.

A non-existing permission control file is treated as if it were an empty file. Thus, permission control can be turned off by providing no permission control files.

From header field and Request-URIs are always compared with regular expressions! For the syntax see the sample file: `config/permissions.allow`.

### Registration Permissions

In addition to call routing it is also possible to check REGISTER messages and decide--based on the configuration files--whether the message should be allowed and the registration accepted or not.

Main purpose of the function is to prevent registration of "prohibited" IP addresses. One example, when a malicious user registers a contact containing IP address of a PSTN gateway, he might be able to bypass authorization checks performed by the SIP proxy. That is undesirable and therefore attempts to register IP address of a PSTN gateway should be rejected. Files `config/register.allow` and `config/register.deny` contain an example configuration.

Function for registration checking is called `allow_register` and the algorithm is very similar to the algorithm described in . The only difference is in the way how pairs are created.

Instead of From header field the function uses To header field because To header field in REGISTER messages contains the URI of the person being registered. Instead of the Request-URI of branches the function uses Contact header field.

Thus, pairs used in matching will look like this: (To, Contact 1), (To, Contact 2), (To, Contact 3), and so on..

The algorithm of matching is same as described in .

### Refer-To Permissions

In addition to call routing and REGISTER it is also possible to check REFER messages and decide--based on the configuration files-- whether or not the message should be accepted for forwarding.

Main purpose of the function is to prevent referring a SIP UA to "prohibited" IP addresses. One example is user sending a REFER request to PSTN gateway trying to refer it to an expensive phone number.

Function for Refer-To checking is called allow_refer_to and the algorithm is very similar to the algorithm described in Section 1.1.1. The only difference is in the way how pairs are created.

Instead of Request-URI the function uses Refer-To header field because Refer-To header field in REFER messages contains the URI to which the UA is being referred to. The algorithm of matching is same as described in Section 1.1.1.

### Refer-To Permissions

The module can be also used for catching messages coming from or going to specific network elements, for example gateways or peering partners.

Users can register or forward the calls to the address of a gateway resulting unauthorized access to them. Such calls must be catched and dropped, see ipmatch functions for details.