From 2b19238cf8064dafb66b9db09d0adcc9eac7f724 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Tue, 12 Jul 2016 14:28:15 +0200 Subject: [PATCH] Support HTTP basic authentication Closes gh-47 Closes gh-36 --- lib/wordpress.js | 4 ++++ readme.md | 3 +++ 2 files changed, 7 insertions(+) diff --git a/lib/wordpress.js b/lib/wordpress.js index 205472c..8bd9e91 100644 --- a/lib/wordpress.js +++ b/lib/wordpress.js @@ -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; diff --git a/readme.md b/readme.md index 0dbc536..1e4a9d9 100644 --- a/readme.md +++ b/readme.md @@ -56,6 +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): An object holding HTTP basic authentication credentials. + * `username`: The username for the HTTP basic auth. + * `password`: The password for the HTTP basic auth. #### wordpress.Client