From f80d6cc5517c6886dc15dc446c0519811c55d04e Mon Sep 17 00:00:00 2001 From: Luis Azedo Date: Wed, 20 Jan 2016 16:09:17 +0000 Subject: [PATCH] FS-8763 [mod_sofia] set is_auth on switch_ivr_set_user result --- src/mod/endpoints/mod_sofia/mod_sofia.h | 1 + src/mod/endpoints/mod_sofia/sofia.c | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 9038b8cf3f..dc06647151 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -291,6 +291,7 @@ typedef enum { PFLAG_PROXY_REFER, PFLAG_CHANNEL_XML_FETCH_ON_NIGHTMARE_TRANSFER, PFLAG_FIRE_TRANFER_EVENTS, + PFLAG_BLIND_AUTH_ENFORCE_RESULT, /* No new flags below this line */ PFLAG_MAX diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 98067676be..5c6658b57b 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -4191,6 +4191,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) sofia_clear_pflag(profile, PFLAG_CHANNEL_XML_FETCH_ON_NIGHTMARE_TRANSFER); sofia_clear_pflag(profile, PFLAG_FIRE_TRANFER_EVENTS); + sofia_clear_pflag(profile, PFLAG_BLIND_AUTH_ENFORCE_RESULT); profile->shutdown_type = "false"; profile->local_network = "localnet.auto"; sofia_set_flag(profile, TFLAG_ENABLE_SOA); @@ -5469,6 +5470,12 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name) } else { sofia_clear_pflag(profile, PFLAG_FIRE_TRANFER_EVENTS); } + } else if (!strcasecmp(var, "enforce-blind-auth-result")) { + if(switch_true(val)) { + sofia_set_pflag(profile, PFLAG_BLIND_AUTH_ENFORCE_RESULT); + } else { + sofia_clear_pflag(profile, PFLAG_BLIND_AUTH_ENFORCE_RESULT); + } } } @@ -9434,6 +9441,7 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia if (!is_auth && sofia_test_pflag(profile, PFLAG_AUTH_CALLS) && sofia_test_pflag(profile, PFLAG_BLIND_AUTH)) { char *user; + switch_status_t blind_result = SWITCH_STATUS_FALSE; if (!strcmp(network_ip, profile->sipip) && network_port == profile->sip_port) { calling_myself++; @@ -9441,10 +9449,11 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia if (sip && sip->sip_from) { user = switch_core_session_sprintf(session, "%s@%s", sip->sip_from->a_url->url_user, sip->sip_from->a_url->url_host); - switch_ivr_set_user(session, user); + blind_result = switch_ivr_set_user(session, user); + } + if(!sofia_test_pflag(profile, PFLAG_BLIND_AUTH_ENFORCE_RESULT) || blind_result == SWITCH_STATUS_SUCCESS) { + is_auth++; } - - is_auth++; } if (!is_auth &&