Skip to content

Commit 9e29920

Browse files
authored
Merge branch '1.0.0-develop' into fix-127
2 parents d95f093 + f3b966e commit 9e29920

File tree

306 files changed

+26609
-6
lines changed

Some content is hidden

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

306 files changed

+26609
-6
lines changed

Securitytxt/Model/Config/Signature.php

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,40 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
declare(strict_types=1);
87

98
namespace Magento\Securitytxt\Model\Config;
109

1110
use Magento\Config\Model\Config\CommentInterface;
11+
use Magento\Framework\Escaper;
1212

1313
/**
1414
* Signature field description
1515
*/
1616
class Signature implements CommentInterface
1717
{
18+
/**
19+
* @var string
20+
*/
21+
private $instructionLink;
22+
23+
/**
24+
* @var Escaper
25+
*/
26+
private $escaper;
27+
28+
/**
29+
* @param Escaper $escaper
30+
* @param string $instructionLink
31+
*/
32+
public function __construct(
33+
Escaper $escaper,
34+
string $instructionLink = ''
35+
) {
36+
$this->escaper = $escaper;
37+
$this->instructionLink = $instructionLink;
38+
}
39+
1840
/**
1941
* Get comment for signature field of security txt extension.
2042
*
@@ -24,8 +46,13 @@ class Signature implements CommentInterface
2446
*/
2547
public function getCommentText($elementValue): string
2648
{
27-
return "<a href='https://devdocs.magento.com/' target='_blank'>
28-
Read instructions on how to generate signature
29-
</a>";
49+
if ($this->instructionLink === '') {
50+
return '';
51+
}
52+
return sprintf(
53+
"<a href='%s' target='_blank'>%s</a>",
54+
$this->escaper->escapeUrl($this->instructionLink),
55+
__('Read instructions on how to generate signature')
56+
);
3057
}
3158
}

Securitytxt/etc/di.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,11 @@
2222
<argument name="resultPageFactory" xsi:type="object">securitytxtResultPageFactory</argument>
2323
</arguments>
2424
</type>
25-
</config>
25+
<type name="Magento\Securitytxt\Model\Config\Signature">
26+
<arguments>
27+
<argument name="instructionLink" xsi:type="string">
28+
https://github.com/magento/security-package/blob/1.0-develop/Securitytxt/README.md
29+
</argument>
30+
</arguments>
31+
</type>
32+
</config>

Securitytxt/i18n/en_US.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ Hiring,Hiring
2626
"Example: https://example.com/jobs.html","Example: https://example.com/jobs.html"
2727
Policy,Policy
2828
"Example: https://example.com/security-policy.html","Example: https://example.com/security-policy.html"
29-
Signature,Signature
29+
Signature,Signature
30+
"Read instructions on how to generate signature","Read instructions on how to generate signature"
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+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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;
9+
10+
use Magento\Framework\Api\SearchCriteriaInterface;
11+
use Magento\Framework\Api\SearchResultsInterface;
12+
use Magento\TwoFactorAuth\Api\Data\CountryInterface;
13+
use Magento\TwoFactorAuth\Api\Data\CountrySearchResultsInterface;
14+
15+
/**
16+
* Countries repository
17+
*
18+
* @SuppressWarnings(PHPMD.ShortVariable)
19+
*/
20+
interface CountryRepositoryInterface
21+
{
22+
/**
23+
* Save object
24+
*
25+
* @param CountryInterface $object
26+
* @return CountryInterface
27+
*/
28+
public function save(CountryInterface $object): CountryInterface;
29+
30+
/**
31+
* Get object by id
32+
*
33+
* @param int $id
34+
* @return CountryInterface
35+
*/
36+
public function getById(int $id): CountryInterface;
37+
38+
/**
39+
* Get by Code value
40+
*
41+
* @param string $value
42+
* @return CountryInterface
43+
*/
44+
public function getByCode(string $value): CountryInterface;
45+
46+
/**
47+
* Delete object
48+
*
49+
* @param CountryInterface $object
50+
* @return void
51+
*/
52+
public function delete(CountryInterface $object): void;
53+
54+
/**
55+
* Get a list of object
56+
*
57+
* @param SearchCriteriaInterface $searchCriteria
58+
* @return CountrySearchResultsInterface
59+
*/
60+
public function getList(SearchCriteriaInterface $searchCriteria): SearchResultsInterface;
61+
}
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+
}

0 commit comments

Comments
 (0)