Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase minimum password length for admin user #39319

Open
wants to merge 3 commits into
base: 2.4-develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/code/Magento/User/Model/UserValidationRules.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2015 Adobe
* All Rights Reserved.
*/

namespace Magento\User\Model;
Expand All @@ -24,7 +24,7 @@ class UserValidationRules
/**
* Minimum length of admin password
*/
public const MIN_PASSWORD_LENGTH = 7;
public const MIN_PASSWORD_LENGTH = 12;

/**
* Adds validation rule for user first name, last name, username and email
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2016 Adobe
* All Rights Reserved.
*/
declare(strict_types=1);

Expand Down Expand Up @@ -201,19 +201,19 @@ public static function executeDataProvider()
{
return [
[
'currentUserPassword' => '123123q',
'currentUserPassword' => '1234512345q!',
'userId' => 1,
'currentUserId' => 2,
'resultMethod' => 'addSuccess',
],
[
'currentUserPassword' => '123123q',
'currentUserPassword' => '1234512345q!',
'userId' => 0,
'currentUserId' => 2,
'resultMethod' => 'addError',
],
[
'currentUserPassword' => '123123q',
'currentUserPassword' => '1234512345q!',
'userId' => 1,
'currentUserId' => 1,
'resultMethod' => 'addError',
Expand Down
6 changes: 3 additions & 3 deletions dev/tests/api-functional/config/install-config-mysql.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/**
* Magento console installer options for Web API functional tests. Are used in functional tests bootstrap.
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2015 Adobe
* All Rights Reserved.
*/
return [
'language' => 'en_US',
Expand All @@ -21,7 +21,7 @@ return [
'admin-firstname' => 'Admin',
'admin-email' => '[email protected]',
'admin-user' => 'admin',
'admin-password' => '123123q',
'admin-password' => '1234512345q!',
'admin-use-security-key' => '0',
/* PayPal has limitation for order number - 20 characters. 10 digits prefix + 8 digits number is good enough */
'sales-order-increment-prefix' => time(),
Expand Down
6 changes: 3 additions & 3 deletions dev/tests/integration/etc/install-config-mysql.php.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2011 Adobe
* All Rights Reserved.
*/

return [
'db-host' => 'localhost',
'db-user' => 'root',
'db-password' => '123123q',
'db-password' => '1234512345q!',
'db-name' => 'magento_integration_tests',
'db-prefix' => '',
'backend-frontname' => 'backend',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2011 Adobe
* All Rights Reserved.
*/

namespace Magento\TestFramework;
Expand All @@ -15,7 +15,7 @@ class Bootstrap
* Predefined admin user credentials
*/
public const ADMIN_NAME = 'user';
public const ADMIN_PASSWORD = 'password1';
public const ADMIN_PASSWORD = 'password1234';
public const ADMIN_EMAIL = '[email protected]';
public const ADMIN_FIRSTNAME = 'firstname';
public const ADMIN_LASTNAME = 'lastname';
Expand Down
12 changes: 6 additions & 6 deletions dev/tests/integration/testsuite/Magento/User/Model/UserTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2012 Adobe
* All Rights Reserved.
*/

namespace Magento\User\Model;
Expand Down Expand Up @@ -392,11 +392,11 @@ public function testBeforeSavePasswordHash()
)->setEmail(
'[email protected]'
)->setPassword(
'123123q'
'1234512345q!'
);
$this->_model->save();
$this->assertStringNotContainsString(
'123123q',
'1234512345q!',
$this->_model->getPassword(),
'Password is expected to be hashed'
);
Expand Down Expand Up @@ -486,9 +486,9 @@ public function testBeforeSaveValidationSuccess()
)->setEmail(
'[email protected]'
)->setPassword(
'1234abc'
'1234512345q!'
)->setPasswordConfirmation(
'1234abc'
'1234512345q!'
);
$this->_model->save();
}
Expand Down
6 changes: 3 additions & 3 deletions dev/tests/setup-integration/etc/install-config-mysql.php.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2017 Adobe
* All Rights Reserved.
*/

return [
Expand All @@ -14,7 +14,7 @@ return [
'db-prefix' => '',
'backend-frontname' => 'admin',
'admin-user' => 'admin',
'admin-password' => '123123q',
'admin-password' => '1234512345q!',
'admin-email' => \Magento\TestFramework\Bootstrap::ADMIN_EMAIL,
'admin-firstname' => \Magento\TestFramework\Bootstrap::ADMIN_FIRSTNAME,
'admin-lastname' => \Magento\TestFramework\Bootstrap::ADMIN_LASTNAME,
Expand Down
8 changes: 4 additions & 4 deletions lib/web/mage/validation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2012 Adobe
* All Rights Reserved.
*/

define([
Expand Down Expand Up @@ -685,13 +685,13 @@ define([
return false;
}

if (pass.length < 7) {
if (pass.length < 12) {
return false;
}

return true;
},
$.mage.__('Please enter 7 or more characters, using both numeric and alphabetic.')
$.mage.__('Please enter 12 or more characters, using both numeric and alphabetic.')
],
'validate-customer-password': [
function (v, elm) {
Expand Down
6 changes: 3 additions & 3 deletions setup/src/Magento/Setup/Fixtures/AdminUsersFixture.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2017 Adobe
* All Rights Reserved.
*/

namespace Magento\Setup\Fixtures;
Expand Down Expand Up @@ -98,7 +98,7 @@ public function execute()
->setFirstName('Firstname')
->setLastName('Lastname')
->setUserName('admin' . $i)
->setPassword('123123q')
->setPassword('1234512345q!')
->setIsActive(1);
$adminUser->save();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2015 Adobe
* All Rights Reserved.
*/
declare(strict_types=1);

Expand Down Expand Up @@ -62,14 +62,14 @@ public function testExecute(): void
{
$options = [
'--' . AdminAccount::KEY_USER => 'user',
'--' . AdminAccount::KEY_PASSWORD => '123123q',
'--' . AdminAccount::KEY_PASSWORD => '1234512345q!',
'--' . AdminAccount::KEY_EMAIL => '[email protected]',
'--' . AdminAccount::KEY_FIRST_NAME => 'John',
'--' . AdminAccount::KEY_LAST_NAME => 'Doe'
];
$data = [
AdminAccount::KEY_USER => 'user',
AdminAccount::KEY_PASSWORD => '123123q',
AdminAccount::KEY_PASSWORD => '1234512345q!',
AdminAccount::KEY_EMAIL => '[email protected]',
AdminAccount::KEY_FIRST_NAME => 'John',
AdminAccount::KEY_LAST_NAME => 'Doe',
Expand All @@ -93,7 +93,7 @@ public function testInteraction(): void

$this->questionHelperMock
->method('ask')
->willReturnOnConsecutiveCalls('admin', 'Password123', '[email protected]', 'John', 'Doe');
->willReturnOnConsecutiveCalls('admin', 'Password1234', '[email protected]', 'John', 'Doe');

// We override the standard helper with our mock
$this->command->getHelperSet()->set($this->questionHelperMock, 'question');
Expand All @@ -102,7 +102,7 @@ public function testInteraction(): void

$expectedData = [
'admin-user' => 'admin',
'admin-password' => 'Password123',
'admin-password' => 'Password1234',
'admin-email' => '[email protected]',
'admin-firstname' => 'John',
'admin-lastname' => 'Doe',
Expand Down Expand Up @@ -189,38 +189,38 @@ public static function validateDataProvider(): array
{
return [
[
[null, 'Doe', 'admin', '[email protected]', '123123q', '123123q'],
[null, 'Doe', 'admin', '[email protected]', '1234512345q!', '1234512345q!'],
['"First Name" is required. Enter and try again.']
],
[
['John', null, null, '[email protected]', '123123q', '123123q'],
['John', null, null, '[email protected]', '1234512345q!', '1234512345q!'],
['"User Name" is required. Enter and try again.', '"Last Name" is required. Enter and try again.'],
],
[['John', 'Doe', 'admin', null, '123123q', '123123q'], ['Please enter a valid email.']],
[['John', 'Doe', 'admin', null, '1234512345q!', '1234512345q!'], ['Please enter a valid email.']],
[
['John', 'Doe', 'admin', 'test', '123123q', '123123q'],
['John', 'Doe', 'admin', 'test', '1234512345q!', '1234512345q!'],
["'test' is not a valid email address in the basic format local-part@hostname"]
],
[
['John', 'Doe', 'admin', '[email protected]', '', ''],
[
'Password is required field.',
'Your password must be at least 7 characters.',
'Your password must be at least 12 characters.',
'Your password must include both numeric and alphabetic characters.'
]
],
[
['John', 'Doe', 'admin', '[email protected]', '123123', '123123'],
[
'Your password must be at least 7 characters.',
'Your password must be at least 12 characters.',
'Your password must include both numeric and alphabetic characters.'
]
],
[
['John', 'Doe', 'admin', '[email protected]', '1231231', '1231231'],
['John', 'Doe', 'admin', '[email protected]', '123123123123', '123123123123'],
['Your password must include both numeric and alphabetic characters.']
],
[['John', 'Doe', 'admin', '[email protected]', '123123q', '123123q'], []],
[['John', 'Doe', 'admin', '[email protected]', '1234512345q!', '1234512345q!'], []],
];
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2015 Adobe
* All Rights Reserved.
*/
declare(strict_types=1);

Expand Down Expand Up @@ -175,7 +175,7 @@ protected function setUp(): void
public function testExecute()
{
$this->input['--' . AdminAccount::KEY_USER] = 'user';
$this->input['--' . AdminAccount::KEY_PASSWORD] = '123123q';
$this->input['--' . AdminAccount::KEY_PASSWORD] = '1234512345q!';
$this->input['--' . AdminAccount::KEY_EMAIL] = '[email protected]';
$this->input['--' . AdminAccount::KEY_FIRST_NAME] = 'John';
$this->input['--' . AdminAccount::KEY_LAST_NAME] = 'Doe';
Expand Down
6 changes: 3 additions & 3 deletions setup/src/Magento/Setup/Test/Unit/Model/AdminAccountTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2015 Adobe
* All Rights Reserved.
*/
declare(strict_types=1);

Expand Down Expand Up @@ -57,7 +57,7 @@ protected function setUp(): void
AdminAccount::KEY_FIRST_NAME => 'John',
AdminAccount::KEY_LAST_NAME => 'Doe',
AdminAccount::KEY_EMAIL => '[email protected]',
AdminAccount::KEY_PASSWORD => '123123q',
AdminAccount::KEY_PASSWORD => '1234512345q!',
AdminAccount::KEY_USER => 'admin',
AdminAccount::KEY_PREFIX => 'pre_'
];
Expand Down