Skip to content

Commit 2b19238

Browse files
staabmscottgonzalez
authored andcommitted
Support HTTP basic authentication
Closes gh-47 Closes gh-36
1 parent 5f051d8 commit 2b19238

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/wordpress.js

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ function Client( settings ) {
4444
// via settings.host
4545
headers: {
4646
Host: parsedUrl.host
47+
},
48+
basic_auth: !settings.basicAuth ? null : {
49+
user: settings.basicAuth.username,
50+
pass: settings.basicAuth.password
4751
}
4852
});
4953
this.blogId = settings.blogId || 0;

readme.md

+3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ Creates a new client instance.
5656
* `host` (optional): The actual host to connect to if different from the URL, e.g., when deploying to a local server behind a firewall.
5757
* `blogId` (optional; default: `0`): The blog ID for the WordPress install.
5858
* `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.
59+
* `basicAuth` (optional): An object holding HTTP basic authentication credentials.
60+
* `username`: The username for the HTTP basic auth.
61+
* `password`: The password for the HTTP basic auth.
5962

6063
#### wordpress.Client
6164

0 commit comments

Comments
 (0)