mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 12:50:28 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@49752 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -37,6 +37,7 @@ class Tests_Auth extends WP_UnitTestCase {
|
||||
|
||||
$this->user = clone self::$_user;
|
||||
wp_set_current_user( self::$user_id );
|
||||
update_site_option( 'using_application_passwords', 1 );
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
@@ -604,4 +605,14 @@ class Tests_Auth extends WP_UnitTestCase {
|
||||
$this->assertInstanceOf( WP_User::class, $user );
|
||||
$this->assertSame( self::$user_id, $user->ID );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 51939
|
||||
*/
|
||||
public function test_authenticate_application_password_returns_null_if_not_in_use() {
|
||||
delete_site_option( 'using_application_passwords' );
|
||||
|
||||
$authenticated = wp_authenticate_application_password( null, 'idonotexist', 'password' );
|
||||
$this->assertNull( $authenticated );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user