浏览代码

modules_k/auth_radius: added optional uri_user param to radius_www_authorize()
- Useful for http authorization.

Juha Heinanen 14 年之前
父节点
当前提交
414af8a49b

+ 9 - 4
modules_k/auth_radius/README

@@ -49,7 +49,7 @@ Jan Janak
 
 
         5. Exported Functions
         5. Exported Functions
 
 
-              5.1. radius_www_authorize(realm)
+              5.1. radius_www_authorize(realm [, uri_user])
               5.2. radius_proxy_authorize(realm [, uri_user])
               5.2. radius_proxy_authorize(realm [, uri_user])
 
 
    List of Examples
    List of Examples
@@ -82,7 +82,7 @@ Chapter 1. Admin Guide
 
 
    5. Exported Functions
    5. Exported Functions
 
 
-        5.1. radius_www_authorize(realm)
+        5.1. radius_www_authorize(realm [, uri_user])
         5.2. radius_proxy_authorize(realm [, uri_user])
         5.2. radius_proxy_authorize(realm [, uri_user])
 
 
 1. Overview
 1. Overview
@@ -206,10 +206,10 @@ modparam("auth_radius", "use_ruri_flag", 22)
 
 
 5. Exported Functions
 5. Exported Functions
 
 
-   5.1. radius_www_authorize(realm)
+   5.1. radius_www_authorize(realm [, uri_user])
    5.2. radius_proxy_authorize(realm [, uri_user])
    5.2. radius_proxy_authorize(realm [, uri_user])
 
 
-5.1. radius_www_authorize(realm)
+5.1. radius_www_authorize(realm [, uri_user])
 
 
    The function verifies credentials according to RFC2617. If the
    The function verifies credentials according to RFC2617. If the
    credentials are verified successfully then the function will succeed
    credentials are verified successfully then the function will succeed
@@ -240,6 +240,11 @@ modparam("auth_radius", "use_ruri_flag", 22)
        to the user so he can decide what username and password to use. In
        to the user so he can decide what username and password to use. In
        case of REGISTER requests it is usually hostpart of To URI.
        case of REGISTER requests it is usually hostpart of To URI.
        The string may contain pseudo variables.
        The string may contain pseudo variables.
+     * uri_user - Uri_user is an optional pseudo variable parameter whose
+       value, if present, will be given to Radius server as value of
+       SIP-URI-User check item. If uri_user pseudo variable parameter is
+       not present, the server will generate SIP-URI-User check item value
+       from user part of To/From URI.
 
 
    This function can be used from REQUEST_ROUTE.
    This function can be used from REQUEST_ROUTE.
 
 

+ 12 - 2
modules_k/auth_radius/authorize.c

@@ -236,10 +236,20 @@ int radius_proxy_authorize_2(struct sip_msg* _msg, char* _realm,
 
 
 
 
 /*
 /*
- * Authorize using WWW-Authorize header field
+ * Authorize using WWW-Authorize header field (no URI user parameter given)
  */
  */
-int radius_www_authorize(struct sip_msg* _msg, char* _realm, char* _s2)
+int radius_www_authorize_1(struct sip_msg* _msg, char* _realm, char* _s2)
 {
 {
 	return authorize(_msg, (pv_elem_t*)_realm, (pv_spec_t *)0,
 	return authorize(_msg, (pv_elem_t*)_realm, (pv_spec_t *)0,
 			 HDR_AUTHORIZATION_T);
 			 HDR_AUTHORIZATION_T);
 }
 }
+
+
+/*
+ * Authorize using WWW-Authorize header field (URI user parameter given)
+ */
+int radius_www_authorize_2(struct sip_msg* _msg, char* _realm, char* _uri_user)
+{
+	return authorize(_msg, (pv_elem_t*)_realm, (pv_spec_t *)_uri_user,
+			 HDR_AUTHORIZATION_T);
+}

+ 10 - 5
modules_k/auth_radius/authorize.h

@@ -33,21 +33,26 @@
 
 
 
 
 /*
 /*
- * Authorize using Proxy-Authorize header field (no from parameter given)
+ * Authorize using Proxy-Authorize header field (no URI user parameter given)
  */
  */
 int radius_proxy_authorize_1(struct sip_msg* _msg, char* _realm, char* _s2);
 int radius_proxy_authorize_1(struct sip_msg* _msg, char* _realm, char* _s2);
 
 
 
 
 /*
 /*
- * Authorize using Proxy-Authorize header field (from parameter given)
+ * Authorize using Proxy-Authorize header field (URI user parameter given)
  */
  */
-int radius_proxy_authorize_2(struct sip_msg* _msg, char* _realm, char* _from);
+int radius_proxy_authorize_2(struct sip_msg* _msg, char* _realm, char* _uri_user);
 
 
 
 
 /*
 /*
- * Authorize using WWW-Authorization header field
+ * Authorize using WWW-Authorization header field (no URI user parameter given)
  */
  */
-int radius_www_authorize(struct sip_msg* _msg, char* _realm, char* _s2);
+int radius_www_authorize_1(struct sip_msg* _msg, char* _realm, char* _s2);
+
+/*
+ * Authorize using WWW-Authorization header field (URI user parameter given)
+ */
+int radius_www_authorize_2(struct sip_msg* _msg, char* _realm, char* _uri_user);
 
 
 
 
 #endif /* AUTHORIZE_H */
 #endif /* AUTHORIZE_H */

+ 3 - 1
modules_k/auth_radius/authrad_mod.c

@@ -73,7 +73,9 @@ struct extra_attr *auth_extra = 0;
  * Exported functions
  * Exported functions
  */
  */
 static cmd_export_t cmds[] = {
 static cmd_export_t cmds[] = {
-	{"radius_www_authorize", (cmd_function)radius_www_authorize,   1, auth_fixup,
+	{"radius_www_authorize", (cmd_function)radius_www_authorize_1,   1, auth_fixup,
+			0, REQUEST_ROUTE},
+	{"radius_www_authorize", (cmd_function)radius_www_authorize_2,   2, auth_fixup,
 			0, REQUEST_ROUTE},
 			0, REQUEST_ROUTE},
 	{"radius_proxy_authorize", (cmd_function)radius_proxy_authorize_1, 1, auth_fixup,
 	{"radius_proxy_authorize", (cmd_function)radius_proxy_authorize_1, 1, auth_fixup,
 			0, REQUEST_ROUTE},
 			0, REQUEST_ROUTE},

+ 12 - 1
modules_k/auth_radius/doc/auth_radius_admin.xml

@@ -193,7 +193,7 @@ modparam("auth_radius", "use_ruri_flag", 22)
 	<section>
 	<section>
 	<title>Exported Functions</title>
 	<title>Exported Functions</title>
 	<section>
 	<section>
-		<title><function moreinfo="none">radius_www_authorize(realm)</function></title>
+		<title><function moreinfo="none">radius_www_authorize(realm [, uri_user])</function></title>
 		<para>
 		<para>
 		The function verifies credentials according to 
 		The function verifies credentials according to 
 		<ulink url="http://www.ietf.org/rfc/rfc2617.txt">RFC2617</ulink>. If 
 		<ulink url="http://www.ietf.org/rfc/rfc2617.txt">RFC2617</ulink>. If 
@@ -253,6 +253,17 @@ modparam("auth_radius", "use_ruri_flag", 22)
 			The string may contain pseudo variables.
 			The string may contain pseudo variables.
 			</para>
 			</para>
 		</listitem>
 		</listitem>
+		<listitem>
+			<para><emphasis>uri_user</emphasis> - Uri_user is an
+			optional pseudo variable parameter whose value, if
+			present, will be given to Radius server as value of
+			SIP-URI-User check item.
+			If uri_user pseudo variable parameter is not
+			present, the server will generate 
+                        SIP-URI-User check item value from user part of
+			To/From URI.
+			</para>
+		</listitem>
 		</itemizedlist>
 		</itemizedlist>
 		<para>
 		<para>
 		This function can be used from REQUEST_ROUTE.
 		This function can be used from REQUEST_ROUTE.