|
|
@ -4,16 +4,10 @@ modparam("htable", "htable", "failed_auth_hash=>size=14;autoexpire=180;") |
|
|
|
|
|
|
|
|
####### Authentication Interface module ########## |
|
|
####### Authentication Interface module ########## |
|
|
loadmodule "auth.so" |
|
|
loadmodule "auth.so" |
|
|
loadmodule "auth_db.so" |
|
|
|
|
|
modparam("auth_db", "use_domain", 1) |
|
|
|
|
|
modparam("auth_db", "version_table", 0) |
|
|
|
|
|
modparam("auth_db", "calculate_ha1", 1) |
|
|
|
|
|
modparam("auth_db", "password_column", "password") |
|
|
|
|
|
modparam("auth_db", "load_credentials", "$avp(password)=password") |
|
|
|
|
|
|
|
|
|
|
|
####### User Location Implementation module ########## |
|
|
####### User Location Implementation module ########## |
|
|
loadmodule "usrloc.so" |
|
|
loadmodule "usrloc.so" |
|
|
modparam("usrloc", "db_mode", 1) |
|
|
|
|
|
|
|
|
modparam("usrloc", "db_mode", 0) |
|
|
modparam("usrloc", "db_update_as_insert", 1) |
|
|
modparam("usrloc", "db_update_as_insert", 1) |
|
|
modparam("usrloc", "use_domain", 1) |
|
|
modparam("usrloc", "use_domain", 1) |
|
|
modparam("usrloc", "nat_bflag", FLB_NATB) |
|
|
modparam("usrloc", "nat_bflag", FLB_NATB) |
|
|
@ -34,8 +28,6 @@ modparam("registrar", "received_avp", "$avp(AVP_RECV_PARAM)") |
|
|
modparam("registrar", "min_expires", 300) |
|
|
modparam("registrar", "min_expires", 300) |
|
|
modparam("registrar", "max_expires", 3600) |
|
|
modparam("registrar", "max_expires", 3600) |
|
|
|
|
|
|
|
|
####### Common Module Parameters ########## |
|
|
|
|
|
modparam("auth_db|usrloc", "db_url", "MY_AMQP_URL/callmgr") |
|
|
|
|
|
|
|
|
|
|
|
####### Registrar Logic ######## |
|
|
####### Registrar Logic ######## |
|
|
route[HANDLE_REGISTER] |
|
|
route[HANDLE_REGISTER] |
|
|
@ -69,26 +61,41 @@ route[HANDLE_REGISTER] |
|
|
#!endif |
|
|
#!endif |
|
|
|
|
|
|
|
|
if ($sht(auth_cache=>$Au) != $null && pv_auth_check("$fd", "$sht(auth_cache=>$Au)", "0", "0")) { |
|
|
if ($sht(auth_cache=>$Au) != $null && pv_auth_check("$fd", "$sht(auth_cache=>$Au)", "0", "0")) { |
|
|
xlog("L_DBG", "$ci|log|authenticated $Au via cached SIP creds"); |
|
|
|
|
|
|
|
|
xlog("L_INFO", "$ci|log|authenticated $Au via cached SIP creds"); |
|
|
} else { |
|
|
} else { |
|
|
## RABBITMQ - Credentials fetch |
|
|
## RABBITMQ - Credentials fetch |
|
|
if (!auth_check("$fd", "subscriber", "1")) { |
|
|
|
|
|
|
|
|
|
|
|
#!ifdef TRAFFIC-FILTER-ROLE |
|
|
|
|
|
route(FAILED_AUTH_COUNT); |
|
|
|
|
|
#!endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$var(amqp_payload_request) = "{'Event-Category' : 'directory' , 'Event-Name' : 'authn_req', 'Method' : 'REGISTER', 'Auth-Realm' : '" + $fd + "', 'Auth-User' : '" + $fU + "', 'From' : '" + $fu + "', 'To' : '" + $tu +"' }"; |
|
|
|
|
|
$var(amqp_routing_key) = "authn.req." + $(fd{kz.encode}); |
|
|
|
|
|
if(kazoo_query("callmgr", $var(amqp_routing_key), $var(amqp_payload_request))) { |
|
|
|
|
|
$var(password) = $(kzR{kz.json,Auth-Password}); |
|
|
|
|
|
if($var(password) != $null) { |
|
|
|
|
|
if (!pv_auth_check("$fd", "$var(password)", "0", "0")) { |
|
|
|
|
|
|
|
|
|
|
|
#!ifdef TRAFFIC-FILTER-ROLE |
|
|
|
|
|
route(FAILED_AUTH_COUNT); |
|
|
|
|
|
#!endif |
|
|
|
|
|
|
|
|
|
|
|
auth_challenge("$fd", "0"); |
|
|
|
|
|
xlog("L_INFO", "$ci|end|failed registration attempt from $si:$sp for $Au"); |
|
|
|
|
|
exit; |
|
|
|
|
|
} else { |
|
|
|
|
|
xlog("L_DBG", "$ci|log|caching SIP credentials for $Au"); |
|
|
|
|
|
$sht(auth_cache=>$Au) = $var(password); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
auth_challenge("$fd", "0"); |
|
|
|
|
|
xlog("L_INFO", "$ci|log|error getting password from kazoo response"); |
|
|
|
|
|
exit; |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
auth_challenge("$fd", "0"); |
|
|
auth_challenge("$fd", "0"); |
|
|
xlog("L_INFO", "$ci|end|failed registration attempt from $si:$sp for $Au"); |
|
|
|
|
|
|
|
|
xlog("L_INFO", "$ci|log|error query kazoo for credentials"); |
|
|
exit; |
|
|
exit; |
|
|
} else { |
|
|
|
|
|
xlog("L_DBG", "$ci|log|caching SIP credentials for $Au"); |
|
|
|
|
|
$sht(auth_cache=>$Au) = $avp(password); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
auth_challenge("$fd", "0"); |
|
|
auth_challenge("$fd", "0"); |
|
|
xlog("L_INFO", "$ci|end|issued new auth challenge to new registration attempt"); |
|
|
|
|
|
|
|
|
xlog("L_INFO", "$ci|end|issued new auth challenge to registration attempt from $Au $si:$sp"); |
|
|
exit; |
|
|
exit; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -96,7 +103,32 @@ route[HANDLE_REGISTER] |
|
|
consume_credentials(); |
|
|
consume_credentials(); |
|
|
|
|
|
|
|
|
save("location"); |
|
|
save("location"); |
|
|
xlog("L_INFO", "$ci|end|successful registration with contact $ct"); |
|
|
|
|
|
|
|
|
$var(expires) = @contact.expires; |
|
|
|
|
|
if($var(expires) == $null) { |
|
|
|
|
|
$var(expires) = $hdr(Expires); |
|
|
|
|
|
} |
|
|
|
|
|
if($var(expires) == $null) { |
|
|
|
|
|
$var(expires) = 190; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$var(fs_path) = "%3C" + $rz + "%3A" + $Ri + "%3A" + $Rp + "%3Btransport=" + $proto + "%3Blr%3Breceived=" + $si+":"+$sp+"%3E"; |
|
|
|
|
|
$var(fs_contact) = "<" + $(ct{tobody.uri}) + ";fs_path=" + $var(fs_path) + ">"; |
|
|
|
|
|
if($(ct{tobody.params}) != $null) { |
|
|
|
|
|
$var(fs_contact) = $var(fs_contact) + ";" + $(ct{tobody.params}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xlog("L_INFO", "$ci|end|successful registration with contact $var(fs_contact)"); |
|
|
|
|
|
$var(register_contants) = " 'Presence-Hosts' : 'n/a', 'Profile-Name' : 'sipinterface_1', 'Status' : 'Registered', 'Event-Timestamp' : '" + $TS + "'"; |
|
|
|
|
|
if($var(expires) != $null) { |
|
|
|
|
|
$var(register_contants) = $var(register_contants) + ", 'Expires' : " + $var(expires); |
|
|
|
|
|
} |
|
|
|
|
|
$var(amqp_payload_request) = "{'Event-Category' : 'directory', 'Event-Name' : 'reg_success', 'Contact' : '" + $var(fs_contact) + "', 'Call-ID' : '" + $ci + "', 'Realm' : '" + $fd +"', 'Username' : '" + $fU + "', 'From-User' : '" + $fU + "', 'From-Host' : '" + $fd + "', 'To-User' : '" + $tU +"', 'To-Host' : '" + $td + "', 'User-Agent' : '" + $ua +"' ," + $var(register_contants)+ " }"; |
|
|
|
|
|
|
|
|
|
|
|
$var(amqp_routing_key) = "registration.success." + $(fd{kz.encode}) + "." + $fU; |
|
|
|
|
|
|
|
|
|
|
|
kazoo_publish("callmgr", $var(amqp_routing_key), $var(amqp_payload_request)); |
|
|
|
|
|
|
|
|
exit; |
|
|
exit; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|