Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (révision 111858) +++ channels/chan_sip.c (copie de travail) @@ -11551,6 +11551,7 @@ const char *secret; const char *md5secret; struct sip_auth *auth = NULL; /* Realm authentication */ + struct sip_user *user = NULL; /* User credential propagation */ if (!ast_strlen_zero(p->domain)) ast_copy_string(uri, p->domain, sizeof(uri)); @@ -11570,14 +11571,21 @@ md5secret = auth->md5secret; if (sipdebug) ast_log(LOG_DEBUG,"Using realm %s authentication for call %s\n", p->realm, p->callid); - } else { - /* No authentication, use peer or register= config */ - username = p->authname; - secret = p->peersecret; - md5secret = p->peermd5secret; - } - if (ast_strlen_zero(username)) /* We have no authentication */ - return -1; + } else { + /* IVeS: propagate USER credentials to the remote proxy */ + user = find_user(p->fromuser, 1); + if ( user ) { + username = user->name; + secret = user->secret; + md5secret = user->md5secret; + ast_log(LOG_DEBUG,"proxy auth: propagating credentials of user %s to external proxy\n", p->realm, p->callid); + } else { + /* no auth. fail */ + ast_log(LOG_WARNING, "proxy auth: no auth available for call %s\n", + p->callid); + return -1; + } + } /* Calculate SIP digest response */ snprintf(a1,sizeof(a1),"%s:%s:%s", username, p->realm, secret);