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.
sayer/1.4-spce2.6
Stefan Sayer 16 years ago
parent b0c6f35cc4
commit ee229de02c

@ -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) " "

@ -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())

Loading…
Cancel
Save