Module: sip-router Branch: master Commit: 8c98ff6472adf4a1aad986913de86bf3c262810f URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=8c98ff64...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Fri Jul 25 12:25:23 2014 +0200
auth_db: new flag for auth_check() to skip caller id check for forwarding requests
- caller id check is skipped for INVITE, BYE, PRACK, UPDATE, MESSAGE -- these requests can come with an anonymous caller id
---
modules/auth/api.h | 1 + modules/auth_db/authorize.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/modules/auth/api.h b/modules/auth/api.h index a180155..dadf3b5 100644 --- a/modules/auth/api.h +++ b/modules/auth/api.h @@ -60,6 +60,7 @@ typedef enum auth_cfg_result { * flags for checks in auth functions */ #define AUTH_CHECK_ID_F 1<<0 +#define AUTH_CHECK_SKIPFWD_F 1<<1
/** * return codes to auth API functions diff --git a/modules/auth_db/authorize.c b/modules/auth_db/authorize.c index d99c0bb..95a8a3e 100644 --- a/modules/auth_db/authorize.c +++ b/modules/auth_db/authorize.c @@ -506,9 +506,14 @@ int auth_check(struct sip_msg* _m, char* _realm, char* _table, char *_flags) } else { uri = furi; } - if(srealm.len!=uri->user.len - || strncmp(srealm.s, uri->user.s, srealm.len)!=0) - return AUTH_USER_MISMATCH; + if((iflags&AUTH_CHECK_SKIPFWD_F) + && (_m->REQ_METHOD==METHOD_INVITE || _m->REQ_METHOD==METHOD_BYE + || _m->REQ_METHOD==METHOD_PRACK || _m->REQ_METHOD==METHOD_UPDATE + || _m->REQ_METHOD==METHOD_MESSAGE)) { + if(srealm.len!=uri->user.len + || strncmp(srealm.s, uri->user.s, srealm.len)!=0) + return AUTH_USER_MISMATCH; + }
if(_m->REQ_METHOD==METHOD_REGISTER || _m->REQ_METHOD==METHOD_PUBLISH) { /* check from==to */