Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP: Access Authentication #46

Open
kapralVV opened this issue Nov 19, 2014 · 4 comments
Open

HTTP: Access Authentication #46

kapralVV opened this issue Nov 19, 2014 · 4 comments

Comments

@kapralVV
Copy link

Could you please add either "basic" or "digest" http authentication feature (rfc2617)
As for me it's very necessary feature.

@shazz
Copy link

shazz commented Mar 9, 2015

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;
}
}

@typhoon71
Copy link

would it be possible to add ssl to this too?

@SuperBFG7
Copy link
Contributor

@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

@SuperBFG7
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants