Module: sems
Branch: master
Commit: ee229de02cf4ee0c6f5171c677bb80b2d078654a
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=ee229de02cf4ee0c6f5171c677bb80b2d078654a

Author: Stefan Sayer <[email protected]>
Committer: Stefan Sayer <[email protected]>
Date:   Thu Sep 16 15:31:59 2010 +0200

b/f: send autheticated BYE with To-tag

closes https://bugtracker.iptel.org/view.php?id=44
Summary:                    authenticated BYE does not work (to-tag missing)
Description:
When authentication is requested by a proxy for a BYE request sent by SEMS,
the second BYE request (with authentication info) does not contain a
to-tag. This causes the proxy to reject the request with a 481 reply.

Thanks to <samusenko at msm dot ru> for reporting this bug.

---

 core/AmSipHeaders.h               |    6 ++++++
 core/plug-in/uac_auth/UACAuth.cpp |   16 +++++++++-------
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/core/AmSipHeaders.h b/core/AmSipHeaders.h
index e7799ac..e8e4880 100644
--- a/core/AmSipHeaders.h
+++ b/core/AmSipHeaders.h
@@ -7,6 +7,7 @@
 #define SIP_METH_INVITE         "INVITE"
 #define SIP_METH_PRACK          "PRACK"
 #define SIP_METH_UPDATE         "UPDATE"
+#define SIP_METH_BYE            "BYE"
 
 #define SIP_HDR_FROM            "From"
 #define SIP_HDR_TO              "To"
@@ -25,6 +26,11 @@
 #define SIP_HDR_MIN_SE          "Min-SE"
 #define SIP_HDR_RSEQ            "RSeq"
 #define SIP_HDR_RACK            "RAck"
+#define SIP_HDR_AUTHORIZATION   "Authorization"
+#define SIP_HDR_PROXY_AUTHORIZATION "Proxy-Authorization"
+#define SIP_HDR_PROXY_AUTHENTICATE "Proxy-Authenticate"
+#define SIP_HDR_WWW_AUTHENTICATE "WWW-Authenticate"
+
 #define SIP_HDR_COL(_hdr)       _hdr ":"
 #define SIP_HDR_COLSP(_hdr)     SIP_HDR_COL(_hdr) " "
 
diff --git a/core/plug-in/uac_auth/UACAuth.cpp 
b/core/plug-in/uac_auth/UACAuth.cpp
index e059d28..d81d372 100644
--- a/core/plug-in/uac_auth/UACAuth.cpp
+++ b/core/plug-in/uac_auth/UACAuth.cpp
@@ -29,6 +29,7 @@
 #include "UACAuth.h"
 #include "AmSipMsg.h"
 #include "AmUtils.h"
+#include "AmSipHeaders.h"
 
 #include <map>
 
@@ -139,14 +140,14 @@ bool UACAuth::onSipReply(const AmSipReply& reply, int 
old_dlg_status)
        //                              credential->user.c_str(),
        //                              credential->pwd.c_str());
        if (((reply.code == 401) && 
-            getHeader(ri->second.hdrs, "Authorization", true).length()) ||
+            getHeader(ri->second.hdrs, SIP_HDR_AUTHORIZATION, true).length()) 
||
            ((reply.code == 407) && 
-            getHeader(ri->second.hdrs, "Proxy-Authorization", true).length())) 
{
+            getHeader(ri->second.hdrs, SIP_HDR_PROXY_AUTHORIZATION, 
true).length())) {
          DBG("Authorization failed!\n");
        } else {
          string auth_hdr = (reply.code==407) ? 
-      getHeader(reply.hdrs, "Proxy-Authenticate", true) : 
-           getHeader(reply.hdrs, "WWW-Authenticate", true);
+      getHeader(reply.hdrs, SIP_HDR_PROXY_AUTHENTICATE, true) : 
+           getHeader(reply.hdrs, SIP_HDR_WWW_AUTHENTICATE, true);
          string result; 
                        
          string auth_uri; 
@@ -161,7 +162,8 @@ bool UACAuth::onSipReply(const AmSipReply& reply, int 
old_dlg_status)
            //                      stripHeader(ri->second.hdrs, 
"Proxy-Authorization"));
            hdrs += result;
 
-           if (dlg->getStatus() < AmSipDialog::Connected) {
+           if (dlg->getStatus() < AmSipDialog::Connected && 
+               ri->second.method != SIP_METH_BYE) {
              // reset remote tag so remote party 
              // thinks its new dlg
              dlg->remote_tag = "";
@@ -298,8 +300,8 @@ bool UACAuth::do_auth(const unsigned int code, const 
string& auth_hdr,
   DBG("calculated response = %s\n", response);
 
   // compile auth response
-  result = ((code==401) ? "Authorization: Digest username=\"" : 
-           "Proxy-Authorization: Digest username=\"")
+  result = ((code==401) ? SIP_HDR_COLSP(SIP_HDR_AUTHORIZATION) "Digest 
username=\"" : 
+           SIP_HDR_COLSP(SIP_HDR_PROXY_AUTHORIZATION) "Digest username=\"")
     + credential->user + "\", realm=\"" + challenge.realm + "\", 
nonce=\""+challenge.nonce + 
     "\", uri=\""+uri+"\", ";
   if (challenge.opaque.length())

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to