-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
Preconditions (*)
- Apache 2.4
- PHP 7.4
- MySQL 8
- Elasticsearch 7
- Magento 2.4.0
Steps to reproduce (*)
- Clean install of Magento 2.4 (via composer)
- Creation of admin account via CLI (part of setup:install command)
Expected result (*)
- Logging into Magento 2.4 for the first time allows immediate Google 2FA setup
Actual result (*)
- Logging into Admin for the first time presents a warning "Failed to send the message. Please contact the administrator. You need to configure Two-Factor Authorization in order to proceed to your store's admin area An E-mail was sent to you with further instructions". An email is required to complete 2FA. Without an SMTP enabled server, there is no way of retrieving the link to complete 2FA.
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
If an SMTP enabled server is required to send a 2FA link to allow for an Admin to complete a first time login, then I feel this should be added as a prerequisite
However, if there is a way to get to the 2FA QR page without the need to receive an email then this should be documented more clearly.
I am aware of the Two-Factor Authentication (MFTF) documentation. Stating that you could bypass this by creating a "Base32-encoded string for the shared secret value" and then "Use the following key to add the encoded value to the MFTF .credentials file."
However, the documentation doesn't provide enough details on the requirements to do this. It also insinuates that this procedure is preferable for a Testing environment and not Development/Production.
If it turns out that these MFTF steps are considered "safe" to complete in a Development/Product environment then it would definately improve QoL if these variables could be set through the bin/magento setup:install
values as stated in the Install the Magento software Documentation.
Activity
m2-assistant commentedon Jul 28, 2020
Hi @DigitalStartupUK. Thank you for your report.
To help us process this issue please make sure that you provided the following information:
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
@magento give me 2.4-develop instance
- upcoming 2.4.x releaseFor more details, please, review the Magento Contributor Assistant documentation.
Please, add a comment to assign the issue:
@magento I am working on this
🕙 You can find the schedule on the Magento Community Calendar page.
📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.
🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel
✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel
speedupmate commentedon Jul 29, 2020
It's not directly related as this issue talks that smtp should be a documented requirement but current workaround for dev environments (that don't need to have smtp set up) is simply to disable 2fa
bin/magento mo:di Magento_TwoFactorAuth
DigitalStartupUK commentedon Jul 29, 2020
But at some point, 2FA needs to be enabled during Development/Production. And there is probably an argument that states "well, surely in a Development/Production environment you would have an SMTP enabled server." But speaking from experience, myself and many others use 3rd party SMTP providers - Which are normally configured in the Admin Backend. It just seems like a really overlooked part of the installation/setup process. What's the point of enforcing 2FA on installation to only immediately disable it?
I'd simply prefer a simple CLI
config:set
command to generate the same URL that gets sent in the Email. Or even better, have the URL output with the Admin Backend URL notification that you see on successful install.I'm trying not to sound negative and whiny, but this lack of clarity is frustrating.
GitSteeve commentedon Jul 29, 2020
Hi, i'am exactly on the same point ... same error, same step ... i will try another solution
PawelP1977 commentedon Jul 29, 2020
Hi,
What is another solution?
MichaelThessel commentedon Aug 6, 2020
What a nightmare. Same issue here. This is the first time I encountered a 2fa setup situation that requires email. Usually you log into admin, enable 2fa and then set up the token logged into admin.
MichaelThessel commentedon Aug 6, 2020
In case anyone needs a temporary workaround to get this working without having SMTP set up:
var_dump($url);die;
on line 86 invendor/magento/module-two-factor-auth/Model/EmailUserNotifier.php
isaacBats commentedon Aug 6, 2020
A great Magento MX developer has created a module to disable double authentication.
This is the repo Module_EnableDisableTFA.
You can also install it from composer
composer require wolfsellers/module-enabledisabletfa
by @Rus0
sudhanshu-bajaj commentedon Aug 7, 2020
Temporary solution to kick start your development, just disable Magento_TwoFactorAuth module. It worked for me.
bin/magento module:disable Magento_TwoFactorAuth
phanku commentedon Aug 11, 2020
Great security feature added for that administration login section of Magento however I have also ran into another weird issue that personally has stopped me from being able to set up 2FA on a fresh install. My issue is that magento does not use the domain name set for the outgoing email when sending the email out to set up 2FA on a fresh install instead it sends the email from
owner@example.com
. I know normally that might not be a big issue but when sending emails from a server on a more security conscious Enterprise network that email may never actually go to the intended target because of the email domain of@example.com
.I have now disabled the Magento_TwoFactorAuth module as described above and have managed to login to the admin interface but I am now in the process of figuring out how to reenable/set up 2FA.
EstebanAorta commentedon Aug 15, 2020
Did you get it to work?
w0d4 commentedon Aug 26, 2020
I see the same problem. I cannot get 2FA to work, since the mail is sent from owner@example.com
Since I'm working with a more secure mailserver, I cannot sent mails from example.com domain.
I suggest to add a parameter during installation to set the owners E-Mail adress.
oviliz commentedon Oct 10, 2020
Speechless @magento-admin ...
fj-sfd commentedon Nov 30, 2020
Same issue with me while following Installation quick reference (tutorial) from Magento
for now I have disabled module (until I setup SMTP), as suggested by @speedupmate
bin/magento mo:di Magento_TwoFactorAuth
Jieiku commentedon Dec 1, 2020
Dropping this here for anyone having trouble configuring their mail in order to activate the 2FA.
To clarify, you do this on your Magento2 host, not your mail server.
Once finished just log out of Magento2 WebUI, then log back, you should receive the email.
Be sure to replace all occurrences of YourDomain.com with your domain name.
stale commentedon Feb 21, 2021
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!
Green2Matter commentedon Oct 12, 2021
Other workaround (https://devdocs.magento.com/guides/v2.4/security/two-factor-authentication.html):
bin/magento config:set twofactorauth/general/force_providers google
bin/magento config:set twofactorauth/google/otp_window 60
bin/magento security:tfa:google:set-secret <admin_user> <Base32-encoded_string_for_the_shared_secret_value>
Base32: https://emn178.github.io/online-tools/base32_encode.html
hgati commentedon Mar 15, 2023
What mean ? <Base32-encoded_string_for_the_shared_secret_value>
Is this mean "encoded_string of <admin_user>" ?
oviliz commentedon Mar 17, 2023
@hgati no, the admin username (
<admin_user>
) is before the shared secret (see the linked Magento doc).The
<Base32-encoded_string_for_the_shared_secret_value>
must be the encoded string of a chosen key you create manually in Google Authenticator.