Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

2FA Updates #7389

Closed
wants to merge 7 commits into from
Closed
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
86 changes: 63 additions & 23 deletions src/guides/v2.3/security/two-factor-authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,25 @@ functional_areas:
- Configuration
---

Magento Two-Factor Authentication (2FA) improves security by requiring two-step authentication to access the Magento Admin for all users and from all devices. The extension supports multiple authenticators including Google Authenticator, Authy, Duo, and U2F keys. 2FA is enabled by default for all Magento Admin users, and cannot be disabled from the Magento Admin or from the command line. 2FA is not available for storefront customer accounts.
Magento Two-Factor Authentication (2FA) improves security by requiring two-step authentication to access the Magento _Admin_ for all users and from all devices. The extension supports multiple authenticators including Google Authenticator, Authy, Duo, and U2F keys. 2FA is enabled by default for all Magento _Admin_ users, and cannot be disabled from the Magento _Admin_ or from the command line. 2FA is not available for storefront customer accounts.

Two-Factor Authentication gives you the ability to:

- Manage and configure authenticator settings globally or per user account.
- Reset authenticators for users.

{:.bs-callout-info}
**Magento Community Contribution** - Magento thanks [Riccardo Tempesta](https://twitter.com/rictempesta) of [MageSpecialist](https://partners.magento.com/portal/details/partner/index/id/129/) for contributing these features as part of the Magento Community Engineering program.
**Magento Community Contribution** - Magento thanks [Riccardo Tempesta][1] of [MageSpecialist][2] for contributing these features as part of the Magento Community Engineering program.

## Magento Admin Workflows

Magento has new workflows for Admin users, including:
Magento has new workflows for _Admin_ users, including:

- The ability to configure the 2FA provider globally or individually.
- Admin users must set their own personal 2FA at first login.
- Confirmation email is sent at first login to verify identity.
- The "Trust this device" option has been removed.
- _Admin_ users must set their own personal 2FA at first login, and receive a confirmation email to verify their identity.
- The `Trust this device` option has been removed.

For more information, see [Two-Factor Authentication](https://docs.magento.com/m2/ee/user_guide/stores/security-two-factor-authentication.html) in the _Magento User Guide_.
For more information, see [Two-Factor Authentication][3] in the _Magento User Guide_.

## Headless Magento

Expand All @@ -34,12 +33,11 @@ The 2FA provider for Magento Headless can be selected with the `config:set` comm

Two-Factor Authentication is implemented for Magento Web APIs with the following changes:

- `AdminTokenServiceInterface::createAdminAccessToken()` throws an exception when the Admin user doesn’t have personal 2FA configured, and also indicates that the confirmationh email has been sent.
- `AdminTokenServiceInterface::createAdminAccessToken()` throws an exception when the _Admin_ user doesn’t have personal 2FA configured, and also indicates that the confirmationh email has been sent.
- `AdminTokenServiceInterface::createAdminAccessToken()` throws an exception that indicates which provider is configured for the user and suggests a provider-specific login endpoint.
- 2FA provider-specific endpoints allow each Admin user to configure a personal 2FA.
- 2FA provider-specific endpoints provide tokens for username, password, and 2FA code.
- 2FA provider-specific endpoints allow each _Admin_ user to configure a personal 2FA and provides tokens for username, password, and 2FA code.

<div class="mxgraph" style="max-width:100%;border:1px solid transparent;" data-mxgraph="{&quot;highlight&quot;:&quot;#808080&quot;,&quot;nav&quot;:true,&quot;resize&quot;:true,&quot;toolbar&quot;:&quot;zoom layers lightbox&quot;,&quot;edit&quot;:&quot;_blank&quot;,&quot;xml&quot;:&quot;&lt;mxfile host=\&quot;app.diagrams.net\&quot; modified=\&quot;2020-05-13T14:34:26.218Z\&quot; agent=\&quot;5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36\&quot; etag=\&quot;1_9dYxgYtKkJoeiHUXCv\&quot; version=\&quot;13.1.1\&quot; type=\&quot;device\&quot;&gt;&lt;diagram id=\&quot;3_r6wyLoFRS8J-phUPnO\&quot; name=\&quot;Page-1\&quot;&gt;7Vtbd5s4EP41Oad9SA4gLuYxcUK2e9put9ndNk97sJFtNYC8Mo7t/vodgWQQwsHxYuz2rB9sGEDAN99cNBpfoGGyvmfhfPaBRji+sIxofYFuLyzLMg0ffrhkU0h82ywEU0aiQlQRPJDvWAgNIV2SCC+UEzNK44zMVeGYpikeZ4osZ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LtAxaR+/s6ML66stC0sdWXXwTeEfr22/K2JV+gB0dZ4u8BZ+vLZuD+bq1k+PAUYpe9i+YN2Bcf3oH30FMV7u7NeqmuctUu16mPltrdb2au9cLdqaHGtz96wkHu+VfLYvoXf5hFd39Cw==&lt;/diagram&gt;&lt;/mxfile&gt;&quot;}"></div>
<div class="mxgraph" style="max-width:100%;border:1px solid transparent;" data-mxgraph="{&quot;highlight&quot;:&quot;#4D4D4D&quot;,&quot;nav&quot;:true,&quot;resize&quot;:true,&quot;toolbar&quot;:&quot;zoom layers lightbox&quot;,&quot;edit&quot;:&quot;_blank&quot;,&quot;xml&quot;:&quot;&lt;mxfile host=\&quot;app.diagrams.net\&quot; modified=\&quot;2020-06-09T20:54:57.358Z\&quot; agent=\&quot;5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36\&quot; etag=\&quot;lHIFAjyy7UH30SC7NB4z\&quot; version=\&quot;13.2.0\&quot; type=\&quot;device\&quot;&gt;&lt;diagram id=\&quot;3_r6wyLoFRS8J-phUPnO\&quot; name=\&quot;Page-1\&quot;&gt;7VvbcqM4EP2aVM08TAoQF/OYOCGbrblkJ9nNZF+2sJFtTTDyyji25+u3BcIgBIYkmHim1g+2aaCB00fdrVZzgobzzRXzF7NPNMDhiaEFmxN0cWIYjqvDNxdsU4FpuKlgykiQivRccEt+YCHUhHRFAryUDowpDWOykIVjGkV4HEsynzG6lg+b0FC+6sKfYkVwO/ZDVXpPgniWSl1Ny+W/YTKdZVe2sz1zPztYCJYzP6DrgghdnqAhozRO/9HRd/4Ahhb6I8AwOS49MwMqP2u+GeIQcPbSTfgjzpb2aqT8rAxHcfGmvJoTzn74jvt1+c9m8O3Re/xM8eRx/sFJtTz54UqAc4PZkkY+P9Pwzk64UjuEC5yPGPyb8n9glwmZrhgGzZ4AIt5m6LIZnY9WYKLz9YzE+Hbhj/meNVAJZLN4znHQ4a/6AOKZnjCL8aYg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HMo2+hoDgVZtKzoxXkybObvBqeH5y9Yo8v/AA==&lt;/diagram&gt;&lt;/mxfile&gt;&quot;}"></div>
<script type="text/javascript" src="https://app.diagrams.net/js/viewer.min.js"></script>

## Install 2FA
Expand All @@ -48,7 +46,7 @@ The 2FA extension installs when you install or upgrade to Magento Open Source or

## Configure and manage 2FA

See the Magento Admin User Guide to [configure](https://docs.magento.com/m2/ee/user_guide/stores/security-two-factor-authentication.html) 2FA settings and [manage user authenticators](https://docs.magento.com/m2/ee/user_guide/stores/security-two-factor-authentication-manage.html).
See the _Magento User Guide_ to [configure][4] 2FA settings and [manage user authenticators][5].

Administrators have options to:

Expand All @@ -58,28 +56,56 @@ Administrators have options to:

## Install authenticator

After configuring 2FA for your Magento instance, Magento Admin users must install and configure an authenticator for their personal use. For complete instructions and workflows, see [Using Two-Factor Authentication](https://docs.magento.com/m2/ee/user_guide/stores/security-two-factor-authentication-use.html).
After configuring 2FA for your Magento instance, Magento _Admin_ users must install and configure an authenticator for their personal use. For complete instructions and workflows, see [Using Two-Factor Authentication][6].

### Supported authenticators

| Provider | Authentication Type | `<provider>` |
| : --------- | : --------- | : ------- |
| [Google Authenticator](https://support.google.com/accounts/answer/1066447?co=GENIE.Platform%3DAndroid&hl=en) | Generate and enter code from mobile app Requirements: Enable in Admin | `google`|
| [Authy](https://authy.com/) | SMS, call, token, and one touch <br/>Requirements: Enable in Admin and API keys | `authy` |
| [U2F Keys](https://docs.magento.com/m2/ee/user_guide/stores/security-two-factor-authentication-use.html#u2f-key) | Physical device to authenticate, like [YubiKey](https://www.yubico.com/). <br/>Requirements: Enable in Admin | `u2fkey` |
| [Duo Security](https://duo.com/) | SMS and push notification. <br/>Requirements: Enable in Admin, Integration and Secret keys, API hostname | `duo` |
| [Google Authenticator][7] | Generate and enter code from mobile app. | `google`|
| [Authy][8] | SMS, call, token, and one touch <br/>Requirements: API keys | `authy` |
| [U2F Keys][9] | Physical device to authenticate, like [YubiKey][10]. | `u2fkey` |
| [Duo Security][11] | SMS and push notification. <br/>Requirements: Integration and Secret keys, API hostname | `duo` |

## Magento Functional Testing Framework

MFTF uses Google Authenticator to execute tests with 2FA enabled. The following steps summarize how to configure MFTF with an encoded shared secret. For more information, see [Configuring MFTF for Two-Factor Authentication (2FA)][12].

1. Select Google Authenticator as the 2FA provider:

```bash
bin/magento config:set twofactorauth/general/force_providers google
```

1. Increase the lifetime of the window to 60 seconds to prevent tokens from expiring.

```bash
bin/magento config:set twofactorauth/google/otp_window 60
```

1. Generate a Base32-encoded string for the shared secret value. For example, encoding the string `abcd` with the online [Base32 Encode][13] tool returns the value `MFRGGZDF`. Use the following key to add the encoded value to the MFTF `.credentials` file:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. Generate a Base32-encoded string for the shared secret value. For example, encoding the string `abcd` with the online [Base32 Encode][13] tool returns the value `MFRGGZDF`. Use the following key to add the encoded value to the MFTF `.credentials` file:
1. Generate a Base32-encoded string for the shared secret value. For example, encoding the string `abcd` with the online [Base32 Encode][13] tool returns the value `MFRGGZDF`. Use the following key to add the encoded value to the MFTF `.credentials` file:


```bash
magento/tfa/OTP_SHARED_SECRET=MFRGGZDF
```

1. Use CLI to add the encoded shared secret to Google Authenticator.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. Use CLI to add the encoded shared secret to Google Authenticator.
1. Add the encoded shared secret to Google Authenticator.


```bash
bin/magento security:tfa:google:set-secret admin MFRGGZDF
```

## Troubleshooting

The extension supports command line options to revoke and reset authenticators. Use these commands when you cannot access the Magento Admin.
The extension supports command line options to revoke and reset authenticators. Use these commands when you cannot access the Magento _Admin_.

### Reset authenticator per account

If you need to manually reset a single user configuration, enter the following command. It restarts configuration and 2FA subscription for the user account.

```bash
bin/magento msp:security:tfa:reset <username> <provider>
```
```bash
bin/magento security:tfa:reset <user> <provider>
```

### Advanced emergency steps

Expand All @@ -90,8 +116,22 @@ In your database, you can modify the following tables and values to affect 2FA.

Table: `core_config_data`

- `msp/twofactorauth/force_providers` - Delete this entry to remove forced providers option.
- `twofactorauth/general/force_providers` - Delete this entry to remove forced providers option.

Table: `msp_tfa_user_config`
Table: `tfa_user_config`

- Delete one user row to reset the user's 2FA preference and configuration.

[1]: https://twitter.com/rictempesta
[2]: https://partners.magento.com/portal/details/partner/index/id/129/
[3]: https://docs.magento.com/m2/ee/user_guide/stores/security-two-factor-authentication.html
[4]: https://docs.magento.com/m2/ee/user_guide/stores/security-two-factor-authentication.html
[5]: https://docs.magento.com/m2/ee/user_guide/stores/security-two-factor-authentication-manage.html
[6]: https://docs.magento.com/m2/ee/user_guide/stores/security-two-factor-authentication-use.html
[7]: https://support.google.com/accounts/answer/1066447?co=GENIE.Platform%3DAndroid&hl=en
[8]: https://authy.com/
[9]: https://docs.magento.com/m2/ee/user_guide/stores/security-two-factor-authentication-use.html#u2f-key
[10]: https://www.yubico.com/
[11]: https://duo.com/
[12]: https://github.com/magento/magento2-functional-testing-framework/blob/develop/docs/configure-2fa.md
Copy link
Contributor

@jeff-matthews jeff-matthews Jun 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if the MFTF team merged this with master so that we could link to it on the devdocs site. We currently publish docs from that repo under: https://devdocs.magento.com/mftf/docs/introduction.html. I guess this will do for beta.

[13]: https://emn178.github.io/online-tools/base32_encode.html