Skip to content

Commit 0a66936

Browse files
authored
Merge pull request #227 from magento-borg/MC-30537
2fa Automation and WebApi
2 parents 631da09 + 36622ce commit 0a66936

File tree

224 files changed

+7964
-253
lines changed

Some content is hidden

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

224 files changed

+7964
-253
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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\Integration\Api\AdminTokenServiceInterface as OriginalTokenServiceInterface;
12+
13+
/**
14+
* Obtain basic information about the user required to setup or use 2fa
15+
*/
16+
interface AdminTokenServiceInterface extends OriginalTokenServiceInterface
17+
{
18+
19+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
* Represents the authy provider authentication
13+
*/
14+
interface AuthyAuthenticateInterface
15+
{
16+
/**
17+
* Get an admin token using authy 2fa
18+
*
19+
* @param string $username
20+
* @param string $password
21+
* @param string $otp
22+
* @return string $otp
23+
*/
24+
public function createAdminAccessTokenWithCredentials(
25+
string $username,
26+
string $password,
27+
string $otp
28+
): string;
29+
30+
/**
31+
* Send a one time password to a device using authy
32+
*
33+
* @param string $username
34+
* @param string $password
35+
* @param string $via
36+
* @return void
37+
*/
38+
public function sendToken(
39+
string $username,
40+
string $password,
41+
string $via
42+
): void;
43+
44+
/**
45+
* Authenticate using the present one touch response and get an admin token
46+
*
47+
* @param string $username
48+
* @param string $password
49+
* @return string
50+
*/
51+
public function creatAdminAccessTokenWithOneTouch(
52+
string $username,
53+
string $password
54+
): string;
55+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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\TwoFactorAuth\Api\Data\AuthyDeviceInterface;
12+
use Magento\TwoFactorAuth\Api\Data\AuthyRegistrationPromptResponseInterface as ResponseInterface;
13+
14+
/**
15+
* Represents the authy provider
16+
*/
17+
interface AuthyConfigureInterface
18+
{
19+
/**
20+
* Get the information required to configure google
21+
*
22+
* @param string $tfaToken
23+
* @param AuthyDeviceInterface $deviceData
24+
* @return \Magento\TwoFactorAuth\Api\Data\AuthyRegistrationPromptResponseInterface
25+
*/
26+
public function sendDeviceRegistrationPrompt(
27+
string $tfaToken,
28+
AuthyDeviceInterface $deviceData
29+
): ResponseInterface;
30+
31+
/**
32+
* Activate the provider and get an admin token
33+
*
34+
* @param string $tfaToken
35+
* @param string $otp
36+
* @return void
37+
*/
38+
public function activate(string $tfaToken, string $otp): void;
39+
}

TwoFactorAuth/Api/CountryRepositoryInterface.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,46 @@
1414

1515
/**
1616
* Countries repository
17+
*
1718
* @SuppressWarnings(PHPMD.ShortVariable)
1819
*/
1920
interface CountryRepositoryInterface
2021
{
2122
/**
2223
* Save object
24+
*
2325
* @param CountryInterface $object
2426
* @return CountryInterface
2527
*/
2628
public function save(CountryInterface $object): CountryInterface;
2729

2830
/**
2931
* Get object by id
32+
*
3033
* @param int $id
3134
* @return CountryInterface
3235
*/
3336
public function getById(int $id): CountryInterface;
3437

3538
/**
3639
* Get by Code value
40+
*
3741
* @param string $value
3842
* @return CountryInterface
3943
*/
4044
public function getByCode(string $value): CountryInterface;
4145

4246
/**
4347
* Delete object
48+
*
4449
* @param CountryInterface $object
4550
* @return void
4651
*/
4752
public function delete(CountryInterface $object): void;
4853

4954
/**
5055
* Get a list of object
56+
*
5157
* @param SearchCriteriaInterface $searchCriteria
5258
* @return CountrySearchResultsInterface
5359
*/
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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\Data;
10+
11+
use Magento\Framework\Api\ExtensibleDataInterface;
12+
13+
/**
14+
* Represents the response to the new admin token response
15+
*/
16+
interface AdminTokenResponseInterface extends ExtensibleDataInterface
17+
{
18+
/**
19+
* User id field
20+
*/
21+
const USER_ID = 'user_id';
22+
23+
/**
24+
* Message field
25+
*/
26+
const MESSAGE = 'message';
27+
28+
/**
29+
* Providers field
30+
*/
31+
const ACTIVE_PROVIDERS = 'active_providers';
32+
33+
/**
34+
* Get the id of the authenticated user
35+
*
36+
* @return string
37+
*/
38+
public function getUserId(): string;
39+
40+
/**
41+
* Set the id of the authenticated user
42+
*
43+
* @param int $value
44+
* @return void
45+
*/
46+
public function setUserId(int $value): void;
47+
48+
/**
49+
* Get the message from the response
50+
*
51+
* @return string
52+
*/
53+
public function getMessage(): string;
54+
55+
/**
56+
* Set the id of the message
57+
*
58+
* @param string $value
59+
* @return void
60+
*/
61+
public function setMessage(string $value): void;
62+
63+
/**
64+
* Get the providers
65+
*
66+
* @return \Magento\TwoFactorAuth\Api\ProviderInterface[]
67+
*/
68+
public function getActiveProviders(): array;
69+
70+
/**
71+
* Set the providers
72+
*
73+
* @param \Magento\TwoFactorAuth\Api\ProviderInterface[] $value
74+
* @return void
75+
*/
76+
public function setActiveProviders(array $value): void;
77+
78+
/**
79+
* Retrieve existing extension attributes object or create a new one
80+
*
81+
* Used fully qualified namespaces in annotations for proper work of extension interface/class code generation
82+
*
83+
* @return \Magento\TwoFactorAuth\Api\Data\AdminTokenResponseExtensionInterface|null
84+
*/
85+
public function getExtensionAttributes(): ?AdminTokenResponseExtensionInterface;
86+
87+
/**
88+
* Set an extension attributes object
89+
*
90+
* @param \Magento\TwoFactorAuth\Api\Data\AdminTokenResponseExtensionInterface $extensionAttributes
91+
* @return void
92+
*/
93+
public function setExtensionAttributes(
94+
AdminTokenResponseExtensionInterface $extensionAttributes
95+
): void;
96+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\TwoFactorAuth\Api\Data;
9+
10+
use Magento\Framework\Api\ExtensibleDataInterface;
11+
12+
/**
13+
* Authy device data interface
14+
*/
15+
interface AuthyDeviceInterface extends ExtensibleDataInterface
16+
{
17+
/**
18+
* Country field
19+
*/
20+
public const COUNTRY = 'country';
21+
22+
/**
23+
* Phone number field
24+
*/
25+
public const PHONE = 'phone_number';
26+
27+
/**
28+
* Method of authentication field
29+
*/
30+
public const METHOD = 'method';
31+
32+
/**
33+
* Authenticate via sms
34+
*/
35+
public const METHOD_SMS = 'sms';
36+
37+
/**
38+
* Authenticate via phone call
39+
*/
40+
public const METHOD_CALL = 'call';
41+
42+
/**
43+
* Get the country
44+
*
45+
* @return string
46+
*/
47+
public function getCountry(): string;
48+
49+
/**
50+
* Set the country
51+
*
52+
* @param string $value
53+
* @return void
54+
*/
55+
public function setCountry(string $value): void;
56+
57+
/**
58+
* Get the phone number
59+
*
60+
* @return string
61+
*/
62+
public function getPhoneNumber(): string;
63+
64+
/**
65+
* Set the phone number
66+
*
67+
* @param string $value
68+
* @return void
69+
*/
70+
public function setPhoneNumber(string $value): void;
71+
72+
/**
73+
* Get the method to authenticate with
74+
*
75+
* @return string
76+
*/
77+
public function getMethod(): string;
78+
79+
/**
80+
* Set the method to authenticate with
81+
*
82+
* @param string $value
83+
* @return void
84+
*/
85+
public function setMethod(string $value): void;
86+
87+
/**
88+
* Retrieve existing extension attributes object or create a new one
89+
*
90+
* Used fully qualified namespaces in annotations for proper work of extension interface/class code generation
91+
*
92+
* @return \Magento\TwoFactorAuth\Api\Data\AuthyDeviceExtensionInterface|null
93+
*/
94+
public function getExtensionAttributes(): ?AuthyDeviceExtensionInterface;
95+
96+
/**
97+
* Set an extension attributes object
98+
*
99+
* @param \Magento\TwoFactorAuth\Api\Data\AuthyDeviceExtensionInterface $extensionAttributes
100+
* @return void
101+
*/
102+
public function setExtensionAttributes(
103+
AuthyDeviceExtensionInterface $extensionAttributes
104+
): void;
105+
}

0 commit comments

Comments
 (0)