{“ code”:401,“ message”:“由于系统问题,无法处理身份验证请求。”}-Symfony 5.0-lexik / jwt-authentication-bundle

时间:2020-03-30 14:38:59

标签: postgresql symfony authentication doctrine-orm lexikjwtauthbundle

我使用Synfony 5.0和“ lexik / jwt-authentication-bundle”:“ ^ 2.6”。

显示以下消息: {“ code”:401,“ message”:“由于系统问题,无法处理身份验证请求。”}

此错误仅在postgres中发生。当我切换到mysql时,它可以工作。 我该如何解决?

下面是我的security.yaml:

security:
  encoders:        
    App\Entity\User:
        algorithm: bcrypt

  providers:
    # used to reload user from session & other features (e.g. switch_user)
    app_user_provider:
        entity:
            class: App\Entity\User
            property: username
  firewalls:
    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false        

    login:
        pattern:  ^/api/login
        stateless: true
        anonymous: true
        json_login:
            check_path:               /api/login_check
            success_handler:          lexik_jwt_authentication.handler.authentication_success
            failure_handler:          lexik_jwt_authentication.handler.authentication_failure
    api:
        pattern:   ^/api
        stateless: true
        guard:
            authenticators:
                - lexik_jwt_authentication.jwt_token_authenticator 

    main:
        anonymous: lazy
        provider: app_user_provider       


  # 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: ^/api/login, roles: IS_AUTHENTICATED_ANONYMOUSLY  }
    - { path: ^/api, roles: IS_AUTHENTICATED_FULLY  }`

在日志中:

3月30日10:19:51 |警告|服务器发布(401)/ api / login_check host =“ 127.0.0.1:8004” ip =“ 127.0.0.1” scheme =“ https” [2020-03-30T10:19:51.769724-03:00] request.INFO:匹配的路线“ api_login_check”。 {“ route”:“ api_login_check”,“ route_parameters”:{“ _ route”:“ api_login_check”},“ request_uri”:“ http://127.0.0.1:8000/api/login_check”,“ method”:“ POST”} [] [2020-03-30T10:19:51.888870-03:00] security.INFO:身份验证请求失败。 {“ exception”:“ [对象](Symfony \ Component \ Security \ Core \ Exception \ AuthenticationServiceException(代码:0):执行'SELECT t0.id AS id_1,t0.username AS username,_2,t0.roles AS时发生异常Roles_3,t0.password AS password_4来自用户t0,其中t0.username =?LIMIT 1',带有参数[“ my_username”]:\ n \ nSQLSTATE [42703]:未定义列:7错误:t0.id列不存在\ nLINE 1:在C:\ Projetos \ Projetos \ mp \ vendor \ symfony \ security-core \ Authentication \ Provider \ DaoAuthenticationProvider.php中选择t0.id AS id_1,t0.username AS用户名_2,t0.roles AS ... \ n ^ :96)\ n [先前的异常] [对象](Doctrine \ DBAL \ Exception \ InvalidFieldNameException(代码:0):执行'SELECT t0.id AS id_1,t0.username AS username_2,t0.roles AS role_3时发生异常,t0.password AS password_4 FROM user t0 WHERE t0.username =?LIMIT 1'with params [“ wagner”]:\ n \ nSQLSTATE [42703]:未定义列:7错误:t0.id列不存在\ nLINE 1 :SELECT t0.id AS id_1,t0.username AS使用rname_2,t0.roles AS ... \ n ^,位于C:\ Projetos \ Projetos \ mp \ vendor \ doctrine \ dbal \ lib \ Doctrine \ DBAL \ Driver \ AbstractPostgreSQLDriver.php:60)\ n [先前的例外] [对象](Doctrine \ DBAL \ Driver \ PDOException(代码:42703):SQLSTATE [42703]:未定义的列:7错误:t0.id列不存在\ nLINE 1:SELECT t0.id AS id_1,t0.username AS username_2,t0.roles AS ... \ n ^,位于C:\ Projetos \ Projetos \ mp \ vendor \ doctrine \ dbal \ lib \ Doctrine \ DBAL \ Driver \ PDOStatement.php:123)\ n [先前的例外] [对象](PDOException(code:42703):SQLSTATE [42703]:未定义的列:7错误:t0.id列不存在\ nLINE 1:选择t0.id AS id_1,t0.username AS用户名_2,t0.roles AS.。 。\ n ^,位于C:\ Projetos \ Projetos \ mp \ vendor \ doctrine \ dbal \ lib \ Doctrine \ DBAL \ Driver \ PDOStatement.php:121)“} []

2 个答案:

答案 0 :(得分:1)

通过更改User类的名称解决了此问题,因为在Postgres中保留了“ user”一词,并且查询解释中存在错误。

答案 1 :(得分:0)

您必须更改用户类名称。