mirror of
https://github.com/owntone/owntone-server.git
synced 2025-11-20 18:06:14 -05:00
Add authentication to web interface, RSP and DAAP
This commit is contained in:
@@ -1789,6 +1789,9 @@ daap_request(struct evhttp_request *req)
|
||||
char *uri_parts[7];
|
||||
struct evbuffer *evbuf;
|
||||
struct evkeyvalq query;
|
||||
cfg_t *lib;
|
||||
char *libname;
|
||||
char *passwd;
|
||||
int handler;
|
||||
int ret;
|
||||
int i;
|
||||
@@ -1838,6 +1841,34 @@ daap_request(struct evhttp_request *req)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check authentication */
|
||||
lib = cfg_getnsec(cfg, "library", 0);
|
||||
passwd = cfg_getstr(lib, "password");
|
||||
|
||||
/* No authentication for these URIs */
|
||||
if ((strcmp(uri, "/server-info") == 0)
|
||||
|| (strcmp(uri, "/logout") == 0)
|
||||
|| (strncmp(uri, "/databases/1/items/", strlen("/databases/1/items/")) == 0))
|
||||
passwd = NULL;
|
||||
|
||||
if (passwd)
|
||||
{
|
||||
libname = cfg_getstr(lib, "name");
|
||||
|
||||
DPRINTF(E_DBG, L_HTTPD, "Checking authentication for library '%s'\n", libname);
|
||||
|
||||
/* We don't care about the username */
|
||||
ret = httpd_basic_auth(req, NULL, passwd, libname);
|
||||
if (ret != 0)
|
||||
{
|
||||
free(uri);
|
||||
free(full_uri);
|
||||
return;
|
||||
}
|
||||
|
||||
DPRINTF(E_DBG, L_HTTPD, "Library authentication successful\n");
|
||||
}
|
||||
|
||||
memset(uri_parts, 0, sizeof(uri_parts));
|
||||
|
||||
uri_parts[0] = strtok_r(uri, "/", &ptr);
|
||||
|
||||
Reference in New Issue
Block a user