Hi!

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. 

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 Authentication header on my original invite?

This is my relevant configuration -
route[RELAY] {
    if (is_method("INVITE|BYE|SUBSCRIBE|UPDATE")) {
        if(!t_is_set("branch_route")) {
                        t_on_branch("MANAGE_BRANCH");
                 }
    }
    if (is_method("INVITE|SUBSCRIBE|UPDATE")) {
        if(!t_is_set("onreply_route")) {
                          t_on_reply("MANAGE_REPLY");
                }
    }
    if (is_method("INVITE")) {
        if(!t_is_set("failure_route")) {
                     t_on_failure("KAM_AUTH");
                }
    }

    if (!t_relay()) {
        sl_reply_error();
    }
    exit;
}

failure_route[KAM_AUTH] {
  if(t_check_status("401|407")) {
    $avp(auser) = "xxx";
    $avp(apass) = "yyy";
    t_on_failure("OUTGOING_FAILURE");
    uac_auth();
    t_relay();
    exit;
  }
}

Edward