AuthenticationException在TokenStorage中找不到Token ?



我已经升级到Symfony 5,我遇到了一个安全问题,我无法打开登录页面。当我从localhost访问公共文件夹时它会将我重定向到

.../public/login与404头

我在MAMP pro mac版本上使用PHP 8.0.8。

我在security.yaml中错过了什么吗?

framework.yaml

# see https://symfony.com/doc/current/reference/configuration/framework.html
framework:
secret: '%env(APP_SECRET)%'
#csrf_protection: true
#http_method_override: true
# Enables session support. Note that the session will ONLY be started if you read or write from it.
# Remove or comment this section to explicitly disable session support.
session:
handler_id: 'session.handler.native_file'
save_path: '%kernel.project_dir%/var/sessions/%kernel.environment%'
cookie_secure: true 
cookie_samesite: 'none'
#        cookie_secure: auto
#        cookie_samesite: lax
#esi: true
#fragments: true
php_errors:
log: true

security.yaml

security:
encoders:
AppEntityUser:
algorithm: auto
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
# used to reload user from session & other features (e.g. switch_user)
app_user_provider:
entity:
class: AppEntityUser
property: email
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
anonymous: false
lazy: false
provider: app_user_provider
guard:
authenticators:
- AppSecurityLoginFormAuthenticator
logout:
path: app_logout
# where to redirect after logout
# target: app_any_route
# activate different ways to authenticate
# https://symfony.com/doc/current/security.html#firewalls-authentication
# https://symfony.com/doc/current/security/impersonating_user.html
# switch_user: true
# 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: ^/admin, roles: ROLE_ADMIN }
# - { path: ^/profile, roles: ROLE_USER }
- { path: ^/efconnect, role: ROLE_USER }
- { path: ^/elfinder, role: ROLE_USER }

错误日志:

[2021-08-21T09:44:38.264832+00:00] request.INFO: Matched route "app_process_process_show". {"route":"app_process_process_show","route_parameters":{"_route":"app_process_process_show","_controller":"App\Controller\ProcessBundle\ProcessController::show"},"request_uri":"http://localhost:8888/site/public/","method":"GET"} []
[2021-08-21T09:44:38.270837+00:00] security.DEBUG: Checking for guard authentication credentials. {"firewall_key":"main","authenticators":1} []
[2021-08-21T09:44:38.270998+00:00] security.DEBUG: Checking support on guard authenticator. {"firewall_key":"main","authenticator":"App\Security\LoginFormAuthenticator"} []
[2021-08-21T09:44:38.271146+00:00] security.DEBUG: Guard authenticator does not support the request. {"firewall_key":"main","authenticator":"App\Security\LoginFormAuthenticator"} []
[2021-08-21T09:44:38.289628+00:00] security.INFO: An AuthenticationException was thrown; redirecting to authentication entry point. {"exception":"[object] (Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException(code: 0): A Token was not found in the TokenStorage. at /Users/xx/Documents/Sites/site/vendor/symfony/security-http/Firewall/AccessListener.php:70)"} []
[2021-08-21T09:44:38.289822+00:00] security.DEBUG: Calling Authentication entry point. [] []

您的配置说您不接受匿名用户。您唯一的Guard不支持当前请求。因此,由于不允许未经授权的用户,并且我们无法授权请求,因此抛出此异常。

anonymous: true

相关内容

  • 没有找到相关文章

最新更新