ympd
ympd copied to clipboard
HTTP: Access Authentication
Could you please add either "basic" or "digest" http authentication feature (rfc2617) As for me it's very necessary feature.
Hi, I added this feature, quite easy as ympd uses Mongoose HTTP lib. I'll fork the code. But basically you jsut have to add those lines to the http event handler :
static int server_callback(struct mg_connection *c, enum mg_event ev) {
int result = MG_FALSE;
FILE *fp;
switch(ev) {
case MG_CLOSE:
mpd_close_handler(c);
return MG_TRUE;
case MG_REQUEST:
if (c->is_websocket) {
c->content[c->content_len] = '\0';
if(c->content_len)
return callback_mpd(c);
else
return MG_TRUE;
} else
#ifdef WITH_DYNAMIC_ASSETS
return MG_FALSE;
#else
return callback_http(c);
#endif
case MG_AUTH:
if ((fp = fopen("/opt/ympd/secrets/.htpasswd", "r")) != NULL) {
result = mg_authorize_digest(c, fp);
fclose(fp);
}
return result;
default:
return MG_FALSE;
}
}
would it be possible to add ssl to this too?
@shazz that shomehow didn't work for me, I ended up having a loop were my browser constantly asked for credentials :(
@typhoon71 adding SSL support just requires that ympd is compiled with SSL support, see PR #97
I figured it out and created pull request #101 For a version supporting both SSL and htdigest check out my fork: https://github.com/SuperBFG7/ympd