Commit bc56a9db authored by jehan's avatar jehan

always provide auth info even in case of successfull authentication

parent ef33d5b7
......@@ -57,8 +57,7 @@ BELLESIP_EXPORT void belle_sip_provider_clean_channels(belle_sip_provider_t *p);
* @param p object
* @param request to be updated
* @param resp response to take authentication values from, might be NULL
* @param auth_infos if auth infos cannot be added for an authenticate header, (I.E case where this method return TRUE),
* a newly allocated belle_sip_auth_info_t object is added to this list. These object contains useful information like realm and username.
* @param auth_infos A newly allocated belle_sip_auth_info_t object is added to this list. These object contains useful information like realm and username.
* @returns 0 in case of success,
*
**/
......
......@@ -822,15 +822,15 @@ int belle_sip_provider_add_authorization(belle_sip_provider_t *p, belle_sip_requ
} else
belle_sip_message_add_header(BELLE_SIP_MESSAGE(request),BELLE_SIP_HEADER(authorization));
result=1;
belle_sip_auth_event_destroy(auth_event);
} else {
belle_sip_message("No auth info found for call id [%s]",belle_sip_header_call_id_get_call_id(call_id));
if (auth_infos) {
/*stored to give user information on realm/username which requires authentications*/
*auth_infos=belle_sip_list_append(*auth_infos,auth_event);
} else {
belle_sip_auth_event_destroy(auth_event);
}
}
/*provides auth info in any cases, uasefull even if found because auth info can contains wrong password*/
if (auth_infos) {
/*stored to give user information on realm/username which requires authentications*/
*auth_infos=belle_sip_list_append(*auth_infos,auth_event);
} else {
belle_sip_auth_event_destroy(auth_event);
}
}
......
......@@ -149,7 +149,7 @@ static void process_response_event(void *user_ctx, const belle_sip_response_even
refresher->auth_failures++;
if (refresher->auth_failures>3){
/*avoid looping with 407 or 401 */
belle_sip_warning("Authentication is failling constantly, giving up.");
belle_sip_warning("Authentication is failing constantly, giving up.");
if (refresher->expires>0) retry_later(refresher);
break;
}
......@@ -229,7 +229,10 @@ void belle_sip_refresher_set_listener(belle_sip_refresher_t* refresher, belle_si
int belle_sip_refresher_refresh(belle_sip_refresher_t* refresher,int expires) {
return belle_sip_refresher_refresh_internal(refresher,expires,FALSE,NULL);
}
static int unfilled_auth_info(const void* info,const void* userptr) {
belle_sip_auth_event_t* auth_info = (belle_sip_auth_event_t*)info;
return auth_info->passwd || auth_info->ha1;
}
static int belle_sip_refresher_refresh_internal(belle_sip_refresher_t* refresher,int expires,int auth_mandatory, belle_sip_list_t** auth_infos) {
belle_sip_request_t*old_request=belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(refresher->transaction));
belle_sip_response_t*old_response=belle_sip_transaction_get_response(BELLE_SIP_TRANSACTION(refresher->transaction));
......@@ -279,7 +282,7 @@ static int belle_sip_refresher_refresh_internal(belle_sip_refresher_t* refresher
return -1;
}
if (auth_mandatory && auth_infos && (*auth_infos!=NULL || belle_sip_list_size(*auth_infos)) >0) {
if (auth_mandatory && auth_infos && belle_sip_list_find_custom(*auth_infos, unfilled_auth_info, NULL)) {
belle_sip_message("Auth info not found for this refresh operation on [%p]",refresher);
if (request) belle_sip_object_unref(request);
return -1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment