1

I'm getting this error during the running of DB migrations. It was working fine until recently. The issue is started with failing the DB migrations in our QA servers when running pipelines. When I looked within the migration container, there was above error occurred.

So, then I tried removing my local application and setting it up from the scratch. During the php bin/console doctrine:migrations:migrate, the error has occurred.

enter image description here

We are using LexikJWTAuthenticationBundle bundle to manage the JWT authentication for the API. So, what I'm guessing is there may be some missing configurations related to LexikJWTAuthenticationBundle that I cannot figure out.

And here is the content of my config\packages\security.yaml file.

enter image description here

Nico Haase
  • 11,420
  • 35
  • 43
  • 69
chamindaindika
  • 455
  • 3
  • 15
  • What have you tried to resolve the problem? Where are you stuck? What has changed between the last working state, and the current one? – Nico Haase Nov 10 '21 at 07:34
  • try following their doc: https://github.com/lexik/LexikJWTAuthenticationBundle/blob/2.x/Resources/doc/1-configuration-reference.md – Tim Zwinkels Nov 10 '21 at 08:17

1 Answers1

2

After updating to Symfony 5.3 (or greater) refer to: https://github.com/lexik/LexikJWTAuthenticationBundle/blob/2.x/Resources/doc/index.rst#installation

Fix:

  1. Remove all from lexis_jwt: and replace it with jwt: ~
  2. Add enable_authenticator_manager: true to security
  3. Remove anonymous: true from api part
  4. You shouldn't change anything in lexik_jwt_authentication.yaml file but make sure it is configured correctly

My sample security file (only admin has access to api resource):

security:
    enable_authenticator_manager: true

    encoders:
        App\Entity\User:
            algorithm: bcrypt
    providers:
        database:
            entity:
                class: App\Entity\User
                property: username

    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt|error)|css|images|js)/
            security: false

        login:
            pattern: ^/secured
            stateless: true
            provider: database
            json_login:
                check_path: /secured/login_check
                username_path: username
                password_path: password
                success_handler: lexik_jwt_authentication.handler.authentication_success
                failure_handler: lexik_jwt_authentication.handler.authentication_failure
                require_previous_session: false

        api:
            pattern: ^/api
            stateless: true
            jwt: ~

    access_control:
        - { path: ^/secured/login_check$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/secured/login$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/api, roles: ROLE_ADMIN }
GusDeCooL
  • 5,639
  • 17
  • 68
  • 102
GrzeGab
  • 76
  • 3