[asterisk-scf-commits] asterisk-scf/release/pjproject.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Tue Aug 30 12:44:38 CDT 2011
branch "master" has been updated
via d0b00a22e2d840431e0bf82ae2980e65ebd36905 (commit)
from d7780631be411856e61d1633e39961e319916307 (commit)
Summary of changes:
pjsip/include/pjsip/sip_auth.h | 2 +-
pjsip/src/pjsip/sip_auth_server.c | 33 ++++++++++++++++-----------------
2 files changed, 17 insertions(+), 18 deletions(-)
- Log -----------------------------------------------------------------
commit d0b00a22e2d840431e0bf82ae2980e65ebd36905
Author: Joshua Colp <jcolp at digium.com>
Date: Tue Aug 30 14:48:04 2011 -0300
Provide an easier method of attaching authentication information that does not require a callback.
diff --git a/pjsip/include/pjsip/sip_auth.h b/pjsip/include/pjsip/sip_auth.h
index 57db0e7..e5737fe 100644
--- a/pjsip/include/pjsip/sip_auth.h
+++ b/pjsip/include/pjsip/sip_auth.h
@@ -274,7 +274,7 @@ typedef struct pjsip_auth_srv
pj_str_t realm; /**< Realm to serve. */
pj_bool_t is_proxy; /**< Will issue 407 instead of 401 */
pjsip_auth_lookup_cred *lookup; /**< Lookup function. */
-
+ pjsip_cred_info cred_info; /**< Credentials */
} pjsip_auth_srv;
diff --git a/pjsip/src/pjsip/sip_auth_server.c b/pjsip/src/pjsip/sip_auth_server.c
index 1a557d7..9dce9c9 100644
--- a/pjsip/src/pjsip/sip_auth_server.c
+++ b/pjsip/src/pjsip/sip_auth_server.c
@@ -38,7 +38,7 @@ PJ_DEF(pj_status_t) pjsip_auth_srv_init( pj_pool_t *pool,
pjsip_auth_lookup_cred *lookup,
unsigned options )
{
- PJ_ASSERT_RETURN(pool && auth_srv && realm && lookup, PJ_EINVAL);
+ PJ_ASSERT_RETURN(pool && auth_srv && realm, PJ_EINVAL);
pj_strdup( pool, &auth_srv->realm, realm);
auth_srv->lookup = lookup;
@@ -60,14 +60,12 @@ static pj_status_t pjsip_auth_verify( const pjsip_authorization_hdr *hdr,
pj_str_t digest;
const pjsip_digest_credential *dig = &hdr->credential.digest;
- /* Check that username and realm match.
- * These checks should have been performed before entering this
- * function.
- */
- PJ_ASSERT_RETURN(pj_strcmp(&dig->username, &cred_info->username) == 0,
- PJ_EINVALIDOP);
- PJ_ASSERT_RETURN(pj_strcmp(&dig->realm, &cred_info->realm) == 0,
- PJ_EINVALIDOP);
+ /* Check that username and realm match. */
+ if ((pj_strcmp(&dig->username, &cred_info->username) != 0) ||
+ (pj_strcmp(&dig->realm, &cred_info->realm) != 0))
+ {
+ return PJ_EINVALIDOP;
+ }
/* Prepare for our digest calculation. */
digest.ptr = digest_buf;
@@ -107,7 +105,6 @@ PJ_DEF(pj_status_t) pjsip_auth_srv_verify( pjsip_auth_srv *auth_srv,
pjsip_msg *msg = rdata->msg_info.msg;
pjsip_hdr_e htype;
pj_str_t acc_name;
- pjsip_cred_info cred_info;
pj_status_t status;
PJ_ASSERT_RETURN(auth_srv && rdata, PJ_EINVAL);
@@ -147,17 +144,19 @@ PJ_DEF(pj_status_t) pjsip_auth_srv_verify( pjsip_auth_srv *auth_srv,
return PJSIP_EINVALIDAUTHSCHEME;
}
- /* Find the credential information for the account. */
- status = (*auth_srv->lookup)(rdata->tp_info.pool, &auth_srv->realm,
- &acc_name, &cred_info);
- if (status != PJ_SUCCESS) {
- *status_code = PJSIP_SC_FORBIDDEN;
- return status;
+ if (*auth_srv->lookup) {
+ /* Find the credential information for the account. */
+ status = (*auth_srv->lookup)(rdata->tp_info.pool, &auth_srv->realm,
+ &acc_name, &auth_srv->cred_info);
+ if (status != PJ_SUCCESS) {
+ *status_code = PJSIP_SC_FORBIDDEN;
+ return status;
+ }
}
/* Authenticate with the specified credential. */
status = pjsip_auth_verify(h_auth, &msg->line.req.method.name,
- &cred_info);
+ &auth_srv->cred_info);
if (status != PJ_SUCCESS) {
*status_code = PJSIP_SC_FORBIDDEN;
}
-----------------------------------------------------------------------
--
asterisk-scf/release/pjproject.git
More information about the asterisk-scf-commits
mailing list