Skip to content

Commit e3fdc9b

Browse files
committed
#171: Default(pre-filled) value should be added to the "Policy" in Admin Panel for Security.txt settings
2 parents 26c6d67 + 8aad7b0 commit e3fdc9b

File tree

306 files changed

+26631
-141
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

+26631
-141
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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\Securitytxt\Model\Config\Backend;
9+
10+
use Magento\Framework\Validator\Exception as ValidatorException;
11+
use Magento\Framework\App\Config\Value;
12+
13+
/**
14+
* Security.txt secure URL validator.
15+
*/
16+
class SecureUrl extends Value
17+
{
18+
/**
19+
* Validate security.txt URL field before saving it.
20+
*
21+
* @return $this
22+
* @throws ValidatorException
23+
*/
24+
public function beforeSave()
25+
{
26+
$url = $this->getValue();
27+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
28+
$isValid = parse_url($url, PHP_URL_SCHEME) === 'https';
29+
if (!$isValid && $url !== '') {
30+
throw new ValidatorException(
31+
__('URL should be in correct format and must start with HTTPS.')
32+
);
33+
}
34+
return $this;
35+
}
36+
}

Securitytxt/Model/Config/Backend/Validate.php

Lines changed: 0 additions & 126 deletions
This file was deleted.

Securitytxt/etc/adminhtml/system.xml

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,80 +12,90 @@
1212
<label>Security</label>
1313
</tab>
1414
<section id="magento_securitytxt_securitytxt" translate="label" type="text" sortOrder="520" showInDefault="1"
15-
showInWebsite="1" showInStore="1">
15+
showInWebsite="1" showInStore="0">
1616
<class>separator-top</class>
1717
<label>Security.txt</label>
1818
<tab>security</tab>
1919
<resource>Magento_Securitytxt::config</resource>
2020
<group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1"
21-
showInStore="1">
21+
showInStore="0">
2222
<label>General</label>
2323
<field id="enabled" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1"
24-
showInStore="1">
24+
showInStore="0">
2525
<label>Enable</label>
2626
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
2727
</field>
2828
</group>
2929
<group id="contact_information" translate="label" type="text" sortOrder="10" showInDefault="1"
3030
showInWebsite="1"
31-
showInStore="1">
31+
showInStore="0">
3232
<label>Contact Information</label>
3333
<field id="email" translate="label comment" type="text" sortOrder="20" showInDefault="1"
34-
showInWebsite="1" showInStore="1">
34+
showInWebsite="1" showInStore="0">
3535
<label>Email</label>
3636
<validate>validate-email</validate>
37-
<backend_model>Magento\Securitytxt\Model\Config\Backend\Validate</backend_model>
3837
</field>
3938
<field id="phone" translate="label comment" type="text" sortOrder="20" showInDefault="1"
40-
showInWebsite="1" showInStore="1">
39+
showInWebsite="1" showInStore="0">
4140
<label>Phone</label>
4241
</field>
4342
<field id="contact_page" translate="label comment" type="text" sortOrder="20" showInDefault="1"
44-
showInWebsite="1" showInStore="1">
43+
showInWebsite="1" showInStore="0">
4544
<label>Contact Page</label>
4645
<validate>validate-url validate-no-html-tags</validate>
46+
<backend_model>Magento\Securitytxt\Model\Config\Backend\SecureUrl</backend_model>
4747
<comment>Example: https://example.com/security-contact.html</comment>
4848
</field>
49+
<depends>
50+
<field id="magento_securitytxt_securitytxt/general/enabled">1</field>
51+
</depends>
4952
</group>
5053
<group id="other_information" translate="label" type="text" sortOrder="10" showInDefault="1"
5154
showInWebsite="1"
52-
showInStore="1">
55+
showInStore="0">
5356
<label>Other Information</label>
5457
<field id="encryption" translate="label comment" type="text" sortOrder="40" showInDefault="1"
55-
showInWebsite="1" showInStore="1">
58+
showInWebsite="1" showInStore="0" >
5659
<label>Encryption</label>
5760
<validate>validate-url validate-no-html-tags</validate>
5861
<comment>Example: https://example.com/pgp-key.txt</comment>
62+
<backend_model>Magento\Securitytxt\Model\Config\Backend\SecureUrl</backend_model>
5963
</field>
6064
<field id="acknowledgements" translate="label comment" type="text" sortOrder="50" showInDefault="1"
61-
showInWebsite="1" showInStore="1">
65+
showInWebsite="1" showInStore="0">
6266
<label>Acknowledgements</label>
6367
<validate>validate-url validate-no-html-tags</validate>
6468
<comment>Example: https://example.com/hall-of-fame.html</comment>
69+
<backend_model>Magento\Securitytxt\Model\Config\Backend\SecureUrl</backend_model>
6570
</field>
6671
<field id="preferred_languages" translate="label comment" type="text" sortOrder="50" showInDefault="1"
67-
showInWebsite="1" showInStore="1">
72+
showInWebsite="1" showInStore="0">
6873
<label>Preferred-Languages</label>
6974
<validate>validate-text validate-no-html-tags</validate>
7075
<comment>Example: en, es, hi, de, fr</comment>
7176
</field>
7277
<field id="hiring" translate="label comment" type="text" sortOrder="50" showInDefault="1"
73-
showInWebsite="1" showInStore="1">
78+
showInWebsite="1" showInStore="0">
7479
<label>Hiring</label>
7580
<validate>validate-url validate-no-html-tags</validate>
7681
<comment>Example: https://example.com/jobs.html</comment>
82+
<backend_model>Magento\Securitytxt\Model\Config\Backend\SecureUrl</backend_model>
7783
</field>
7884
<field id="policy" translate="label comment" type="text" sortOrder="60" showInDefault="1"
79-
showInWebsite="1" showInStore="1">
85+
showInWebsite="1" showInStore="0">
8086
<label>Policy</label>
8187
<validate>validate-url validate-no-html-tags</validate>
88+
<backend_model>Magento\Securitytxt\Model\Config\Backend\SecureUrl</backend_model>
8289
</field>
8390
<field id="signature_text" translate="label comment" type="textarea" sortOrder="80" showInDefault="1"
84-
showInWebsite="1" showInStore="1">
91+
showInWebsite="1" showInStore="0">
8592
<label>Signature</label>
8693
<validate>validate-no-html-tags</validate>
8794
<comment model="Magento\Securitytxt\Model\Config\Signature"/>
8895
</field>
96+
<depends>
97+
<field id="magento_securitytxt_securitytxt/general/enabled">1</field>
98+
</depends>
8999
</group>
90100
</section>
91101
</system>
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+
}

0 commit comments

Comments
 (0)