Module: sip-router Branch: master Commit: 451cce6b5a4edada89a05f80e220b08be58a56a4 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=451cce6b...
Author: Jason Penton jason.penton@gmail.com Committer: Jason Penton jason.penton@gmail.com Date: Fri Aug 8 08:34:48 2014 +0200
modules/ims_auth: use IMS lib for getting IMPI/IMPUs (cleanup)
---
modules/ims_auth/authorize.c | 12 +++--- modules/ims_auth/cxdx_mar.c | 4 +- modules/ims_auth/utils.c | 84 ------------------------------------------ modules/ims_auth/utils.h | 2 - 4 files changed, 8 insertions(+), 94 deletions(-)
diff --git a/modules/ims_auth/authorize.c b/modules/ims_auth/authorize.c index 90d35c3..c409b4a 100644 --- a/modules/ims_auth/authorize.c +++ b/modules/ims_auth/authorize.c @@ -329,14 +329,14 @@ int challenge(struct sip_msg* msg, char* str1, char* str2, int is_proxy_auth, ch }
/* get the private_identity */ - private_identity = get_private_identity(msg, realm, is_proxy_auth); + private_identity = cscf_get_private_identity(msg, realm); if (!private_identity.len) { LM_ERR("No private identity specified (Authorization: username)\n"); stateful_request_reply(msg, 403, MSG_403_NO_PRIVATE); return CSCF_RETURN_BREAK; } /* get the public_identity */ - public_identity = get_public_identity(msg); + public_identity = cscf_get_public_identity(msg); if (!public_identity.len) { LM_ERR("No public identity specified (To:)\n"); stateful_request_reply(msg, 403, MSG_403_NO_PUBLIC); @@ -517,14 +517,14 @@ int www_resync_auth(struct sip_msg* msg, char* _route, char* str1, char* str2) { }
/* get the private_identity */ - private_identity = get_private_identity(msg, realm, is_proxy_auth); + private_identity = cscf_get_private_identity(msg, realm); if (!private_identity.len) { LM_ERR("No private identity specified (Authorization: username)\n"); stateful_request_reply(msg, 403, MSG_403_NO_PRIVATE); return CSCF_RETURN_BREAK; } /* get the public_identity */ - public_identity = get_public_identity(msg); + public_identity = cscf_get_public_identity(msg); if (!public_identity.len) { LM_ERR("No public identity specified (To:)\n"); stateful_request_reply(msg, 403, MSG_403_NO_PUBLIC); @@ -743,13 +743,13 @@ int authenticate(struct sip_msg* msg, char* _realm, char* str2, int is_proxy_aut return 0; //CSCF_RETURN_BREAK; }
- private_identity = get_private_identity(msg, realm, is_proxy_auth); + private_identity = cscf_get_private_identity(msg, realm); if (!private_identity.len) { LM_ERR("private identity missing\n"); return AUTH_NO_CREDENTIALS; }
- public_identity = get_public_identity(msg); + public_identity = cscf_get_public_identity(msg); if (!public_identity.len) { LM_ERR("public identity missing\n"); return AUTH_NO_CREDENTIALS; diff --git a/modules/ims_auth/cxdx_mar.c b/modules/ims_auth/cxdx_mar.c index cdff800..f075821 100644 --- a/modules/ims_auth/cxdx_mar.c +++ b/modules/ims_auth/cxdx_mar.c @@ -138,7 +138,7 @@ void async_cdp_callback(int is_timeout, void *param, AAAMessage *maa, long elaps }
/* get the private_identity */ - private_identity = get_private_identity(t->uas.request, data->realm, data->is_proxy_auth); + private_identity = cscf_get_private_identity(t->uas.request, data->realm); if (!private_identity.len) { LM_ERR("No private identity specified (Authorization: username)\n"); stateful_request_reply_async(t, t->uas.request, 403, MSG_403_NO_PRIVATE); @@ -146,7 +146,7 @@ void async_cdp_callback(int is_timeout, void *param, AAAMessage *maa, long elaps goto error; } /* get the public_identity */ - public_identity = get_public_identity(t->uas.request); + public_identity = cscf_get_public_identity(t->uas.request); if (!public_identity.len) { LM_ERR("No public identity specified (To:)\n"); stateful_request_reply_async(t, t->uas.request, 403, MSG_403_NO_PUBLIC); diff --git a/modules/ims_auth/utils.c b/modules/ims_auth/utils.c index 0548391..ff1ef5b 100644 --- a/modules/ims_auth/utils.c +++ b/modules/ims_auth/utils.c @@ -141,90 +141,6 @@ inline int ims_find_credentials(struct sip_msg* _m, str* _realm, return 1; }
- -/** - * Returns the Private Identity extracted from the Authorization header. - * If none found there takes the SIP URI in To without the "sip:" prefix - * \todo - remove the fallback case to the To header - * @param msg - the SIP message - * @param realm - the realm to match in an Authorization header - * @param is_proxy_auth 0 if the header is Authorization, anything else for Proxy-Authorization - * @returns the str containing the private id, no mem dup - */ -str get_private_identity(struct sip_msg *msg, str realm, int is_proxy_auth) -{ - str pi={0,0}; - struct hdr_field* h=0; - int ret,i; - - if (parse_headers(msg, is_proxy_auth ? HDR_PROXYAUTH_F : HDR_AUTHORIZATION_F,0)!=0) { - return pi; - } - - if (!(is_proxy_auth ? msg->proxy_auth : msg->authorization)){ - goto fallback; - } - - ret = find_credentials(msg, &realm, is_proxy_auth ? HDR_PROXYAUTH_F : HDR_AUTHORIZATION_F, &h); - if (ret < 0) { - goto fallback; - } else - if (ret > 0) { - goto fallback; - } - - if (h) pi=((auth_body_t*)h->parsed)->digest.username.whole; - - goto done; - -fallback: - pi = get_public_identity(msg); - if (pi.len>4&&strncasecmp(pi.s,"sip:",4)==0) {pi.s+=4;pi.len-=4;} - for(i=0;i<pi.len;i++) - if (pi.s[i]==';') { - pi.len=i; - break; - } -done: - return pi; -} - -/** - * Returns the Public Identity extracted from the From header - * @param msg - the SIP message - * @returns the str containing the public id, no mem dup - */ -str get_public_identity(struct sip_msg *msg) -{ - str pu={0,0}; - struct to_body *from; - int i; - - if (parse_headers(msg,HDR_TO_F,0)!=0) { - return pu; - } - - if ( get_from(msg) == NULL ) { - from = (struct to_body*) pkg_malloc(sizeof(struct to_body)); - if (!from) { - LM_ERR("out of pkg memory\n"); - return pu; - } - parse_to( msg->from->body.s, msg->from->body.s + msg->from->body.len, from ); - msg->from->parsed = from; - } - else from=(struct to_body *) msg->from->parsed; - - pu = from->uri; - - /* truncate to sip:username@host or tel:number */ - for(i=4;i<pu.len;i++) - if (pu.s[i]==';' || pu.s[i]=='?' ||pu.s[i]==':'){ - pu.len = i; - } - return pu; -} - /** * Looks for the nonce and response parameters in the Authorization header and returns them * @param msg - the SIP message diff --git a/modules/ims_auth/utils.h b/modules/ims_auth/utils.h index f16ebc1..6412a37 100644 --- a/modules/ims_auth/utils.h +++ b/modules/ims_auth/utils.h @@ -54,8 +54,6 @@ #include "../../parser/parse_content.h" #include "../../data_lump_rpl.h"
-str get_private_identity(struct sip_msg *msg, str realm, int is_proxy_auth); -str get_public_identity(struct sip_msg *msg); int get_nonce_response(struct sip_msg *msg, str realm,str *nonce,str *response, enum qop_type *qop,str *qop_str,str *nc,str *cnonce,str *uri, int is_proxy_auth); str ims_get_body(struct sip_msg * msg);