Skip to content

Support http-basic-auth via basicAuth setting #47

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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/wordpress.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ function Client( settings ) {
// via settings.host
headers: {
Host: parsedUrl.host
},
basic_auth: !settings.basicAuth ? null : {
user: settings.basicAuth.username,
pass: settings.basicAuth.password
}
});
this.blogId = settings.blogId || 0;
Expand Down
4 changes: 3 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ Creates a new client instance.
* `host` (optional): The actual host to connect to if different from the URL, e.g., when deploying to a local server behind a firewall.
* `blogId` (optional; default: `0`): The blog ID for the WordPress install.
* `rejectUnauthorized` (optional; default: `true`): A boolean indicating whether Node.js should automatically reject clients with invalid certificates. See [tls.createSecurePair()](https://nodejs.org/api/tls.html#tls_tls_createsecurepair_context_isserver_requestcert_rejectunauthorized_options) in Node's documentation.

* `basicAuth` (optional: default: `null`): A object holding http basic authentication credentials
* `username`: The username for the http basic auth.
* `password`: The password for the http basic auth.
#### wordpress.Client

The constructor used for client connections. Useful for creating extensions.
Expand Down