add password support

This commit is contained in:
Ron Pedde 2003-12-09 05:48:30 +00:00
parent af983110a2
commit 0df8292d6f
2 changed files with 21 additions and 5 deletions

View File

@ -52,6 +52,21 @@
*/ */
CONFIG config; CONFIG config;
/*
* daap_auth
*
* Auth handler for the daap server
*/
int daap_auth(char *username, char *password) {
if((password == NULL) && (config.readpassword == NULL))
return 1;
if(password == NULL)
return 0;
return !strcasecmp(password,config.readpassword);
}
/* /*
* daap_handler * daap_handler
* *
@ -387,11 +402,11 @@ int main(int argc, char *argv[]) {
ws_registerhandler(server, "^.*$",config_handler,config_auth,1); ws_registerhandler(server, "^.*$",config_handler,config_auth,1);
ws_registerhandler(server, "^/server-info$",daap_handler,NULL,0); ws_registerhandler(server, "^/server-info$",daap_handler,NULL,0);
ws_registerhandler(server, "^/content-codes$",daap_handler,NULL,0); ws_registerhandler(server, "^/content-codes$",daap_handler,NULL,0);
ws_registerhandler(server,"^/login$",daap_handler,NULL,0); ws_registerhandler(server,"^/login$",daap_handler,daap_auth,0);
ws_registerhandler(server,"^/update$",daap_handler,NULL,0); ws_registerhandler(server,"^/update$",daap_handler,daap_auth,0);
ws_registerhandler(server,"^/databases$",daap_handler,NULL,0); ws_registerhandler(server,"^/databases$",daap_handler,daap_auth,0);
ws_registerhandler(server,"^/logout$",daap_handler,NULL,0); ws_registerhandler(server,"^/logout$",daap_handler,daap_auth,0);
ws_registerhandler(server,"^/databases/.*",daap_handler,NULL,0); ws_registerhandler(server,"^/databases/.*",daap_handler,daap_auth,0);
config.stop=0; config.stop=0;

View File

@ -4,4 +4,5 @@ admin_pw secret
mp3_dir mp3 mp3_dir mp3
servername Ron's Secret Stash servername Ron's Secret Stash
playlist mt-daapd.playlist playlist mt-daapd.playlist
password mp3