這讓我發瘋,它正在作業,我不知道發生了什么變化,但現在我的登錄頁面上出現了無限重定向回圈 (301),日志顯示 AccessDeniedException。顯然我已經檢查了許多 StackOverflow 答案和其他互聯網鏈接,但我看不出我的設定有什么問題:
安全.yaml:
security:
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
providers:
app_user_provider:
entity:
class: App\Entity\Users
property: email
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
customer:
pattern: ^/customer
security: false
main:
pattern: ^/
lazy: true
provider: app_user_provider
form_login:
login_path: login
check_path: login
enable_csrf: true
logout:
path: logout
target: /login
# Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/customer, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/sales, roles: [ROLE_SALES, ROLE_ADMIN] }
- { path: ^/admin, role: ROLE_ADMIN }
日志:
[2022-10-26T11:29:20.918658 00:00] request.INFO: Matched route "login". {"route":"login","route_parameters":{"_route":"login","_controller":"App\\Controller\\SecurityController::login"},"request_uri":"https://***.com/login","method":"GET"} []
[2022-10-26T11:29:20.928261 00:00] security.DEBUG: Checking for authenticator support. {"firewall_name":"main","authenticators":1} []
[2022-10-26T11:29:20.928351 00:00] security.DEBUG: Checking support on authenticator. {"firewall_name":"main","authenticator":"Symfony\\Component\\Security\\Http\\Authenticator\\FormLoginAuthenticator"} []
[2022-10-26T11:29:20.928405 00:00] security.DEBUG: Authenticator does not support the request. {"firewall_name":"main","authenticator":"Symfony\\Component\\Security\\Http\\Authenticator\\FormLoginAuthenticator"} []
[2022-10-26T11:29:20.955819 00:00] security.DEBUG: Access denied, the user is not fully authenticated; redirecting to authentication entry point. {"exception":"[object] (Symfony\\Component\\Security\\Core\\Exception\\AccessDeniedException(code: 403): Access Denied. at /vendor/symfony/security-http/Firewall/AccessListener.php:97)"} []
這有什么問題?
uj5u.com熱心網友回復:
IS_AUTHENTICATED_ANONYMOUSLY 在 5.3 中已棄用并在 6.0 中洗掉(?),官方檔案建議改用 PUBLIC_ACCESS
請參閱https://symfony.com/doc/6.1/security.html#allowing-unsecured-access-ie-anonymous-users
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/520698.html
標籤:验证交响乐防火墙
上一篇:Mybatis常見知識點
下一篇:Django用戶模型覆寫
