Make WordPress Core


Ignore:
Timestamp:
12/04/2020 09:42:52 PM (4 years ago)
Author:
TimothyBlynJacobs
Message:

App Passwords: Prevent conflicts when Basic Auth is already used by the site.

Application Passwords uses Basic Authentication to transfer authentication details. If the site is already using Basic Auth, for instance to implement a private staging environment, then the REST API will treat this as an authentication attempt and would end up generating an error for any REST API request.

Now, Application Password authentication will only be attempted if Application Passwords is in use by a site. This is flagged by setting an option whenever an Application Password is created. An upgrade routine is added to set this option if any App Passwords already exist.

Lastly, creating an Application Password will be prevented if the site appears to already be using Basic Authentication.

Props chexwarrior, georgestephanis, adamsilverstein, helen, Clorith, marybaum, TimothyBlynJacobs.
Fixes #51939.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/authorize-application.php

    r49617 r49752  
    8686        __( 'The Authorize Application request is not allowed.' ) . ' ' . implode( ' ', $is_valid->get_error_messages() ),
    8787        __( 'Cannot Authorize Application' )
     88    );
     89}
     90
     91if ( ! empty( $_SERVER['PHP_AUTH_USER'] ) || ! empty( $_SERVER['PHP_AUTH_PW'] ) ) {
     92    wp_die(
     93        __( 'Your website appears to use Basic Authentication, which is not currently compatible with Application Passwords.' ),
     94        __( 'Cannot Authorize Application' ),
     95        array(
     96            'response'  => 501,
     97            'link_text' => __( 'Go Back' ),
     98            'link_url'  => $reject_url ? add_query_arg( 'error', 'disabled', $reject_url ) : admin_url(),
     99        )
    88100    );
    89101}
Note: See TracChangeset for help on using the changeset viewer.