Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
belle-sip
Commits
62477789
Commit
62477789
authored
Jun 06, 2018
by
Matthieu Tanon
Browse files
Add From header in http requests for authentication purposes
parent
0e96f66a
Pipeline
#38
failed with stage
in 0 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
src/http-provider.c
src/http-provider.c
+10
-3
No files found.
src/http-provider.c
View file @
62477789
...
@@ -56,7 +56,6 @@ static int http_channel_context_handle_authentication(belle_http_channel_context
...
@@ -56,7 +56,6 @@ static int http_channel_context_handle_authentication(belle_http_channel_context
belle_sip_header_www_authenticate_t
*
authenticate
;
belle_sip_header_www_authenticate_t
*
authenticate
;
int
ret
=
0
;
int
ret
=
0
;
if
(
req
->
auth_attempt_count
>
1
){
if
(
req
->
auth_attempt_count
>
1
){
req
->
auth_attempt_count
=
0
;
req
->
auth_attempt_count
=
0
;
return
-
1
;
return
-
1
;
...
@@ -73,7 +72,6 @@ static int http_channel_context_handle_authentication(belle_http_channel_context
...
@@ -73,7 +72,6 @@ static int http_channel_context_handle_authentication(belle_http_channel_context
return
-
1
;
return
-
1
;
}
}
if
(
strcasecmp
(
"Digest"
,
belle_sip_header_www_authenticate_get_scheme
(
authenticate
))
!=
0
)
{
if
(
strcasecmp
(
"Digest"
,
belle_sip_header_www_authenticate_get_scheme
(
authenticate
))
!=
0
)
{
belle_sip_error
(
"Unsupported auth scheme [%s] in response [%p], cannot authenticate"
,
belle_sip_header_www_authenticate_get_scheme
(
authenticate
),
resp
);
belle_sip_error
(
"Unsupported auth scheme [%s] in response [%p], cannot authenticate"
,
belle_sip_header_www_authenticate_get_scheme
(
authenticate
),
resp
);
return
-
1
;
return
-
1
;
...
@@ -85,9 +83,18 @@ static int http_channel_context_handle_authentication(belle_http_channel_context
...
@@ -85,9 +83,18 @@ static int http_channel_context_handle_authentication(belle_http_channel_context
passwd
=
belle_generic_uri_get_user_password
(
req
->
orig_uri
);
passwd
=
belle_generic_uri_get_user_password
(
req
->
orig_uri
);
}
}
// add from_uri to process_auth_requested event data
belle_sip_uri_t
*
from_uri
=
NULL
;
belle_sip_header_t
*
header
=
belle_sip_message_get_header
(
BELLE_SIP_MESSAGE
(
req
),
"From"
);
if
(
header
)
{
belle_sip_header_address_t
*
from_address
=
belle_sip_header_address_parse
(
belle_sip_header_get_unparsed_value
(
header
));
from_uri
=
belle_sip_header_address_get_uri
(
from_address
);
}
realm
=
belle_sip_header_www_authenticate_get_realm
(
authenticate
);
realm
=
belle_sip_header_www_authenticate_get_realm
(
authenticate
);
if
(
!
username
||
!
passwd
)
{
if
(
!
username
||
!
passwd
)
{
ev
=
belle_sip_auth_event_create
((
belle_sip_object_t
*
)
ctx
->
provider
,
realm
,
NULL
);
ev
=
belle_sip_auth_event_create
((
belle_sip_object_t
*
)
ctx
->
provider
,
realm
,
from_uri
);
BELLE_HTTP_REQUEST_INVOKE_LISTENER
(
req
,
process_auth_requested
,
ev
);
BELLE_HTTP_REQUEST_INVOKE_LISTENER
(
req
,
process_auth_requested
,
ev
);
username
=
ev
->
username
;
username
=
ev
->
username
;
passwd
=
ev
->
passwd
;
passwd
=
ev
->
passwd
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment