0
votes

I use Synfony 5.0 and "lexik/jwt-authentication-bundle": "^2.6".

displays the following message: {"code":401,"message":"Authentication request could not be processed due to a system problem."}

This error only occurs with postgres. When I switch to mysql it works. How can I solve this?

Below is my 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  }`

in the log:

Mar 30 10:19:51 |WARN | SERVER 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: Matched route "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: Authentication request failed. {"exception":"[object] (Symfony\Component\Security\Core\Exception\AuthenticationServiceException(code: 0): An exception occurred while executing '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 ["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 ^ at C:\Projetos\Projetos\mp\vendor\symfony\security-core\Authentication\Provider\DaoAuthenticationProvider.php:96)\n[previous exception] [object] (Doctrine\DBAL\Exception\InvalidFieldNameException(code: 0): An exception occurred while executing '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 username_2, t0.roles AS...\n ^ at C:\Projetos\Projetos\mp\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\AbstractPostgreSQLDriver.php:60)\n[previous exception] [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 ^ at 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 ^ at C:\Projetos\Projetos\mp\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOStatement.php:121)"} []

2
What have you tried to debug the problem? Which parts of that error message are unclear?Nico Haase

2 Answers

0
votes

This problem was solved by changing the name of the User class, because in Postgres the word "user" is reserved and there is an error in the query interpretation.

0
votes

You have to change the User class name.