Browse Source

do not query kazoo if creds are in cache (#127)

4.1
lazedo 9 years ago
committed by GitHub
parent
commit
84b8d8b991
1 changed files with 23 additions and 34 deletions
  1. +23
    -34
      kamailio/registrar-role.cfg

+ 23
- 34
kamailio/registrar-role.cfg View File

@ -118,9 +118,9 @@ route[ATTEMPT_AUTHORIZATION]
$xavp(regcfg=>match_received) = $su;
if($sht(auth_cache=>$Au) != $null && registered("location", "$rz:$Au", 2, 1) == 1 && $(xavp(ulattrs=>custom_channel_vars){s.len}) > 1) {
$var(password) = $sht(auth_cache=>$Au);
route(CHECK_AUTHORIZATION);
route(SAVE_LOCATION);
}
if( is_present_hf("Authorization")) {
route(KAZOO_AUTHORIZATION);
}
@ -184,30 +184,16 @@ route[KAZOO_AUTHORIZATION_ERROR]
route[CHECK_AUTHORIZATION]
{
#!ifdef OPENBTS_AUTH_ROLE
if($ua =~ "OpenBTS") {
if($var(password) == $null) {
openbts_auth_challenge("$fd", "$var(nonce)");
xlog("L_INFO", "$ci|end|issued auth challenge to registration attempt for $Au $si:$sp\n");
exit;
}
if (!openbts_auth_check("$fd", "$var(password)")) {
#!ifdef ANTIFLOOD_ROLE
route(ANITFLOOD_FAILED_AUTH);
#!endif
openbts_auth_challenge("$fd", "$var(nonce)");
xlog("L_INFO", "$ci|end|issued auth challenge to failed registration attempt for $Au $si:$sp\n");
exit;
}
xlog("L_INFO", "$ci|end|OPENBTS attempt for $Au $si:$sp\n");
} else {
#!endif
if($var(password) == $null) {
auth_challenge("$fd", "0");
xlog("L_INFO", "$ci|end|issued auth challenge to registration attempt for $Au $si:$sp\n");
exit;
}
if (!pv_auth_check("$fd", "$var(password)", "0", "0")) {
#!ifdef ANTIFLOOD_ROLE
route(ANITFLOOD_FAILED_AUTH);
@ -218,9 +204,9 @@ route[CHECK_AUTHORIZATION]
exit;
}
#!ifdef OPENBTS_AUTH_ROLE
}
#!endif
@ -228,29 +214,32 @@ route[CHECK_AUTHORIZATION]
route(ANTIFLOOD_SUCCESSFUL_AUTH);
#!endif
if ($sht(auth_cache=>$Au) == $null) {
xlog("L_INFO", "$ci|log|caching SIP credentials for $Au\n");
$sht(auth_cache=>$Au) = $var(password);
#!ifdef OPENBTS_AUTH_ROLE
if($ua =~ "OpenBTS") {
$sht(auth_cache=>$Au::nonce) = $var(nonce);
}
#!endif
}
# user authenticated - remove auth header
consume_credentials();
route(SAVE_LOCATION);
}
route[SAVE_LOCATION]
{
if ($sht(auth_cache=>$Au) == $null) {
xlog("L_INFO", "$ci|log|caching sip credentials for $Au\n");
};
$sht(auth_cache=>$Au) = $var(password);
#!ifdef OPENBTS_AUTH_ROLE
if($ua =~ "OpenBTS") {
$sht(auth_cache=>$Au::nonce) = $var(nonce);
}
#!endif
$var(save_result) = save("location", "0x04");
if($var(save_result) == -1) {
auth_challenge("$fd", "0");
xlog("L_INFO", "$ci|end|issued auth challenge after failed attempt to save contact for $Au $si:$sp\n");
exit;
} else {
} else {
if($var(save_result) == 1) {
$var(new_reg) = "true";
} else {
@ -260,7 +249,7 @@ route[SAVE_LOCATION]
if(@contact.expires) {
$var(expires) = @contact.expires;
} else {
} else {
if(is_present_hf("Expires")) {
$var(expires) = $hdr(Expires);
} else {
@ -290,7 +279,7 @@ route[SAVE_LOCATION]
kazoo_publish("registrar", $var(amqp_routing_key), $var(amqp_payload_request));
xlog("L_INFO", "$ci|end|successful $(var(Status){s.tolower}) with contact $ct\n");
#!ifdef PUSHER_ROLE
route(PUSHER_ON_REGISTRATION);
#!endif
@ -299,7 +288,7 @@ route[SAVE_LOCATION]
}
## kazoo event route , {"directory", "reg_flush") => reg-flush by kamailio limitations
## when a Event-Category or Event-Name has a underscore (_) we need to declare it with a dash (-)
## when a Event-Category or Event-Name has a underscore (_) we need to declare it with a dash (-)
event_route[kazoo:consumer-event-directory-reg-flush]
{
$var(user) = $(kzE{kz.json,Username}) + "@" + $(kzE{kz.json,Realm});


Loading…
Cancel
Save