Configuration

Version 1 (Adrian Georgescu, 04/22/2010 01:37 pm)

1 1 Adrian Georgescu
= Configuration =
2 1 Adrian Georgescu
3 1 Adrian Georgescu
== Configure OpenXCAP server ==
4 1 Adrian Georgescu
5 1 Adrian Georgescu
If you have installed the debian package copy /etc/openxcap/config.ini.sample  to /etc/openxcap/config.ini. For other Linux OS copy config.ini.sample from the tar archive to the same directory. Edit config.ini with your settings.
6 1 Adrian Georgescu
7 1 Adrian Georgescu
The specific settings for an installation must be set from the configuration file, which is split in several configuration sections.
8 1 Adrian Georgescu
9 1 Adrian Georgescu
The [Server] section contains global settings: the IP address and port where OpenXCAP listens for client 
10 1 Adrian Georgescu
requests.
11 1 Adrian Georgescu
12 1 Adrian Georgescu
The XCAP root is the context that contains all the documents across all applications and users that
13 1 Adrian Georgescu
are managed by the server. Only the client requests that address the root defined here are accepted.
14 1 Adrian Georgescu
If the root URI has the "https" scheme, the server will listen for requests in TLS mode. The X509
15 1 Adrian Georgescu
certificate and private key that will identify the server are loaded using the values in the [TLS] section. 
16 1 Adrian Georgescu
17 1 Adrian Georgescu
OpenXCAP support multiple, interchangeable backend modules. Each backend knows where and how to
18 1 Adrian Georgescu
authorize and authenticate XCAP users and where to store the XCAP documents. Currently, supported values
19 1 Adrian Georgescu
are "Database" and "OpenSIPS", the specific settings will be taken the corresponding sections, [Database] or
20 1 Adrian Georgescu
[OpenSIPS].
21 1 Adrian Georgescu
22 1 Adrian Georgescu
An XCAP request must be authenticated before it's handled, and the various settings are found in the
23 1 Adrian Georgescu
[Authentication] section. The HTTP authentication algorithm can be chosen from 'basic' and 'digest'.
24 1 Adrian Georgescu
A trusted peer IP list can be defined,  requests matching this list will be accepted without authentication.
25 1 Adrian Georgescu
Client requests must be authenticated in the context of a realm that is the same as the SIP domain. This realm is 
26 1 Adrian Georgescu
derived in real time for each request using the following logic:
27 1 Adrian Georgescu
28 1 Adrian Georgescu
 * if the user section of the XCAP URI (the section following the "users" path segment) is in the form of username@domain, the realm is taken from the domain part
29 1 Adrian Georgescu
 * some XCAP clients (e.g. CounterPath's Eyebeam), only put the username in the XCAP URI, so there is the need for a convention to determine the realm: it must be included in the XCAP root URI on the client side. For example, if the XCAP root of the server is http://example.com/xcap-root, the client should be provisioned with http://example.com/xcap-root@domain/
30 1 Adrian Georgescu
 * if the above logic does not provide the realm, the realm will be taken from the default_realm setting of [Authentication]
31 1 Adrian Georgescu
32 1 Adrian Georgescu
There are separate configuration settings for each backend. The current supported back-ends are Database
33 1 Adrian Georgescu
and OpenSIPS.
34 1 Adrian Georgescu
35 1 Adrian Georgescu
The Database section contains the database connection URI to the database where the service subscribers
36 1 Adrian Georgescu
are kept (authentication_db_uri) and the database connection URI to the database where XCAP documents are
37 1 Adrian Georgescu
stored. Currently, only the MySQL database engine has been thoroughly tested.
38 1 Adrian Georgescu
39 1 Adrian Georgescu
The OpenSIPS section contains all the settings of the Database section, plus the URL where OpenSIPS's XMLRPC
40 1 Adrian Georgescu
management interface is listening for commands. The refreshWatchers command is sent to OpenSIPS management 
41 1 Adrian Georgescu
interface to inform the server that the XCAP documents have been changed for a user so that OpenSIPS can send notifications out according to the new policy in real-time.
42 1 Adrian Georgescu
43 1 Adrian Georgescu
When using TLS you must generate an X.509 certificate and a key. Consult Internet resources for how to do this. The procedure is the same as for any other TLS server like Apache web server.
44 1 Adrian Georgescu
45 1 Adrian Georgescu
== Database setup ==
46 1 Adrian Georgescu
47 1 Adrian Georgescu
Both OpenXCAP backends (Database and OpenSIPS) depend on a database engine to store service subscribers
48 1 Adrian Georgescu
and XCAP resources. The database creation scripts are found in the scripts/ directory, and involve 2 tables:
49 1 Adrian Georgescu
subscriber, which is used to authenticate XCAP requests, and xcap, where XCAP documents are stored.
50 1 Adrian Georgescu
The subscriber table is a subset of the subscriber table from OpenSIPS, xcap table is the same as the one
51 1 Adrian Georgescu
from OpenSIPS.
52 1 Adrian Georgescu
53 1 Adrian Georgescu
[source:config.ini.sample Sample OpenXCAP configuration file]
54 1 Adrian Georgescu
55 1 Adrian Georgescu
== Configure  opensips-mi-proxy ==
56 1 Adrian Georgescu
57 1 Adrian Georgescu
If you have installed the debian package copy /etc/opensips-mi-proxy/config.ini.sample  to /etc/opensips-mi-proxy/config.ini. For other Linux OS copy config.ini.sample from the tar archive to the same directory. Edit config.ini with your settings.
58 1 Adrian Georgescu
59 1 Adrian Georgescu
{{{
60 1 Adrian Georgescu
[OpenSIPS]
61 1 Adrian Georgescu
socket = /var/run/opensips/socket
62 1 Adrian Georgescu
63 1 Adrian Georgescu
[MIProxy]
64 1 Adrian Georgescu
;listen_url = http://<defaultIPAddress>:8080
65 1 Adrian Georgescu
;trusted = any
66 1 Adrian Georgescu
}}}
67 1 Adrian Georgescu
68 1 Adrian Georgescu
For more information see the README and INSTALL files that come together with the tar archive.
69 1 Adrian Georgescu
70 1 Adrian Georgescu
== Configure  soap-simple-proxy ==
71 1 Adrian Georgescu
72 1 Adrian Georgescu
If you have installed the debian package copy /etc/soap-simple-proxy/config.ini.sample  to /etc/soap-simple-proxy/config.ini. For other Linux OS copy config.ini.sample from the tar archive to the same directory. Edit config.ini with your settings.
73 1 Adrian Georgescu
74 1 Adrian Georgescu
{{{
75 1 Adrian Georgescu
[SOAP Server]
76 1 Adrian Georgescu
address = 0.0.0.0
77 1 Adrian Georgescu
port = 9300
78 1 Adrian Georgescu
log_requests = Yes
79 1 Adrian Georgescu
80 1 Adrian Georgescu
[WSDL]
81 1 Adrian Georgescu
public_service_url = https://example.com/soap-simple-proxy/
82 1 Adrian Georgescu
internal_service_url = http://private-address:9200/
83 1 Adrian Georgescu
84 1 Adrian Georgescu
[XCAP]
85 1 Adrian Georgescu
root_uri = http://xcap.example.com/xcap-root
86 1 Adrian Georgescu
}}}
87 1 Adrian Georgescu
88 1 Adrian Georgescu
For more information see the README and INSTALL files that come together with the tar archive.
89 1 Adrian Georgescu
90 1 Adrian Georgescu
== Configure OpenSIPS ==
91 1 Adrian Georgescu
92 1 Adrian Georgescu
The following OpenSIPS configuration example enables OpenSIPS to act like a dedicated SIP Presence server that accepts messages from a trusted SIP Proxy with XCAP authorization enabled using OpenXCAP as policy server. The SIP Proxies defined as trusted peers must be configured to authenticate and authorize  the PUBLISH and SUBSCRIBE methods.
93 1 Adrian Georgescu
94 1 Adrian Georgescu
Is advisable to consult http://opensips.org web site, documentation section for the up to date configuration and settings.
95 1 Adrian Georgescu
96 1 Adrian Georgescu
{{{
97 1 Adrian Georgescu
98 1 Adrian Georgescu
listen       = 10.0.0.1:5060
99 1 Adrian Georgescu
100 1 Adrian Georgescu
# --- module loading ---
101 1 Adrian Georgescu
102 1 Adrian Georgescu
mpath = "/usr/lib/opensips/modules"
103 1 Adrian Georgescu
loadmodule "mi_fifo.so"
104 1 Adrian Georgescu
loadmodule "mi_datagram.so"
105 1 Adrian Georgescu
loadmodule "mysql.so"
106 1 Adrian Georgescu
loadmodule "sl.so"
107 1 Adrian Georgescu
loadmodule "maxfwd.so"
108 1 Adrian Georgescu
loadmodule "tm.so"
109 1 Adrian Georgescu
loadmodule "rr.so"
110 1 Adrian Georgescu
loadmodule "xlog.so"
111 1 Adrian Georgescu
112 1 Adrian Georgescu
loadmodule "presence.so"
113 1 Adrian Georgescu
loadmodule "presence_xml.so"
114 1 Adrian Georgescu
loadmodule "presence_mwi.so"
115 1 Adrian Georgescu
loadmodule "presence_xcapdiff.so"
116 1 Adrian Georgescu
loadmodule "pua.so"
117 1 Adrian Georgescu
loadmodule "pua_mi.so"
118 1 Adrian Georgescu
loadmodule "rls.so"
119 1 Adrian Georgescu
120 1 Adrian Georgescu
121 1 Adrian Georgescu
# ----------------- setting module-specific parameters ---------------
122 1 Adrian Georgescu
123 1 Adrian Georgescu
# -- rr params --
124 1 Adrian Georgescu
# add value to ;lr param to make some broken UAs happy
125 1 Adrian Georgescu
modparam("rr", "enable_full_lr", 1)
126 1 Adrian Georgescu
127 1 Adrian Georgescu
modparam("mi_datagram", "socket_name",       "/var/run/opensips/socket")
128 1 Adrian Georgescu
modparam("mi_datagram", "unix_socket_user",  "opensips")
129 1 Adrian Georgescu
modparam("mi_datagram", "unix_socket_group", "opensips")
130 1 Adrian Georgescu
131 1 Adrian Georgescu
modparam("mi_fifo", "fifo_name", "/var/run/opensips/fifo")
132 1 Adrian Georgescu
modparam("mi_fifo", "fifo_user",  "opensips")
133 1 Adrian Georgescu
modparam("mi_fifo", "fifo_group", "opensips")
134 1 Adrian Georgescu
135 1 Adrian Georgescu
# -- presence params --
136 1 Adrian Georgescu
modparam("presence", "db_url", "mysql://opensips:password@db/opensips")
137 1 Adrian Georgescu
modparam("presence", "server_address", "sip:presence@10.0.0.1")
138 1 Adrian Georgescu
modparam("presence", "fallback2db", 1)
139 1 Adrian Georgescu
modparam("presence", "clean_period",  30)
140 1 Adrian Georgescu
141 1 Adrian Georgescu
# -- xcap params --
142 1 Adrian Georgescu
modparam("presence_xml", "db_url", "mysql://opensips:password@db/opensips")
143 1 Adrian Georgescu
modparam("presence_xml", "force_active", 0)
144 1 Adrian Georgescu
modparam("presence_xml", "pidf_manipulation", 1)
145 1 Adrian Georgescu
modparam("presence_xml", "integrated_xcap_server", 1)
146 1 Adrian Georgescu
147 1 Adrian Georgescu
# -- rls params --
148 1 Adrian Georgescu
149 1 Adrian Georgescu
modparam("rls", "db_url", "mysql://opensips:password@db/opensips")
150 1 Adrian Georgescu
modparam("rls", "server_address",         "sip:rls@10.0.0.1")
151 1 Adrian Georgescu
modparam("rls", "to_presence_code", 5)
152 1 Adrian Georgescu
modparam("rls", "integrated_xcap_server", 1)
153 1 Adrian Georgescu
154 1 Adrian Georgescu
155 1 Adrian Georgescu
# -------------------------  request routing logic -------------------
156 1 Adrian Georgescu
 
157 1 Adrian Georgescu
# main routing logic
158 1 Adrian Georgescu
 
159 1 Adrian Georgescu
route {
160 1 Adrian Georgescu
    xlog("L_INFO", "----- Start routing");
161 1 Adrian Georgescu
162 1 Adrian Georgescu
    if ((method=="PUBLISH" || method=="SUBSCRIBE" || method=="NOTIFY")) {
163 1 Adrian Georgescu
        xlog("L_INFO", "Presence event: $hdr(Event)\n");
164 1 Adrian Georgescu
    }
165 1 Adrian Georgescu
166 1 Adrian Georgescu
    if(is_method("PUBLISH")) {
167 1 Adrian Georgescu
        if ((src_ip==10.0.0.1 && src_port==5060)) {  
168 1 Adrian Georgescu
            sl_send_reply("404", "Domain not served here");
169 1 Adrian Georgescu
            return;
170 1 Adrian Georgescu
        }
171 1 Adrian Georgescu
        if (is_from_local()) {
172 1 Adrian Georgescu
            if (avp_check("$hdr(Event)", "fm/presence*/i") && ($au != $rU || $ar != $rd)) {
173 1 Adrian Georgescu
                xlog("L_WARN", "Account $au@$ar tried to publish $hdr(Event) event for $ru\n");
174 1 Adrian Georgescu
                sl_send_reply("403", "Publishing $hdr(Event) events for others is forbidden");
175 1 Adrian Georgescu
               return; 
176 1 Adrian Georgescu
            }
177 1 Adrian Georgescu
       } else {
178 1 Adrian Georgescu
            sl_send_reply("403", "PUBLISH forbidden for outside domains");
179 1 Adrian Georgescu
            return;
180 1 Adrian Georgescu
        }
181 1 Adrian Georgescu
182 1 Adrian Georgescu
        if (t_newtran()) {  
183 1 Adrian Georgescu
            handle_publish();
184 1 Adrian Georgescu
            t_release();
185 1 Adrian Georgescu
        } else {
186 1 Adrian Georgescu
            sl_reply_error();
187 1 Adrian Georgescu
        }
188 1 Adrian Georgescu
        exit;
189 1 Adrian Georgescu
    } else if( is_method("NOTIFY"))
190 1 Adrian Georgescu
        if (has_totag()) {
191 1 Adrian Georgescu
            if (!loose_route()) {
192 1 Adrian Georgescu
                if (!t_newtran()) {
193 1 Adrian Georgescu
                    sl_reply_error();
194 1 Adrian Georgescu
                    exit;
195 1 Adrian Georgescu
                }
196 1 Adrian Georgescu
                rls_handle_notify();
197 1 Adrian Georgescu
                switch ($retcode) {
198 1 Adrian Georgescu
                case 1:
199 1 Adrian Georgescu
                    # Notify processed by rls
200 1 Adrian Georgescu
                    xlog("L_INFO", "$rm processed by RLS\n");
201 1 Adrian Georgescu
                    t_release();
202 1 Adrian Georgescu
                    exit;
203 1 Adrian Georgescu
                    break;
204 1 Adrian Georgescu
                case -1:
205 1 Adrian Georgescu
                    # Error
206 1 Adrian Georgescu
                    xlog("L_INFO", "$rm processed by RLS but has error\n");
207 1 Adrian Georgescu
                    t_reply("500", "Server error while processing RLS NOTIFY");
208 1 Adrian Georgescu
                    exit;
209 1 Adrian Georgescu
                    break;
210 1 Adrian Georgescu
                default:
211 1 Adrian Georgescu
                    if (uri == "sip:rls@10.0.0.1") {
212 1 Adrian Georgescu
                        xlog("L_ERR", "$rm should be processed by RLS but was not recognized\n");
213 1 Adrian Georgescu
                        xlog("L_INFO", "Dropping $rm because it will loop\n");
214 1 Adrian Georgescu
                        t_reply("500", "Server error while processing RLS NOTIFY");
215 1 Adrian Georgescu
                        exit;  
216 1 Adrian Georgescu
                    } else {   
217 1 Adrian Georgescu
                        xlog("L_INFO", "$rm handled by presence\n");
218 1 Adrian Georgescu
                        t_release();
219 1 Adrian Georgescu
                    }
220 1 Adrian Georgescu
                }
221 1 Adrian Georgescu
            }
222 1 Adrian Georgescu
        } else {
223 1 Adrian Georgescu
            # Out-of-dialog NOTIFY
224 1 Adrian Georgescu
            sl_send_reply("405", "Method Not Allowed");
225 1 Adrian Georgescu
            exit;
226 1 Adrian Georgescu
        }
227 1 Adrian Georgescu
228 1 Adrian Georgescu
    } else if( is_method("SUBSCRIBE")) {
229 1 Adrian Georgescu
        if (!has_totag()) {
230 1 Adrian Georgescu
            if (loose_route()) {
231 1 Adrian Georgescu
                xlog("L_ERR", "Incorrectly formatted $rm request. Rejected.\n");
232 1 Adrian Georgescu
                sl_send_reply("400", "Incorrectly formatted request");
233 1 Adrian Georgescu
                return;
234 1 Adrian Georgescu
            }
235 1 Adrian Georgescu
236 1 Adrian Georgescu
            if ((src_ip==10.0.0.1 && src_port==5060) && is_present_hf("Record-Route")) {
237 1 Adrian Georgescu
                sl_send_reply("404", "Domain not served here");
238 1 Adrian Georgescu
                return;
239 1 Adrian Georgescu
            }
240 1 Adrian Georgescu
241 1 Adrian Georgescu
            if (is_from_local()) {
242 1 Adrian Georgescu
                   if (!(src_ip==10.0.0.1 && src_port==5060)) {
243 1 Adrian Georgescu
                       xlog("L_INFO", "Request came directly from the subscriber\n");
244 1 Adrian Georgescu
                        setflag(18);
245 1 Adrian Georgescu
                   }
246 1 Adrian Georgescu
247 1 Adrian Georgescu
                    if ((avp_check("$hdr(Event)", "fm/*.winfo/i") || avp_check("$hdr(Event)", "eq/message-summary/i")) &&
248 1 Adrian Georgescu
                        ($au != $rU || $ar != $rd)) {
249 1 Adrian Georgescu
                        xlog("L_WARN", "Account $au@$ar tried to subscribe to $ru for $hdr(Event)\n");
250 1 Adrian Georgescu
                        sl_send_reply("403", "Subscription to others $hdr(Event) is forbidden");
251 1 Adrian Georgescu
                        return;
252 1 Adrian Georgescu
                    }
253 1 Adrian Georgescu
                }
254 1 Adrian Georgescu
            }
255 1 Adrian Georgescu
256 1 Adrian Georgescu
            # Internal presence handling
257 1 Adrian Georgescu
            if (!t_newtran()) {
258 1 Adrian Georgescu
                sl_reply_error();
259 1 Adrian Georgescu
                exit;
260 1 Adrian Georgescu
            }
261 1 Adrian Georgescu
262 1 Adrian Georgescu
            rls_handle_subscribe();
263 1 Adrian Georgescu
264 1 Adrian Georgescu
            switch ($retcode) {
265 1 Adrian Georgescu
            case 5:
266 1 Adrian Georgescu
                # RLS indicated that message should be processed by presence
267 1 Adrian Georgescu
268 1 Adrian Georgescu
                if (is_uri_host_local()) {
269 1 Adrian Georgescu
                    if (does_uri_exist()) {
270 1 Adrian Georgescu
                        handle_subscribe();
271 1 Adrian Georgescu
                        t_release();
272 1 Adrian Georgescu
                    } else {   
273 1 Adrian Georgescu
                        t_reply("404", "User not found");
274 1 Adrian Georgescu
                    }
275 1 Adrian Georgescu
                    exit;
276 1 Adrian Georgescu
                }
277 1 Adrian Georgescu
                break;
278 1 Adrian Georgescu
            default:
279 1 Adrian Georgescu
                t_release();   
280 1 Adrian Georgescu
                exit;
281 1 Adrian Georgescu
            }
282 1 Adrian Georgescu
        } else {
283 1 Adrian Georgescu
            # In-dialog SUBSCRIBE
284 1 Adrian Georgescu
            if (uri=="sip:presence@10.0.0.1" || uri=="sip:rls@10.0.0.1" || !loose_route()) {
285 1 Adrian Georgescu
                # Internal presence handling
286 1 Adrian Georgescu
                if (t_newtran()) {
287 1 Adrian Georgescu
                    rls_handle_subscribe();
288 1 Adrian Georgescu
                    if ($retcode==5) {
289 1 Adrian Georgescu
                        handle_subscribe();
290 1 Adrian Georgescu
                    }
291 1 Adrian Georgescu
                    t_release();
292 1 Adrian Georgescu
                } else {
293 1 Adrian Georgescu
                    sl_reply_error();
294 1 Adrian Georgescu
                }
295 1 Adrian Georgescu
                exit;
296 1 Adrian Georgescu
            }
297 1 Adrian Georgescu
        }
298 1 Adrian Georgescu
    } else {
299 1 Adrian Georgescu
        xlog("L_INFO", "Method $rm Not Acceptable Here");
300 1 Adrian Georgescu
        sl_send_reply("488", "Not Acceptable Here");
301 1 Adrian Georgescu
        exit;
302 1 Adrian Georgescu
    };
303 1 Adrian Georgescu
}
304 1 Adrian Georgescu
}}}
305 1 Adrian Georgescu
306 1 Adrian Georgescu
= Running the server =
307 1 Adrian Georgescu
308 1 Adrian Georgescu
For non Debian systems copy openxcap, soap-simple-proxy and opensips-mi-proxy  startup scripts from their debian directory present in each tar file to /etc/init.d/ and edit them to match your system.
309 1 Adrian Georgescu
310 1 Adrian Georgescu
Start OpenXCAP server: 
311 1 Adrian Georgescu
312 1 Adrian Georgescu
{{{
313 1 Adrian Georgescu
/etc/init.d/openxcap start
314 1 Adrian Georgescu
}}}
315 1 Adrian Georgescu
316 1 Adrian Georgescu
Start opensips-mi-proxy: 
317 1 Adrian Georgescu
318 1 Adrian Georgescu
{{{
319 1 Adrian Georgescu
/etc/init.d/opensips-mi-proxy start
320 1 Adrian Georgescu
}}}
321 1 Adrian Georgescu
322 1 Adrian Georgescu
Start soap-simple-proxy: 
323 1 Adrian Georgescu
324 1 Adrian Georgescu
{{{
325 1 Adrian Georgescu
/etc/init.d/soap-simple-proxy start
326 1 Adrian Georgescu
}}}
327 1 Adrian Georgescu
328 1 Adrian Georgescu
OpenXCAP logs its messages to /var/log/openxcap/. All other servers log their messages to the system syslog. Check the log files for any startup or runtime errors.
329 1 Adrian Georgescu
330 1 Adrian Georgescu
== Creating user accounts ==
331 1 Adrian Georgescu
332 1 Adrian Georgescu
The user accounts are stored in OpenSIPS subscriber table. You can add subscribers by using your favorite OpenSIPS subscriber management tool.