Skip to content

Adding basic_auth support #36

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

Closed
wants to merge 1 commit into from

Conversation

ericabouaf
Copy link

Hi,

My Wordpress installation is protected by a Basic Authentication, so here is a fix to support Basic Auth.

Cheers,

}
},

basic_auth: settings.basic_auth
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename the option to basicAuth.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the key basic_auth is defined in https://github.com/baalexander/node-xmlrpc/blob/master/lib/client.js#L61 so cannot be changed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh you mean the key we use in our side of the config..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw... there are some more "misnamed" options in the game. as it stands right now, even when using basicAuth as a key the config would look like

{
    "url": "https://example.com/",
    "username": "test123",
    "password": "xdsfadsf",
    "basicAuth": {
        "user": "testr5z57",
        "pass": "asdfadsf"
    }
}

so username vs. user
and password vs. pass

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to avoid the name mismatch I would suggest using

// ....
    this.rpc = xmlrpc[ parsedUrl.secure ? "createSecureClient" : "createClient" ]({
        host: settings.host || parsedUrl.host,
        port: parsedUrl.port,
        path: parsedUrl.path,

        // Always set Host header in case we're pointing to a different server
        // via settings.host
        headers: {
            Host: parsedUrl.host
        },
        basic_auth: settings.basicAuth ? {
            user: settings.basicAuth.username,
            pass: settings.basicAuth.password
        } : null,
    });
// ....

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

submitted #47

@staabm
Copy link
Contributor

staabm commented Jul 12, 2016

also need support for basic auth... so +1

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

Successfully merging this pull request may close these issues.

3 participants