lexik/LexikJWTAuthenticationBundle

Unrecognized option "api_platform" under "lexik_jwt_authentication"

sayou opened this issue · 2 comments

sayou commented

I am currently working on programming a website using Symfony version 6.2 and API Platform in addition to MongoDB in the database and a work environment on Docker.

I am trying to add the feature of connecting through JWT (LexikJWTAuthenticationBundle), and I was able to log in successfully and get the token, but when I try to use the token to get access to the rest of the pages, the response is always as follows:

{
    "code": 401,
    "message": "JWT Token not found"
}

I searched for the cause of the following problem in the search engines, and the solutions presented were numerous (although unfortunately, they are absent in everything related to the latest version of Symfony), most notably modifying the environment and adding the following code:

SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

Honestly, I didn't know exactly how to change this command in the Docker environment, but when I use the following code on the index page to check that the token is being sent, I get the correct answer and that the token is being sent

$token = getallheaders()['Authorization'];

print_r($token);
exit;

I went to the official documentation for the used bundle (LexikJWTAuthenticationBundle), but unfortunately, when I do the next step:

# config/packages/lexik_jwt_authentication.yaml
lexik_jwt_authentication:
    # ...
    api_platform:
        check_path: /api/login_check

I get the following error:

Unrecognized option "api_platform" under "lexik_jwt_authentication". Available options are "additional_public_keys", "allow_no_expiration", "clock_skew", "encoder", "pass_phrase", "private_key_path", "public_key", "public_key_path", "remove_token_from_body_when_cookies_used", "secret_key", "set_cookies", "token_extractors", "token_ttl", "user_id_claim", "user_identity_field".

Is there a solution to that?

sayou commented

I solved the 401 problem by adding the following code to the vhost file:

SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
But I still get the error message if I follow the official documentation:

Unrecognized option "api_platform" under "lexik_jwt_authentication"

It's from #1098 which is not yet released. So don't set that key for now.