【问题标题】:{"code":401,"message":"Authentication request could not be processed due to a system problem."} - Symfony 5.0 - lexik/jwt-authentication-bundle{"code":401,"message":"由于系统问题,无法处理身份验证请求。"} - Symfony 5.0 - lexik/jwt-authentication-bundle
【发布时间】:2020-03-30 14:38:59
【问题描述】:

我使用 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 |警告 |服务器 POST (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":"[object] (Symfony\Component\Security\Core\Exception\AuthenticationServiceException(code: 0): 执行 'SELECT t0.id AS id_1, t0.username AS username_2, t0.roles AS 时发生异常角色_3,t0.password AS password_4 FROM user t0 WHERE t0.username = ? LIMIT 1' with params ["my_username"]:\n\nSQLSTATE[42703]: Undefined column: 7 ERROR: column t0.id does not exist\nLINE 1: SELECT t0.id AS id_1, t0.username AS username_2, t0.roles AS...\n ^ 在 C:\Projetos\Projetos\mp\vendor\symfony\security-core\Authentication\Provider\DaoAuthenticationProvider.php :96)\n[previous exception] [object] (Doctrine\DBAL\Exception\InvalidFieldNameException(code: 0): 执行 'SELECT t0.id AS id_1, t0.username AS username_2, t0.roles AS roles_3 时发生异常, t0.password AS password_4 FROM user t0 WHERE t0.username = ? LIMIT 1' with params ["wagner"]:\n\nSQLSTATE[42703]: Undefined column: 7 ERROR: column t0.id does not exist\nLINE 1 : SELECT t0.id AS id_1, t0.username AS use rname_2, t0.roles AS...\n ^ 在 C:\Projetos\Projetos\mp\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\AbstractPostgreSQLDriver.php:60)\n[上一个例外] [object] (Doctrine\DBAL\Driver\PDOException(code: 42703): SQLSTATE[42703]: Undefined column: 7 ERROR: column t0.id does not exist\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[previous exception] [object ] (PDOException(code: 42703): SQLSTATE[42703]: Undefined column: 7 ERROR: column t0.id does not exist\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:121)"} []

【问题讨论】:

  • 您尝试过什么调试问题?该错误消息的哪些部分不清楚?

标签: postgresql symfony authentication doctrine-orm lexikjwtauthbundle


【解决方案1】:

这个问题是通过更改 User 类的名称解决的,因为在 Postgres 中“user”这个词是保留的,查询解释有错误。

【讨论】:

    【解决方案2】:

    您必须更改用户类名称。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-27
      • 1970-01-01
      • 1970-01-01
      • 2022-07-14
      • 1970-01-01
      • 1970-01-01
      • 2022-10-14
      • 2020-10-31
      相关资源
      最近更新 更多