dtnqbre7980007 2018-10-13 16:55
浏览 158

Symfony 4经过身份验证的用户令牌丢失

I have an issue with a login. When I enter the user credentials and press login button it creates a user token and redirects to the main page but when the request gets main page user token doesn't exist... Here is data from dev.log file

request.INFO: Matched route "login_check". {"route":"login_check","route_parameters":{"_route":"login_check","_controller":"App\\Controller\\Auth\\LoginController::login"},"request_uri":"http://localhost:8082/login","method":"POST"} []
security.INFO: User has been authenticated successfully. {"username":"jac@jack.com"} []
security.DEBUG: Fallback to the default authentication success handler. [] []
security.DEBUG: Clearing remember-me cookie. {"name":"REMEMBERME"} []
security.DEBUG: Remember-me was requested; setting cookie. [] []
security.DEBUG: Stored the security token in the session. {"key":"_security_main"} []
request.INFO: Matched route "main". {"route":"main","route_parameters":{"_route":"main","_controller":"App\\Controller\\MainController::index"},"request_uri":"http://localhost:8082/","method":"GET"} []
security.DEBUG: Read existing security token from the session. {"key":"_security_main","token_class":"Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken"} []
security.WARNING: Username could not be found in the selected user provider. {"username":null,"provider":"App\\Security\\UserProvider"} []
security.DEBUG: Remember-me cookie detected. [] []
security.INFO: User for remember-me cookie not found. {"exception":"[object] (Symfony\\Component\\Security\\Core\\Exception\\UsernameNotFoundException(code: 0): Username \"jac@jack.com\" does not exist. at /opt/aicty/src/Security/UserProvider.php:52)"} []
security.DEBUG: Clearing remember-me cookie. {"name":"REMEMBERME"} []
security.INFO: Populated the TokenStorage with an anonymous Token. [] []
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 /opt/aicty/vendor/symfony/security/Http/Firewall/AccessListener.php:68)"} []
security.DEBUG: Calling Authentication entry point. [] []
request.INFO: Matched route "show_login". {"route":"show_login","route_parameters":{"_route":"show_login","_controller":"App\\Controller\\Auth\\LoginController::showLogin"},"request_uri":"http://localhost:8082/login","method":"GET"} []
security.INFO: Populated the TokenStorage with an anonymous Token. [] []
request.INFO: Matched route "_wdt". {"route":"_wdt","route_parameters":{"_route":"_wdt","_controller":"web_profiler.controller.profiler::toolbarAction","token":"e96cb7"},"request_uri":"http://localhost:8082/_wdt/e96cb7","method":"GET"} []

And here is my security yaml conf. I took User class and UserProvider class from symfony documentation.

security:
    encoders:
        App\Entity\User:
            algorithm: bcrypt
            cost: 12
    providers:
        japi:
            id: App\Security\UserProvider
    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        main:
            anonymous: ~
            provider: japi
            simple_form:
                login_path: show_login
                check_path: login_check
                username_parameter: email
                password_parameter: password
                authenticator: App\Security\Authenticator
                remember_me: true
                provider: japi
  • 写回答

1条回答 默认 最新

  • douchaqi3369 2018-10-13 21:30
    关注

    Do you use https://github.com/lexik/LexikJWTAuthenticationBundle?

    Configuration is straightforward:

    security:
        # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
        providers:
          webservice:
            id: App\Security\UserProvider
    
        encoders:
          App\Entity\User:
            algorithm: bcrypt
            cost: 12
    
        firewalls:
            dev:
                pattern: ^/(_(profiler|wdt)|css|images|js)/
                security: false
    
            login:
              pattern:  ^/login
              stateless: true
              anonymous: true
              json_login:
                check_path:               /login_check
                success_handler:          lexik_jwt_authentication.handler.authentication_success
                failure_handler:          lexik_jwt_authentication.handler.authentication_failure
    
    评论

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码