Copyright © 2003 Miklos Tirpak
Copyright © 2006 Juha Heinanen
default_allow_file
(string)default_deny_file
(string)check_all_branches
(integer)allow_suffix
(string)deny_suffix
(string)db_url
(string)address_table
(string)grp_col
(string)ip_addr_col
(string)mask_col
(string)port_col
(string)db_mode
(integer)trusted_table
(string)source_col
(string)proto_col
(string)from_col
(string)tag_col
(string)peer_tag_avp
(AVP string)allow_routing()
allow_routing(basename)
allow_routing(allow_file,deny_file)
allow_register(basename)
allow_register(allow_file, deny_file)
allow_uri(basename, pseudo-variable)
set_address_group(group_id)
allow_address(ip_addr_pv, port_pv)
allow_source_address(group_id)
allow_trusted()
address_reload
address_dump
subnet_dump
trusted_reload
trusted_dump
allow_uri
default_allow_file
parameterdefault_deny_file
parametercheck_all_branches
parameterallow_suffix
parameterdeny_suffix
parameterdb_url
parameteraddress_table
parametergrp_col
parameterip_addr_col
parametermask_col
parameterport_col
parameterdb_mode
parametertrusted_table
parametersource_col
parameterproto_col
parameterfrom_col
parametertag_col
parameterpeer_tag_avp
parameterallow_routing
usageallow_routing(basename)
usageallow_routing(allow_file, deny_file)
usageallow_register(basename)
usageallow_register(allow_file, deny_file)
usageallow_uri(basename, pseudo-variable)
usageset_address_group(group_id)
usageallow_address(ip_addr_pv, port_pv)
usageallow_source_address(group_id)
usageallow_trusted()
usageThe 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.
OpenSER 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.
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
Section 1.1.1. 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 Section 1.1.1.
The module can be used to determine if request is allowed to the destination specified by an URI stored in a pseudo-variable. Permission rules are stored in plaintext configuration files similar to hosts.allow and hosts.deny used by tcpd.
When allow_uri
function is called, it tries to find a rule that matches
selected fields of the message.
The matching algorithm is as follows, first match wins:
Create a pair <From URI, URI stored in pseudo-variable>.
Request will be allowed when the pair matches an entry in the allow file.
Otherwise request will be denied when the pair matches an entry in the deny file.
Otherwise, request 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 URI and URI stored in pseudo-variable are always compared with regular expressions! For the syntax see the sample file: config/permissions.allow.
The module can be used to determine if an address (IP address and port) matches any of the IP subnets stored in cached openser database table. Port 0 in cached database table matches any port. IP address and port to be matched can be either taken from the request (allow_source_address) or given as pseudo value arguments (allow_address).
Addresses stored in cached database table can be grouped together into one or more groups specified by a group identifier (unsigned integer). Group identifier is given as argument to allow_source_address function or assigned separately for subsequent allow_address function calls using set_address_group function.
The module can be used to determine if an incoming request can be trusted without authentication.
When allow_trusted
function is called, it tries to find a rule that matches
the request. Rules contain the following fields:
<source address, transport protocol, regular
expression>.
A requests is accepted if there exists a rule, where
source address is equal to source address of request,
transport protocol is either "any" or equal to transport protocol of request, and
regular expression is either empty (NULL in database) or matches From URI of request.
Otherwise the request is rejected.
Rules are stored in a database table specified by module parameters. There also exists a module parameter that determines if rules are cached into memory for faster matching or if database is consulted for each invocation of allow_trusted function call.
The following modules must be loaded before this module:
No dependencies on other OpenSER modules.
The following libraries or applications must be installed before running OpenSER with this module loaded:
None.
default_allow_file
(string)Default allow file used by functions without parameters. If you don't specify full pathname then the directory in which is the main config file is located will be used.
Default value is "permissions.allow".
default_deny_file
(string)Default file containing deny rules. The file is used by functions without parameters. If you don't specify full pathname then the directory in which the main config file is located will be used.
Default value is "permissions.deny".
check_all_branches
(integer)If set then allow_routing functions will check Request-URI of all branches (default). If disabled then only Request-URI of the first branch will be checked.
Do not disable this parameter unless you really know what you are doing. |
Default value is 1.
allow_suffix
(string) Suffix to be appended to basename to create filename of the allow
file when version with one parameter of either
allow_routing
or
allow_register
is used.
Including leading dot. |
Default value is ".allow".
deny_suffix
(string) Suffix to be appended to basename to create filename of the deny file
when version with one parameter of either
allow_routing
or
allow_register
is used.
Including leading dot. |
Default value is ".deny".
db_url
(string) This is URL of the database to be used to store rules used by
allow_trusted
function.
Default value is "NULL".
address_table
(string) Name of database table containing IP subnet information used by
allow_address
and
allow_source_address
functions.
Default value is "address".
grp_col
(string)Name of address table column containing group identifier of the address.
Default value is "grp".
ip_addr_col
(string)Name of address table column containing IP address part of the address.
Default value is "ip_addr".
mask_col
(string)Name of address table column containing network mask of the address. Possible values are 0-32.
Default value is "mask".
port_col
(string)Name of address table column containing port part of the address.
Default value is "port".
db_mode
(integer)Database mode. 0 means non-caching, 1 means caching. Valid only for allow_trusted function.
Default value is 0 (non-caching).
trusted_table
(string) Name of database table containing matching rules used by
allow_register
function.
Default value is "trusted".
source_col
(string)Name of trusted table column containing source IP address that is matched against source IP address of received request.
Default value is "src_ip".
proto_col
(string)Name of trusted table column containing transport protocol that is matched against transport protocol of received request. Possible values that can be stored in proto_col are "any", "udp", "tcp", "tls", "sctp", and "none". Value "any" matches always and value "none" never.
Default value is "proto".
from_col
(string)Name of trusted table column containing regular expression that is matched against From URI.
Default value is "from_pattern".
tag_col
(string)Name of trusted table column containing a string that is added as value to peer_tag AVP if peer_tag AVP has been defined and if the peer matches.
Default value is "tag".
peer_tag_avp
(AVP string)If defined, the AVP will be set as side effect of allow_trusted() call to not NULL tag column value of the matching peer.
Default value is "undefined".
allow_routing()
Returns true if all pairs constructed as described in Section 1.1.1 have appropriate permissions according to
the configuration files. This function uses default configuration
files specified in default_allow_file
and
default_deny_file
.
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
allow_routing(basename)
Returns true if all pairs constructed as described in Section 1.1.1 have appropriate permissions according to the configuration files given as parameters.
Meaning of the parameters is as follows:
basename - Basename from which allow
and deny filenames will be created by appending contents of
allow_suffix
and deny_suffix
parameters.
If the parameter doesn't contain full pathname then the function expects the file to be located in the same directory as the main configuration file of the server.
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
allow_routing(allow_file,deny_file)
Returns true if all pairs constructed as described in Section 1.1.1 have appropriate permissions according to the configuration files given as parameters.
Meaning of the parameters is as follows:
allow_file - File containing allow rules.
If the parameter doesn't contain full pathname then the function expects the file to be located in the same directory as the main configuration file of the server.
deny_file - File containing deny rules.
If the parameter doesn't contain full pathname then the function expects the file to be located in the same directory as the main configuration file of the server.
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
allow_register(basename)
The function returns true if all pairs constructed as described in Section 1.1.2 have appropriate permissions according to the configuration files given as parameters.
Meaning of the parameters is as follows:
basename - Basename from which allow
and deny filenames will be created by appending contents of
allow_suffix
and deny_suffix
parameters.
If the parameter doesn't contain full pathname then the function expects the file to be located in the same directory as the main configuration file of the server.
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
allow_register(allow_file, deny_file)
The function returns true if all pairs constructed as described in Section 1.1.2 have appropriate permissions according to the configuration files given as parameters.
Meaning of the parameters is as follows:
allow_file - File containing allow rules.
If the parameter doesn't contain full pathname then the function expects the file to be located in the same directory as the main configuration file of the server.
deny_file - File containing deny rules.
If the parameter doesn't contain full pathname then the function expects the file to be located in the same directory as the main configuration file of the server.
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
allow_uri(basename, pseudo-variable)
Returns true if the pair constructed as described in Section 1.1.3 have appropriate permissions according to the configuration files specified by the parameter.
Meaning of the parameter is as follows:
basename - Basename from which allow
and deny filenames will be created by appending contents of
allow_suffix
and deny_suffix
parameters.
If the parameter doesn't contain full pathname then the function expects the file to be located in the same directory as the main configuration file of the server.
pseudo-variable - Any pseudo-variable defined in OpenSER.
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
set_address_group(group_id)
Sets address group to be used in subsequent allow_address function calls to an unsigned integer value given as argument. Argument can be an integer string or a pseudo variable.
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
allow_address(ip_addr_pv, port_pv)
Returns true if IP address and port given as values of pseudo variable arguments and belonging to an earlier assigned address group matches an IP subnet found in cached address table. Cached address table entry containing port value 0 matches any port.
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
Example 1-26. allow_address(ip_addr_pv, port_pv)
usage
... // Check source address/port of request if (!allow_address("$si", "$sp")) { sl_send_reply("403", "Forbidden"); }; // Check IP address/port stored in AVPs i:704/i:705 if (!allow_address("$avp(i:704)", "$avp(i:705)") { sl_send_reply("403", "Forbidden"); }; ...
allow_source_address(group_id)
Equal to set_address_group(group_id); allow_address("$si", "$sp"), but faster.
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
allow_trusted()
Checks based on request's source address, transport protocol, and From URI if request can be trusted without authentication. Returns 1 if a match is found as described in Section 1.1.5 and -1 otherwise. If a match is found and peer_tag_avp has been defined, adds a non-NULL tag column value of the matching peer to AVP peer_tag_avp.
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
address_reload
Causes permissions module to re-read the contents of address database table into cache memory. In cache memory the entries are for performance reasons stored in two different tables: address table and subnet table depending on the value of the mask field (32 or smaller).
Parameters: none
address_dump
Causes permissions module to dump contents of cache memory address table.
Parameters: none
subnet_dump
Causes permissions module to dump contents of cache memory subnet table.
Parameters: none
trusted_reload
Causes permissions module to re-read the contents of trusted table into cache memory.
Parameters: none
trusted_dump
Causes permissions module to dump contents of trusted table from cache memory.
Parameters: none
allow_uri
Tests if (URI, Contact) pair is allowed according to allow/deny files. The files must already have been loaded by OpenSER.
Parameters:
basename - Basename from which allow and deny filenames will be created by appending contents of allow_suffix and deny_suffix parameters.
URI - URI to be tested
Contact - Contact to be tested
Take a look at http://www.openser-project.org/.
First at all check if your question was already answered on one of our mailing lists:
User Mailing List - http://lists.openser-project.org/cgi-bin/mailman/listinfo/users
Developer Mailing List - http://lists.openser-project.org/cgi-bin/mailman/listinfo/devel
E-mails regarding any stable OpenSER release should be sent to
<users@lists.openser-project.org>
and e-mails regarding development versions
should be sent to <devel@lists.openser-project.org>
.
If you want to keep the mail private, send it to
<team@lists.openser-project.org>
.
Please follow the guidelines provided at: http://sourceforge.net/tracker/?group_id=139143.