<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;
      charset=windows-1252">
  </head>
  <body>
    <p>Hello,</p>
    <p><br>
    </p>
    <p><br>
    </p>
    <p>if you have this topology:</p>
    <p><br>
    </p>
    <p>[freeswitch] ====> [kamailio] ====> [gateway]</p>
    <p><br>
    </p>
    <p>and the gateway is sending back 407, the I would still use
      freeswitch to do the authentication, otherwise you need dialog
      module in kamailio to track cseq changes. FreeSwitch originates
      the call and then can increase the cseq as it needs. If the
      gateway is a proxy (e.g., another Kamailio), then cseq increase is
      not needed and you can just do it with uac module without dialog
      module.<br>
    </p>
    <p><br>
    </p>
    <p>Regarding your question of adding the Proxy-Authorization header
      in the first INVITE, that can work sometimes if you know the nonce
      the gateway is going to use, which can be the case of caching the
      nonce when receiving the 407 first time and reusing it later.
      However, the nonce typically is invalidated after a while (or even
      on first usage), so reusing it is not going to work always. Which
      is for good reasons, otherwise there can be reply-attacks.</p>
    <p><br>
    </p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 10.05.20 18:53, Edward Romanenco
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:AM0PR04MB66929E8FEBCA9CC00702F05CC7A00@AM0PR04MB6692.eurprd04.prod.outlook.com">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
      <div style="font-family: Calibri, Arial, Helvetica, sans-serif;
        font-size: 12pt; color: rgb(0, 0, 0);">
        Hi!</div>
      <div style="font-family: Calibri, Arial, Helvetica, sans-serif;
        font-size: 12pt; color: rgb(0, 0, 0);">
        <br>
      </div>
      <div style="font-family: Calibri, Arial, Helvetica, sans-serif;
        font-size: 12pt; color: rgb(0, 0, 0);">
        I've using a SIP setup that includes both Kamailio &
        Freeswitch, invites are passed from Freeswitch and relayed by
        Kamailio to various dispatchers, I would like to have Kamailio
        authenticating when Proxy Authentication is required. </div>
      <div style="font-family: Calibri, Arial, Helvetica, sans-serif;
        font-size: 12pt; color: rgb(0, 0, 0);">
        <br>
      </div>
      <div style=""><font face="Calibri, Arial, Helvetica, sans-serif"
          color="#000000"><span style="font-size: 12pt;">As I
            understood, this can be achieved with the help of a failure
            route, problem is, when I'm utilizing this method - the 407
            response gets reverted back to Freeswitch, which returns the
            revised invite filled with the default Freeswitch
            username/password, how can let Kamailio handle the
            authentication once receiving the 407? Can I work straight
            without relying on a failure route, but having the Proxy
          </span>Authentication<span style="font-size: 12pt;"> header on
            my original invite?</span></font></div>
      <div style="font-family: Calibri, Arial, Helvetica, sans-serif;
        font-size: 12pt; color: rgb(0, 0, 0);">
        <br>
      </div>
      <div style="font-family: Calibri, Arial, Helvetica, sans-serif;
        font-size: 12pt; color: rgb(0, 0, 0);">
        This is my relevant configuration -</div>
      <div style="font-family: Calibri, Arial, Helvetica, sans-serif;
        font-size: 12pt; color: rgb(0, 0, 0);">
        <span>route[RELAY] {<br>
        </span>
        <div>    if (is_method("INVITE|BYE|SUBSCRIBE|UPDATE")) {<br>
        </div>
        <div>        if(!t_is_set("branch_route")) {<br>
        </div>
        <div>                        t_on_branch("MANAGE_BRANCH");<br>
        </div>
        <div>                 }<br>
        </div>
        <div>    }<br>
        </div>
        <div>    if (is_method("INVITE|SUBSCRIBE|UPDATE")) {<br>
        </div>
        <div>        if(!t_is_set("onreply_route")) {<br>
        </div>
        <div>                          t_on_reply("MANAGE_REPLY");<br>
        </div>
        <div>                }<br>
        </div>
        <div>    }<br>
        </div>
        <div>    if (is_method("INVITE")) {<br>
        </div>
        <div>        if(!t_is_set("failure_route")) {<br>
        </div>
        <div>                     t_on_failure("KAM_AUTH");<br>
        </div>
        <div>                }<br>
        </div>
        <div>    }<br>
        </div>
        <div><br>
        </div>
        <div>    if (!t_relay()) {<br>
        </div>
        <div>        sl_reply_error();<br>
        </div>
        <div>    }<br>
        </div>
        <div>    exit;<br>
        </div>
        <div>}<br>
        </div>
        <div><br>
        </div>
        <div>failure_route[KAM_AUTH] {<br>
        </div>
        <div>  if(t_check_status("401|407")) {<br>
        </div>
        <div>    $avp(auser) = "xxx";<br>
        </div>
        <div>    $avp(apass) = "yyy";<br>
        </div>
        <div>    t_on_failure("OUTGOING_FAILURE");<br>
        </div>
        <div>    uac_auth();<br>
        </div>
        <div>    t_relay();<br>
        </div>
        <div>    exit;<br>
        </div>
        <div>  }<br>
        </div>
        <span>}</span><br>
      </div>
      <div style="font-family: Calibri, Arial, Helvetica, sans-serif;
        font-size: 12pt; color: rgb(0, 0, 0);">
        <span><br>
        </span></div>
      <div style="font-family: Calibri, Arial, Helvetica, sans-serif;
        font-size: 12pt; color: rgb(0, 0, 0);">
        <span>Edward</span></div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
Kamailio (SER) - Users Mailing List
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a>
<a class="moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla -- <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
<a class="moz-txt-link-abbreviated" href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a class="moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a>
Funding: <a class="moz-txt-link-freetext" href="https://www.paypal.me/dcmierla">https://www.paypal.me/dcmierla</a></pre>
  </body>
</html>