|
|
|
@ -40,41 +40,6 @@
|
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int auth_check(Octstr *user, Octstr *pass, List *headers, int *has_auth_hdr)
|
|
|
|
|
{
|
|
|
|
|
int i, res = -1;
|
|
|
|
|
Octstr *v = http_header_value(headers, octstr_imm("Authorization"));
|
|
|
|
|
Octstr *p = NULL, *q = NULL;
|
|
|
|
|
|
|
|
|
|
*has_auth_hdr = (v != NULL);
|
|
|
|
|
if (octstr_len(user) == 0) {
|
|
|
|
|
res = 0;
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!v ||
|
|
|
|
|
octstr_search(v, octstr_imm("Basic "), 0) != 0)
|
|
|
|
|
goto done;
|
|
|
|
|
p = octstr_copy(v, sizeof "Basic", octstr_len(v));
|
|
|
|
|
octstr_base64_to_binary(p);
|
|
|
|
|
|
|
|
|
|
i = octstr_search_char(p, ':', 0);
|
|
|
|
|
q = octstr_copy(p, i+1, octstr_len(p));
|
|
|
|
|
octstr_delete(p, i, octstr_len(p));
|
|
|
|
|
|
|
|
|
|
/* p = user, q = pass. */
|
|
|
|
|
|
|
|
|
|
if (octstr_compare(user, p) != 0 ||
|
|
|
|
|
octstr_compare(pass, q) != 0)
|
|
|
|
|
res = -1;
|
|
|
|
|
else
|
|
|
|
|
res = 0;
|
|
|
|
|
done:
|
|
|
|
|
octstr_destroy(v);
|
|
|
|
|
octstr_destroy(p);
|
|
|
|
|
octstr_destroy(q);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Octstr *get_dlr_notify_url(Octstr *msgid, char *report_type, Octstr *mmc_gid, Octstr *mmc_id,
|
|
|
|
|
Octstr *status,
|
|
|
|
@ -1027,10 +992,12 @@ static void dispatch_mm7_recv(List *rl)
|
|
|
|
|
/* hmon->register_thread( "dispatch_mm7" ); */
|
|
|
|
|
while ((h = gwlist_consume(rl)) != NULL) {
|
|
|
|
|
MmscGrp *m = h->m;
|
|
|
|
|
char *user = m->incoming.user ? octstr_get_cstr(m->incoming.user) : NULL;
|
|
|
|
|
char *pass = m->incoming.pass ? octstr_get_cstr(m->incoming.pass) : NULL;
|
|
|
|
|
int ret = -1, has_auth = (m->type != MM1_MMSC); /* We dont authenticate mm1. right? */
|
|
|
|
|
|
|
|
|
|
if (!has_auth && auth_check(m->incoming.user,
|
|
|
|
|
m->incoming.pass,
|
|
|
|
|
if (!has_auth && http_auth_check(user,
|
|
|
|
|
pass,
|
|
|
|
|
h->headers, &has_auth) != 0) { /* Ask it to authenticate... */
|
|
|
|
|
List *hh = http_create_empty_headers();
|
|
|
|
|
http_header_add(hh, "WWW-Authenticate",
|
|
|
|
|