英文:
Shopware: htaccess authentication not working with adminnistration
问题
我尝试在我的Shopware 6应用程序中设置密码验证,我创建了一个.htpasswd
文件,其中包含用户名和哈希密码。
.htpasswd
已与.htaccess
正确链接,我可以看到提示对话框要求输入用户名/密码组合。
我的public/.htaccess
文件:
AuthType Basic
AuthName "受限区域"
AuthUserFile /Path/to/MyDomainSecretDirectory/.htpasswd
require valid-user
问题: 尝试访问/admin
时,对话框一直要求输入密码,并返回401错误,尽管密码正确,并在商店页面中有效。可能的问题是什么?
英文:
I'm trying to set a password authentication in my Shopware 6 application, I created a .htpasswd
file with the username and a hashed password.
The .htpasswd
was linked properly with the .htaccess and it works as I can see the prompt dialog asking for the username/password combination.
My public/.htaccess
file:
AuthType Basic
AuthName "restricted area"
AuthUserFile /Path/to/MyDomainSecretDirectory/.htpasswd
require valid-user
The problem: When trying to access the /admin
the dialogue box keeps asking for the password and returns a 401 error although the password is fine and works with the storefront.
What could be the problem?
答案1
得分: 1
我找到了解决这个问题的方法。
> 使用Shopware 6,一些商店数据也存在于无法从互联网访问的目录之外。使用经典的.htaccess
密码保护设置后,Shopware登录不再起作用。在调用Shopware后台时,会反复要求输入htaccess保护的密码,因此无法登录。
解决方法是取消保护/api
端点。只需在.htaccess
代码下添加以下代码块:
AuthType Basic
AuthName "受限区域"
AuthUserFile /Path/to/MyDomainSecretDirectory/.htpasswd
require valid-user
# 添加以下行以取消保护/API路由
SetEnvIf Request_URI /api noauth=1
<RequireAny>
Require env noauth
Require env REDIRECT_noauth
Require valid-user
</RequireAny>
英文:
I found the answer to this issue.
> With Shopware 6, some of the shop data is also outside of the
> directory that can be accessed from the Internet. With a classic
> .htaccess
password protection setup, the Shopware login no longer
> works. When calling up the Shopware backend, you are repeatedly asked
> for the password for the htaccess protection, making it impossible to
> log in.
The solution here is to unprotect the /api
endpoint. Simply add the following code block under the .htaccess
code:
AuthType Basic
AuthName "restricted area"
AuthUserFile /Path/to/MyDomainSecretDirectory/.htpasswd
require valid-user
# ADD THESE LINES TO UNPROTECT THE /API ROUTE
SetEnvIf Request_URI /api noauth=1
<RequireAny>
Require env noauth
Require env REDIRECT_noauth
Require valid-user
</RequireAny>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论