Browse Source

modules/auth: new flag 16 to add stale=true to challenge response

Juha Heinanen 14 years ago
parent
commit
b63f14b1fd
3 changed files with 19 additions and 2 deletions
  1. 2 0
      modules/auth/README
  2. 8 2
      modules/auth/auth_mod.c
  3. 9 0
      modules/auth/doc/functions.xml

+ 2 - 0
modules/auth/README

@@ -539,6 +539,7 @@ if (www_authenticate("realm", "subscriber)) {
           + 4 - do not send '500 Internal Server Error' reply
             automatically in failure cases (error code is returned to
             config)
+          + 16 - build challenge header with stale=true
 
    This function can be used from REQUEST_ROUTE.
 
@@ -607,6 +608,7 @@ if (!proxy_authenticate("$fd", "subscriber)) {
           + 2 - build challenge header with no qop and add it to avp
           + 4 - build challenge header with qop=auth and add it to avp
           + 8 - build challenge header with qop=auth-int and add it to avp
+          + 16 - build challenge header with stale=true
 
    When challenge header is built and stored in avp, append_to_reply() and
    sl reply functions can be used to send appropriate SIP reply to

+ 8 - 2
modules/auth/auth_mod.c

@@ -635,7 +635,7 @@ static int auth_send_reply(struct sip_msg *msg, int code, char *reason,
  */
 int auth_challenge(struct sip_msg *msg, str *realm, int flags, int hftype)
 {
-	int ret;
+    int ret, stale;
     str hf = {0, 0};
 	struct qp *qop = NULL;
 
@@ -646,7 +646,13 @@ int auth_challenge(struct sip_msg *msg, str *realm, int flags, int hftype)
 	} else if(flags&1) {
 		qop = &auth_qauth;
 	}
-	if (get_challenge_hf(msg, 0, realm, NULL, NULL, qop, hftype, &hf) < 0) {
+	if (flags & 16) {
+	    stale = 1;
+	} else {
+	    stale = 0;
+	}
+	if (get_challenge_hf(msg, stale, realm, NULL, NULL, qop, hftype, &hf)
+	    < 0) {
 		ERR("Error while creating challenge\n");
 		ret = -2;
 		goto error;

+ 9 - 0
modules/auth/doc/functions.xml

@@ -81,6 +81,10 @@ if (www_authenticate("realm", "subscriber)) {
 					Server Error' reply automatically in failure cases
 					(error code is returned to config)</para>
 			</listitem>
+			<listitem>
+				<para><emphasis>16</emphasis> - build challenge header with
+					stale=true</para>
+			</listitem>
 			</itemizedlist>
 		</listitem>
 		</itemizedlist>
@@ -214,6 +218,11 @@ if (!proxy_authenticate("$fd", "subscriber)) {
 				<para><emphasis>8</emphasis> - build challenge header with
 					qop=auth-int and add it to avp</para>
 			</listitem>
+			<listitem>
+				<para><emphasis>16</emphasis> - build challenge header with
+					stale=true</para>
+			</listitem>
+
 			</itemizedlist>
 		</listitem>
 		</itemizedlist>