]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7228 - Max Register Refresh before the Register is challenged for credentials
authorRajesh Panicker <rajesh@firespotter.com>
Fri, 6 Feb 2015 07:23:41 +0000 (23:23 -0800)
committerRajesh Panicker <rajesh@firespotter.com>
Fri, 6 Feb 2015 18:16:36 +0000 (10:16 -0800)
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_reg.c

index 52307a2800431f2d89e545bfc94d58b045d00f59..28ce0f8fb6c675b954b81836e77314e576064bff 100644 (file)
@@ -639,6 +639,7 @@ struct sofia_profile {
        unsigned int mndlb;
        uint32_t max_calls;
        uint32_t nonce_ttl;
+       uint32_t max_auth_validity;
        nua_t *nua;
        switch_memory_pool_t *pool;
        su_root_t *s_root;
index 0f0f492e995434d1e23caa9922b057a8a7e2ceb2..1eafbe438448a4d4ec60519061c931d8063dfa48 100644 (file)
@@ -4971,6 +4971,8 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
                                                }
                                        } else if (!strcasecmp(var, "nonce-ttl")) {
                                                profile->nonce_ttl = atoi(val);
+                                       } else if (!strcasecmp(var, "max-auth-validity")) {
+                                               profile->max_auth_validity = atoi(val);
                                        } else if (!strcasecmp(var, "accept-blind-reg")) {
                                                if (switch_true(val)) {
                                                        sofia_set_pflag(profile, PFLAG_BLIND_REG);
@@ -5390,6 +5392,11 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting nonce TTL to 60 seconds\n");
                                        profile->nonce_ttl = 60;
                                }
+                               
+                               if (!profile->max_auth_validity) {
+                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting MAX Auth Validity to 0 Attempts\n");
+                                       profile->max_auth_validity = 0;
+                               }
 
                                if (!profile->sdp_username) {
                                        profile->sdp_username = switch_core_strdup(profile->pool, "FreeSWITCH");
index 7e26470d7329cda15d18a2626429b07c2a182c9f..dad7c09a36f92d7828094a37bc08129eb22fd0ce 100644 (file)
@@ -2726,7 +2726,7 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile,
                free(sql);
 
                //if (!sofia_glue_execute_sql2str(profile, profile->dbh_mutex, sql, np, nplen)) {
-               if (zstr(np)) {
+               if (zstr(np) || (profile->max_auth_validity != 0 && cb.last_nc >= profile->max_auth_validity )) {
                        sql = switch_mprintf("delete from sip_authentication where nonce='%q'", nonce);
                        sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
                        ret = AUTH_STALE;