diff --git a/kamailio/auth.cfg b/kamailio/auth.cfg index 820264d..da10e32 100644 --- a/kamailio/auth.cfg +++ b/kamailio/auth.cfg @@ -64,7 +64,7 @@ route[SETUP_AUTH_HEADERS] #!ifdef REGISTRAR_ROLE $avp(is_registered) = "false"; $xavp(regcfg=>match_received) = $su; - if (registered("location","$fu", 2, 1) == 1) { + if (registered("location","sip:$Au", 2, 1) == 1) { $avp(is_registered) = "true"; $avp(auth_allowed) = "true"; #!ifdef WITH_AUTH_TOKEN @@ -73,6 +73,18 @@ route[SETUP_AUTH_HEADERS] route(AUTH_CCVS) #!endif return; + } else if(is_present_hf("Proxy-Authorization")) { + if(registered("location", "sip:$au@$ar", 2, 1) == 1) { + xlog("L_INFO", "$ci|auth|from sip:$au@$ar\n"); + $avp(is_registered) = "true"; + $avp(auth_allowed) = "true"; + #!ifdef WITH_AUTH_TOKEN + route(AUTH_TOKEN); + #!else + route(AUTH_CCVS) + #!endif + return; + } } #!endif diff --git a/kamailio/default.cfg b/kamailio/default.cfg index 899efe5..0039932 100644 --- a/kamailio/default.cfg +++ b/kamailio/default.cfg @@ -632,8 +632,12 @@ route[SETUP] { if($sel(cfg_get.kazoo.strict_auth) == 1 && $avp(auth_allowed) != "true") { - xlog("L_WARN", "$ci|auth|request denied\n"); - sl_reply("403", "Please Register"); + if(is_present_hf("Proxy-Authorization")) { + xlog("L_WARN", "$ci|auth|request denied\n"); + } else { + xlog("L_INFO", "$ci|auth|challenging invite\n"); + proxy_challenge("$td", "4"); + } exit; }