Hello,
iirc, the auth header related variables (like $ar) are set when some authentication functions are used, but that is for requests. For replies, I am not sure if it is done at all, being also a different header name.
Unless you want to dig a bit in the code and see what happens there, for now a solution here would be using transformations to extract fields from the header Proxy-Authenticate or WWW-Authenticate.
If you want to have these variables set in other cases than it is now, you can open a new feature request on github issue tracker.
Cheers,
Daniel
Hey All,
So, I want to use the UAC module to handle Digest Auth to upstream carriers. But, I don’t know which carrier will be selected until another module (dRouting in this case) tells the logic which carrier to use.
I can see in the logs that the uac_auth function can capture the Auth Realm. But, I need to access it from the Kamailio script so that I can lookup the credentials for that realm and then call uac_auth. I’ve tried getting the info from $ar, but that gives me the realm of the inbound request versus the realm of the upstream carrier. Also, I’ve tried using $T_rpl($ar), but that returns 0. Here’s my logic from the Kamailio file:
if(t_check_status("401|407")) {$var(reply_realm) = $T_rpl($ar);$var(query)="select auth_username,auth_password from uacreg where realm='" + $var(reply_realm) + "'";sql_xquery("cb","$var(query)","rb");xlog("L_DEBUG","[MANAGE_FAILURE: Proxy Auth]: The query is $var(query) auth realm is $var(reply_realm) and the user name is $xavp(rb=>auth_username)");$avp(auser) = $xavp(rb=>auth_username);$avp(apass) = $xavp(rb=>auth_password);uac_auth();t_relay();exit;`}
A snippet of the log file is below:
Jan 20 10:05:58 dsiprouter /usr/sbin/kamailio[2871]: exec: *** cfgtrace:failure_route=[DEFAULT_ROUTE] c=[/etc/kamailio/kamailio.cfg] l=1616 a=63 n=assignJan 20 10:05:58 dsiprouter /usr/sbin/kamailio[2871]: exec: *** cfgtrace:failure_route=[DEFAULT_ROUTE] c=[/etc/kamailio/kamailio.cfg] l=1617 a=63 n=assignJan 20 10:05:58 dsiprouter /usr/sbin/kamailio[2871]: exec: *** cfgtrace:failure_route=[DEFAULT_ROUTE] c=[/etc/kamailio/kamailio.cfg] l=1618 a=24 n=uac_authJan 20 10:05:58 dsiprouter /usr/sbin/kamailio[2871]: DEBUG: uac [auth.c:409]: uac_auth(): picked reply is 0x7f900cb7eaf0, code 407Jan 20 10:05:58 dsiprouter /usr/sbin/kamailio[2871]: DEBUG: uac [auth.c:225]: get_autenticate_hdr(): looking for header "Proxy-Authenticate"Jan 20 10:05:58 dsiprouter /usr/sbin/kamailio[2871]: DEBUG: uac [auth.c:429]: uac_auth(): header found; body=<Digest realm="sip.flowroute.com", nonce="XERJMlxESAbDNCK3INmBfoET1GGxpcyr", qop="auth">Jan 20 10:05:58 dsiprouter /usr/sbin/kamailio[2871]: DEBUG: uac [auth_hdr.c:209]: parse_authenticate_body(): <realm>="sip.flowroute.com" state=2Jan 20 10:05:58 dsiprouter /usr/sbin/kamailio[2871]: DEBUG: uac [auth_hdr.c:209]: parse_authenticate_body(): <nonce>="XERJMlxESAbDNCK3INmBfoET1GGxpcyr" state=3Jan 20 10:05:58 dsiprouter /usr/sbin/kamailio[2871]: DEBUG: uac [auth_hdr.c:209]: parse_authenticate_body(): <qop>="auth" state=1Jan 20 10:05:58 dsiprouter /usr/sbin/kamailio[2871]: DEBUG: uac [auth.c:449]: uac_auth(): no credential for realm "sip.flowroute.com"Jan 20 10:05:58 dsiprouter /usr/sbin/kamailio[2871]: exec: *** cfgtrace:failure_route=[DEFAULT_ROUTE] c=[/etc/kamailio/kamailio.cfg] l=1619 a=24 n=t_relay
Thanks in advance for any help
Mack HendricksdSIPRouter
_______________________________________________ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla -- www.asipto.com www.twitter.com/miconda -- www.linkedin.com/in/miconda Kamailio World Conference - May 6-8, 2019 -- www.kamailioworld.com Kamailio Advanced Training - Mar 4-6, 2019 in Berlin; Mar 25-27, 2019, in Washington, DC, USA -- www.asipto.com