Jelajahi Sumber

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).
pd 14 tahun lalu
induk
melakukan
3abdef329a

+ 1 - 1
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
      * $xcapuri(name=>key) - name can be any to idenitfy the XCAP uri; key
        can be: data, uri, root, auid, type, tree, xuid, file, node,
        can be: data, uri, root, auid, type, tree, xuid, file, node,
-       target, domain.
+       target, domain, xuiddomain.
 
 
    Exported pseudo-variables are documented at
    Exported pseudo-variables are documented at
    http://www.kamailio.org/dokuwiki/.
    http://www.kamailio.org/dokuwiki/.

+ 1 - 1
modules_k/xcap_server/doc/xcap_server_admin.xml

@@ -307,7 +307,7 @@ event_route[xhttp:request] {
 			<listitem><para>
 			<listitem><para>
 				<emphasis>$xcapuri(name=>key)</emphasis> - name can be any
 				<emphasis>$xcapuri(name=>key)</emphasis> - name can be any
 				to idenitfy the XCAP uri; key can be: data, uri, root, auid,
 				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>
 			</para></listitem>
 		</itemizedlist>
 		</itemizedlist>
 		<para>
 		<para>

+ 13 - 0
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;
 		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 */
 	/* file */
 	xuri->file.s = s.s;
 	xuri->file.s = s.s;
 	if(xuri->nss==NULL) {
 	if(xuri->nss==NULL) {
@@ -747,6 +754,8 @@ int pv_parse_xcap_uri_name(pv_spec_p sp, str *in)
 		pxs->ktype = 9;
 		pxs->ktype = 9;
 	} else if(pxs->key.len==6 && strncmp(pxs->key.s, "domain", 6)==0) {
 	} else if(pxs->key.len==6 && strncmp(pxs->key.s, "domain", 6)==0) {
 		pxs->ktype = 10;
 		pxs->ktype = 10;
+	} else if(pxs->key.len==10 && strncmp(pxs->key.s, "xuiddomain", 10)==0) {
+		pxs->ktype = 11;
 	} else {
 	} else {
 		LM_ERR("unknown key type [%.*s]\n", in->len, in->s);
 		LM_ERR("unknown key type [%.*s]\n", in->len, in->s);
 		goto error;
 		goto error;
@@ -850,6 +859,10 @@ int pv_get_xcap_uri(struct sip_msg *msg,  pv_param_t *param,
 			/* get domain */
 			/* get domain */
 			if(pxs->xus->xuri.domain.len>0)
 			if(pxs->xus->xuri.domain.len>0)
 				return pv_get_strval(msg, param, res, &pxs->xus->xuri.domain);
 				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;
 		break;
 		default:
 		default:
 			return pv_get_null(msg, param, res);
 			return pv_get_null(msg, param, res);

+ 1 - 0
modules_k/xcap_server/xcap_misc.h

@@ -48,6 +48,7 @@ typedef struct xcap_uri {
 	str node;
 	str node;
 	str target;
 	str target;
 	str domain;
 	str domain;
+	str xuiddomain;
 } xcap_uri_t;
 } xcap_uri_t;
 
 
 int xcap_parse_uri(str *huri, str *xroot, xcap_uri_t *xuri);
 int xcap_parse_uri(str *huri, str *xroot, xcap_uri_t *xuri);