Module: sip-router
Branch: master
Commit: 3abdef329a13e4bc452f860c76f70735fcd16201
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=3abdef3…
Author: pd <peter.dunkley(a)crocodile-rcs.com>
Committer: pd <peter.dunkley(a)crocodile-rcs.com>
Date: Mon Aug 8 12:24:46 2011 +0100
modules_k/xcap_server: Added new pseudo variable $xcapuri(name=>xuiddomain)
- $xcapuri(name=>xuiddomain) contains the domain part from $xcapuri(name=>xuid)
The xuiddomain can be used with www_authorize() and www_challenge() if you
want the realm to be based on the user's domain instead of something
hard-coded (like "xcap").
This is particularly useful if you need multi-domain support, don't want
plain-text passwords in the subscriber table, and also don't want to have to
create two entries for each subscriber (one with the SIP domain as the realm
and one with "xcap" as the realm).
---
modules_k/xcap_server/README | 2 +-
modules_k/xcap_server/doc/xcap_server_admin.xml | 2 +-
modules_k/xcap_server/xcap_misc.c | 13 +++++++++++++
modules_k/xcap_server/xcap_misc.h | 1 +
4 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/modules_k/xcap_server/README b/modules_k/xcap_server/README
index aca4a04..88623e1 100644
--- a/modules_k/xcap_server/README
+++ b/modules_k/xcap_server/README
@@ -264,7 +264,7 @@ event_route[xhttp:request] {
* $xcapuri(name=>key) - name can be any to idenitfy the XCAP uri; key
can be: data, uri, root, auid, type, tree, xuid, file, node,
- target, domain.
+ target, domain, xuiddomain.
Exported pseudo-variables are documented at
http://www.kamailio.org/dokuwiki/.
diff --git a/modules_k/xcap_server/doc/xcap_server_admin.xml
b/modules_k/xcap_server/doc/xcap_server_admin.xml
index c690557..d83c7c5 100644
--- a/modules_k/xcap_server/doc/xcap_server_admin.xml
+++ b/modules_k/xcap_server/doc/xcap_server_admin.xml
@@ -307,7 +307,7 @@ event_route[xhttp:request] {
<listitem><para>
<emphasis>$xcapuri(name=>key)</emphasis> - name can be any
to idenitfy the XCAP uri; key can be: data, uri, root, auid,
- type, tree, xuid, file, node, target, domain.
+ type, tree, xuid, file, node, target, domain, xuiddomain.
</para></listitem>
</itemizedlist>
<para>
diff --git a/modules_k/xcap_server/xcap_misc.c b/modules_k/xcap_server/xcap_misc.c
index 57abf3f..06b5a57 100644
--- a/modules_k/xcap_server/xcap_misc.c
+++ b/modules_k/xcap_server/xcap_misc.c
@@ -238,6 +238,13 @@ int xcap_parse_uri(str *huri, str *xroot, xcap_uri_t *xuri)
s.len -= xuri->xuid.len + 1;
}
+ /* xuiddomain */
+ if (xuri->xuid.len > 0) {
+ p = strchr(xuri->xuid.s, '@');
+ xuri->xuiddomain.s = p + 1;
+ xuri->xuiddomain.len = xuri->xuid.len - (p - xuri->xuid.s) - 1;
+ }
+
/* file */
xuri->file.s = s.s;
if(xuri->nss==NULL) {
@@ -747,6 +754,8 @@ int pv_parse_xcap_uri_name(pv_spec_p sp, str *in)
pxs->ktype = 9;
} else if(pxs->key.len==6 && strncmp(pxs->key.s, "domain",
6)==0) {
pxs->ktype = 10;
+ } else if(pxs->key.len==10 && strncmp(pxs->key.s, "xuiddomain",
10)==0) {
+ pxs->ktype = 11;
} else {
LM_ERR("unknown key type [%.*s]\n", in->len, in->s);
goto error;
@@ -850,6 +859,10 @@ int pv_get_xcap_uri(struct sip_msg *msg, pv_param_t *param,
/* get domain */
if(pxs->xus->xuri.domain.len>0)
return pv_get_strval(msg, param, res, &pxs->xus->xuri.domain);
+ case 11:
+ /* get xuiddomain */
+ if(pxs->xus->xuri.xuiddomain.len>0)
+ return pv_get_strval(msg, param, res, &pxs->xus->xuri.xuiddomain);
break;
default:
return pv_get_null(msg, param, res);
diff --git a/modules_k/xcap_server/xcap_misc.h b/modules_k/xcap_server/xcap_misc.h
index 4fcd3d1..908d592 100644
--- a/modules_k/xcap_server/xcap_misc.h
+++ b/modules_k/xcap_server/xcap_misc.h
@@ -48,6 +48,7 @@ typedef struct xcap_uri {
str node;
str target;
str domain;
+ str xuiddomain;
} xcap_uri_t;
int xcap_parse_uri(str *huri, str *xroot, xcap_uri_t *xuri);