Skip to content

Commit d5c472e

Browse files
author
Oleksandr Gorkun
committed
MC-22950: Enable 2FA by default for Admins
1 parent 03665ef commit d5c472e

File tree

113 files changed

+3956
-519
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+3956
-519
lines changed

TwoFactorAuth/Api/Data/TrustedInterface.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
/**
1313
* Trusted platform entity interface
14+
*
15+
* @deprecated Trusted Devices functionality was removed.
1416
*/
1517
interface TrustedInterface extends ExtensibleDataInterface
1618
{
@@ -51,6 +53,7 @@ interface TrustedInterface extends ExtensibleDataInterface
5153

5254
/**
5355
* Get value for tfa_trusted_id
56+
*
5457
* @return int
5558
*/
5659
public function getId(): int;

TwoFactorAuth/Api/Data/TrustedSearchResultsInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
/**
1313
* Trusted devices search results interface
14+
*
15+
* @deprecated Trusted Devices functionality was removed.
1416
*/
1517
interface TrustedSearchResultsInterface extends SearchResultsInterface
1618
{

TwoFactorAuth/Api/EngineInterface.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@ interface EngineInterface
1717
{
1818
/**
1919
* Return true if this provider has been enabled by admin
20+
*
2021
* @return bool
2122
*/
2223
public function isEnabled(): bool;
2324

2425
/**
2526
* Return true if this provider allows trusted devices
27+
*
2628
* @return bool
29+
* @deprecated Trusted Devices functionality is deprecated.
2730
*/
2831
public function isTrustedDevicesAllowed(): bool;
2932

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\TwoFactorAuth\Api\Exception;
10+
11+
/**
12+
* Occurs when failed to notify a user.
13+
*/
14+
interface NotificationExceptionInterface extends \Throwable
15+
{
16+
17+
}

TwoFactorAuth/Api/ProviderInterface.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ interface ProviderInterface
1414
{
1515
/**
1616
* Return true if this provider has been enabled by admin
17+
*
1718
* @return bool
1819
*/
1920
public function isEnabled(): bool;
@@ -50,7 +51,9 @@ public function isResetAllowed(): bool;
5051

5152
/**
5253
* Return true if this provider allows trusted devices
54+
*
5355
* @return bool
56+
* @deprecated Trusted Devices functionality was removed.
5457
*/
5558
public function isTrustedDevicesAllowed(): bool;
5659

TwoFactorAuth/Api/TfaInterface.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010
use Magento\TwoFactorAuth\Api\Data\TrustedInterface;
1111

1212
/**
13-
* 2FA interface
13+
* 2FA configuration manager.
1414
*/
1515
interface TfaInterface
1616
{
1717
/**
1818
* Enabled field
19+
*
20+
* @deprecated 2FA cannot be disabled anymore.
1921
*/
2022
public const XML_PATH_ENABLED = 'twofactorauth/general/enabled';
2123

@@ -26,6 +28,7 @@ interface TfaInterface
2628

2729
/**
2830
* Return true if 2FA is enabled
31+
*
2932
* @return bool
3033
*/
3134
public function isEnabled(): bool;
@@ -73,8 +76,10 @@ public function getAllEnabledProviders(): array;
7376

7477
/**
7578
* Return a list of trusted devices for given user id
79+
*
7680
* @param int $userId
7781
* @return \Magento\TwoFactorAuth\Api\ProviderInterface[]
82+
* @deprecated Trusted Devices functionality was removed.
7883
*/
7984
public function getTrustedDevices(int $userId): array;
8085

TwoFactorAuth/Api/TrustedManagerInterface.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
/**
1414
* Trusted management service
15+
*
16+
* @deprecated Trusted Device functionality was removed.
1517
*/
1618
interface TrustedManagerInterface
1719
{
@@ -22,29 +24,37 @@ interface TrustedManagerInterface
2224

2325
/**
2426
* Rotate secret trust token
27+
*
2528
* @return void
29+
* @deprecated Trusted Device functionality was removed.
2630
*/
2731
public function rotateTrustedDeviceToken(): void;
2832

2933
/**
3034
* Return true if device is trusted
35+
*
3136
* @return bool
37+
* @deprecated Trusted Device functionality was removed.
3238
*/
3339
public function isTrustedDevice(): bool;
3440

3541
/**
3642
* Revoke trusted device
43+
*
3744
* @param int $tokenId
3845
* @return void
3946
* @throws NoSuchEntityException
47+
* @deprecated Trusted Device functionality was removed.
4048
*/
4149
public function revokeTrustedDevice(int $tokenId): void;
4250

4351
/**
4452
* Trust a device
53+
*
4554
* @param string $providerCode
4655
* @param RequestInterface $request
4756
* @return bool
57+
* @deprecated Trusted Device functionality was removed.
4858
*/
4959
public function handleTrustDeviceRequest(string $providerCode, RequestInterface $request): bool;
5060
}

TwoFactorAuth/Api/TrustedRepositoryInterface.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,52 @@
1414
/**
1515
* Trusted repository
1616
* @SuppressWarnings(PHPMD.ShortVariable)
17+
* @deprecated Trusted Devices functionality was removed.
1718
*/
1819
interface TrustedRepositoryInterface
1920
{
2021
/**
2122
* Save object
23+
*
2224
* @param TrustedInterface $object
2325
* @return TrustedInterface
26+
* @deprecated Trusted Devices functionality was removed.
2427
*/
2528
public function save(TrustedInterface $object): TrustedInterface;
2629

2730
/**
2831
* Get object by id
32+
*
2933
* @param int $id
3034
* @return TrustedInterface
35+
* @deprecated Trusted Devices functionality was removed.
3136
*/
3237
public function getById(int $id): TrustedInterface;
3338

3439
/**
3540
* Get by UserId value
41+
*
3642
* @param int $value
3743
* @return TrustedInterface
44+
* @deprecated Trusted Devices functionality was removed.
3845
*/
3946
public function getByUserId(int $value): TrustedInterface;
4047

4148
/**
4249
* Delete object
50+
*
4351
* @param TrustedInterface $object
52+
* @return void
53+
* @deprecated Trusted Devices functionality was removed.
4454
*/
4555
public function delete(TrustedInterface $object): void;
4656

4757
/**
4858
* Get a list of object
59+
*
4960
* @param SearchCriteriaInterface $searchCriteria
5061
* @return SearchResultsInterface
62+
* @deprecated Trusted Devices functionality was removed.
5163
*/
5264
public function getList(SearchCriteriaInterface $searchCriteria): SearchResultsInterface;
5365
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\TwoFactorAuth\Api;
10+
11+
use Magento\Framework\Exception\AuthorizationException;
12+
use Magento\User\Model\User;
13+
use Magento\TwoFactorAuth\Api\Exception\NotificationExceptionInterface;
14+
15+
/**
16+
* Manages configuration requests for users.
17+
*/
18+
interface UserConfigRequestManagerInterface
19+
{
20+
/**
21+
* Is user required to configure 2FA?
22+
*
23+
* @param int $userId
24+
* @return bool
25+
*/
26+
public function isConfigurationRequiredFor(int $userId): bool;
27+
28+
/**
29+
* Request configurations from the user.
30+
*
31+
* @param User $user
32+
* @return void
33+
* @throws AuthorizationException When user is not allowed to configure 2FA.
34+
* @throws NotificationExceptionInterface When failed to send the message.
35+
*/
36+
public function sendConfigRequestTo(User $user): void;
37+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\TwoFactorAuth\Api;
10+
11+
/**
12+
* Manages tokens issued to users to authorize them to configure 2FA.
13+
*/
14+
interface UserConfigTokenManagerInterface
15+
{
16+
/**
17+
* Issue token for the user.
18+
*
19+
* @param int $userId
20+
* @return string
21+
*/
22+
public function issueFor(int $userId): string;
23+
24+
/**
25+
* Is given token valid for given user?
26+
*
27+
* @param int $userId
28+
* @param string $token
29+
* @return bool
30+
*/
31+
public function isValidFor(int $userId, string $token): bool;
32+
}

0 commit comments

Comments
 (0)