1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2025-01-06 03:25:31 +00:00

sip: slightly improved authentication

* removed nua_callstate_authenticating as it was never hit
* move debug statement further up, because we might not reach it if no
  corresponding call is found
* handle 401 and 407 the same way
  note: we should record which realm we're authenticating against during
  REGISTER so we can prompt the user for additional credentials when
  challenged for a different realm - still happens when calling from
  a sip.linphone.org account to a jmp.bwapp.bwsip.io account.
This commit is contained in:
Evangelos Ribeiro Tzaras 2021-03-11 00:30:12 +01:00
parent cadaa6a3e0
commit 17ac56fe44

View file

@ -128,6 +128,10 @@ sip_authenticate (CallsSipOrigin *origin,
scheme = proxy_auth->au_scheme;
realm = msg_params_find (proxy_auth->au_params, "realm=");
}
else {
g_warning ("No authentication context found");
return;
}
g_debug ("need to authenticate to realm %s", realm);
auth = g_strdup_printf ("%s:%s:%s:%s",
@ -149,17 +153,15 @@ sip_r_invite (int status,
g_debug ("response to outgoing INVITE: %03d %s", status, phrase);
/* TODO call states (see i_state) */
if (status == 401) {
if (status == 401 || status == 407) {
sip_authenticate (origin, nh, sip);
}
else if (status == 403) {
g_warning ("wrong credentials?");
}
else if (status == 407) {
sip_authenticate (origin, nh, sip);
g_warning ("Response to outgoing INVITE: 403 wrong credentials?");
}
else if (status == 904) {
g_warning ("unmatched challenge");
g_warning ("Response to outgoing INVITE: 904 unmatched challenge."
"Possibly the challenge was already answered?");
}
else if (status == 180) {
}
@ -187,7 +189,7 @@ sip_r_register (int status,
origin->state = SIP_ACCOUNT_ONLINE;
}
else if (status == 401) {
else if (status == 401 || status == 407) {
sip_authenticate (origin, nh, sip);
origin->state = SIP_ACCOUNT_AUTHENTICATING;
@ -221,6 +223,8 @@ sip_i_state (int status,
g_assert (CALLS_IS_SIP_ORIGIN (origin));
g_debug ("The call state has changed: %03d %s", status, phrase);
call = g_hash_table_lookup (origin->call_handles, nh);
if (call == NULL) {
@ -228,7 +232,6 @@ sip_i_state (int status,
return;
}
g_debug ("The call state has changed: %03d %s", status, phrase);
tl_gets (tags,
SOATAG_REMOTE_SDP_REF (r_sdp),
NUTAG_CALLSTATE_REF (call_state),
@ -283,10 +286,6 @@ sip_i_state (int status,
return;
case nua_callstate_authenticating:
g_warning ("TODO Move authentication (INVITE) here");
return;
default:
return;
}