From d1385dc8f0cfc7870333d0999bbcd0330ed84eca Mon Sep 17 00:00:00 2001 From: George Stephanis Date: Fri, 24 Feb 2017 20:40:40 -0800 Subject: [PATCH 1/4] Add a better catcher for the jQuery block so it handles displaying the error when a 404 code is caught. --- application-passwords.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/application-passwords.js b/application-passwords.js index 6372486..0179487 100644 --- a/application-passwords.js +++ b/application-passwords.js @@ -19,6 +19,14 @@ method: 'POST', beforeSend: function( xhr ) { xhr.setRequestHeader( 'Authorization', 'Basic ' + btoa( testBasicAuthUser + ':' + testBasicAuthPassword ) ); + }, + error: function( jqXHR ) { + if ( 404 === jqXHR.status ) { + $newAppPassForm.before( tmplNotice( { + type: 'error', + message: appPass.text.no_credentials + } ) ); + } } } ).done( function( response ) { if ( response.PHP_AUTH_USER === testBasicAuthUser && response.PHP_AUTH_PW === testBasicAuthPassword ) { From 0c2dc42a532547c5300b05bf8cf2e970110ae9a2 Mon Sep 17 00:00:00 2001 From: George Stephanis Date: Fri, 24 Feb 2017 20:49:21 -0800 Subject: [PATCH 2/4] Add a link to a more verbose explainer of http basic auth issues. --- class.application-passwords.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/class.application-passwords.php b/class.application-passwords.php index 1209696..7ac43dc 100644 --- a/class.application-passwords.php +++ b/class.application-passwords.php @@ -403,7 +403,7 @@ public static function show_user_profile( $user ) { 'nonce' => wp_create_nonce( 'wp_rest' ), 'user_id' => $user->ID, 'text' => array( - 'no_credentials' => __( 'Due to a potential server misconfiguration, it seems that HTTP Basic Authorization may not work for the REST API on this site: `Authorization` headers are not being sent to WordPress by the web server.' ), + 'no_credentials' => __( 'Due to a potential server misconfiguration, it seems that HTTP Basic Authorization may not work for the REST API on this site: `Authorization` headers are not being sent to WordPress by the web server. You can learn more about this problem, and a possible solution, on our GitHub Wiki.' ), ), ) ); @@ -468,7 +468,7 @@ public static function show_user_profile( $user ) { Date: Tue, 15 Aug 2017 10:20:32 -0400 Subject: [PATCH 3/4] Fix a typo. Fixes #65 --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 8f5f5b3..0d7123d 100644 --- a/readme.md +++ b/readme.md @@ -90,7 +90,7 @@ echo -n "admin:mypassword123" | base64 2. Once your username and password are base64 encoded, you are now able to make a simple REST API call using the terminal window to update a post. Because you are performing a POST request, you will need to authorize the request using your newly created base64 encoded access token. If authorized correctly, you will see the post title update to "New Title." ```shell -curl --header "Authorization: Basic ACCESS_TOKEN" -X POST -d "title=New Title" http://LOCALHOST/wp-json/wp/v2/posts/POST_ID} +curl --header "Authorization: Basic ACCESS_TOKEN" -X POST -d "title=New Title" http://LOCALHOST/wp-json/wp/v2/posts/POST_ID ``` When running this command, be sure to replace *ACCESS_TOKEN* with your newly generated access token, *LOCALHOST* with the location of your local WordPress installation, and *POST_ID* with the ID of the post that you want to edit. From d342d38f9d6db5a2e40ba1d8c3d3988e64cb17bf Mon Sep 17 00:00:00 2001 From: George Stephanis Date: Sun, 3 Dec 2017 13:29:41 -0600 Subject: [PATCH 4/4] Update readme.txt --- readme.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.txt b/readme.txt index 8ac456a..82c04a2 100644 --- a/readme.txt +++ b/readme.txt @@ -2,7 +2,7 @@ Contributors: georgestephanis, valendesigns, kraftbj Tags: application-passwords, rest api, xml-rpc, security, authentication Requires at least: 4.4 -Tested up to: 4.5 +Tested up to: 4.9 Stable tag: trunk License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -79,4 +79,4 @@ Once you have created a new application password, it's time to send a request to ```shell curl -H 'Content-Type: text/xml' -d 'wp.getUsers1USERNAMEPASSWORD' LOCALHOST ``` -In the above example, replace *USERNAME* with your username, and *PASSWORD* with your new application password. This should output a response containing all users on your site. \ No newline at end of file +In the above example, replace *USERNAME* with your username, and *PASSWORD* with your new application password. This should output a response containing all users on your site.