JWTRefreshTokenBundle icon indicating copy to clipboard operation
JWTRefreshTokenBundle copied to clipboard

Can't configure refresh token with SF6

Open sanchobouillant opened this issue 2 years ago • 6 comments

Hi everyone,

I try to configure the bundle with SF6 AND php8.1

routes.yaml

gesdinet_jwt_refresh_token:
  path: /auth-token/refresh
  controller: gesdinet.jwtrefreshtoken::refresh

security.yaml

    login:
      pattern: ^/auth-token
      user_checker: App\Security\UserChecker
      stateless: true
      json_login:
        check_path: /auth-token
        success_handler: lexik_jwt_authentication.handler.authentication_success
        failure_handler: lexik_jwt_authentication.handler.authentication_failure

    refresh:
      pattern: ^/auth-token/refresh
      user_checker: App\Security\UserChecker
      stateless: true
      refresh_jwt: ~
      provider: app_user_provider

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

    main:
      lazy: true
      provider: app_user_provider
      user_checker: App\Security\UserChecker
      stateless: true
      jwt: ~
      entry_point: jwt

With that code I have

Attempted to load class \"AbstractGuardAuthenticator\" from namespace \"Symfony\\Component\\Security\\Guard\".\nDid you forget a \"use\" statement for another namespace?

If I remove the controller part from the routes.yaml I have:

Unable to find the controller for path "/auth-token/refresh". The route is wrongly configured.

What did I missed in my configuration?

sanchobouillant avatar Jun 27 '22 10:06 sanchobouillant

Try to remove controller: from routes. It's non intended for usage with recent SF versions. Also add provider to a firewall https://github.com/markitosgv/JWTRefreshTokenBundle/issues/307#issuecomment-1077822967

programmador avatar Jun 27 '22 17:06 programmador

Whenb I remove the controller and add the provider. I have

Unable to find the controller for path \"/auth-token/refresh\". The route is wrongly configured.

security.yaml

    api_token_refresh:
      pattern: ^/auth-token/refresh
      stateless: true
      provider: app_user_provider
      refresh_jwt: ~

routes.yaml

api_refresh_token:
  path: /auth-token/refresh

sanchobouillant avatar Jul 01 '22 05:07 sanchobouillant

@sanchobouillant Did you ever find a solution for this? I'm also facing the same issue.

boxedcode avatar Sep 09 '22 12:09 boxedcode

same here

fico7489 avatar Feb 28 '23 14:02 fico7489

Remove config/routes/gesdinet_jwt_refresh_token.yaml

yo1nick avatar Aug 03 '23 18:08 yo1nick

It work but there are some deprecated warning routes.yaml:

api_login_check:
  path: /auth-token

gesdinet_jwt_refresh_token:
  path: /api/token/refresh

security:

    login:
      pattern: ^/auth-token
      user_checker: App\Security\UserChecker
      stateless: true
      json_login:
        check_path: /auth-token
        success_handler: lexik_jwt_authentication.handler.authentication_success
        failure_handler: lexik_jwt_authentication.handler.authentication_failure

    refresh:
      pattern: ^/auth-token/refresh
      user_checker: App\Security\UserChecker
      stateless: true
      refresh_jwt: ~
      provider: app_user_provider

    main:
      lazy: true
      provider: app_user_provider
      user_checker: App\Security\UserChecker
      stateless: true
      jwt: ~
      entry_point: jwt
      refresh_jwt:
        check_path: gesdinet_jwt_refresh_token

gesdinet_jwt_refresh_token:

gesdinet_jwt_refresh_token:
    refresh_token_class: App\Entity\RefreshToken
    single_use: true

sanchobouillant avatar Aug 04 '23 06:08 sanchobouillant