lexik/LexikJWTAuthenticationBundle

Unrecognized option "enabled" under "lexik_jwt_authentication.api_platform"

thibaut22200 opened this issue · 14 comments

I have this error message when cache clear in symfony app (version 6.2) :
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 1
!!
!! In ArrayNode.php line 304:
!!
!! Unrecognized option "enabled" under "lexik_jwt_authentication.api_platform"
!! . Available options are "check_path", "password_path", "username_path".
!!
!!
!!
Script @auto-scripts was called via post-install-cmd

Here is my lexik configuration file:
lexik_jwt_authentication:
secret_key: '%env(resolve:JWT_SECRET_KEY)%'
public_key: '%env(resolve:JWT_PUBLIC_KEY)%'
pass_phrase: '%env(JWT_PASSPHRASE)%'
token_ttl: 86400

Hello there,

I have the same error with a new symfony 6.3 projet.

[KO]
Script cache:clear returned with error code 1
!!
!!  In ArrayNode.php line 327:
!!
!!    Unrecognized option "enabled" under "lexik_jwt_authentication.api_platform". Available options are "check_path", "password_path", "username_path".
!!
!!
!!  2023-08-11T09:29:21+00:00 [info] User Deprecated: Method "Symfony\Component\HttpKernel\Bundle\Bundle::build()" might add "void" as a native return type declaration in the future. Do the same in child class "Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle" now to avoid errors or add an explicit @return annotation to suppress this message.
!!  2023-08-11T09:29:21+00:00 [info] User Deprecated: Method "Symfony\Component\HttpKernel\Bundle\Bundle::registerCommands()" might add "void" as a native return type declaration in the future. Do the same in child class "Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle" now to avoid errors or add an explicit @return annotation to suppress this message.
!!
Script @auto-scripts was called via post-update-cmd

there is a problem with lexik/jwt version.
i use composer require lexik/jwt-authentication-bundle by default.

composer.json

{
    "type": "project",
    "license": "proprietary",
    "minimum-stability": "stable",
    "prefer-stable": true,
    "require": {
        "php": ">=8.1",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "api-platform/core": "^3.1",
        "doctrine/doctrine-bundle": "^2.10",
        "doctrine/doctrine-migrations-bundle": "^3.2",
        "doctrine/orm": "^2.16",
        "lexik/jwt-authentication-bundle": "*",
        "nelmio/cors-bundle": "^2.3",
        "phpdocumentor/reflection-docblock": "^5.3",
        "phpstan/phpdoc-parser": "^1.23",
        "symfony/asset": "6.3.*",
        "symfony/console": "6.3.*",
        "symfony/dotenv": "6.3.*",
        "symfony/expression-language": "6.3.*",
        "symfony/flex": "^2",
        "symfony/framework-bundle": "6.3.*",
        "symfony/property-access": "6.3.*",
        "symfony/property-info": "6.3.*",
        "symfony/runtime": "6.3.*",
        "symfony/security-bundle": "6.3.*",
        "symfony/serializer": "6.3.*",
        "symfony/twig-bundle": "6.3.*",
        "symfony/validator": "6.3.*",
        "symfony/yaml": "6.3.*"
    },
    "require-dev": {
        "symfony/maker-bundle": "^1.50"
    },
    "config": {
        "allow-plugins": {
            "php-http/discovery": true,
            "symfony/flex": true,
            "symfony/runtime": true
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php72": "*",
        "symfony/polyfill-php73": "*",
        "symfony/polyfill-php74": "*",
        "symfony/polyfill-php80": "*",
        "symfony/polyfill-php81": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "6.3.*"
        }
    }
}
Niiph commented

I had the same problem with Lexik bundle being 2.18 when I updated api-platform/core to latest 3.1.14, but updating Lexik to 2.19 resolved this problem.

Hello there.

I solved my problem by enable sodium extension in php.ini.
lcobucci/jwt 5.0.0 require this extension.

The same for me guys ...

Hello there.

I solved my problem by enable sodium extension in php.ini. lcobucci/jwt 5.0.0 require this extension.

Nice work, thanks

I had the same problem with Lexik bundle being 2.18 when I updated api-platform/core to latest 3.1.14, but updating Lexik to 2.19 resolved this problem.

Fonctionnel pour un projet Symfony en 6.2, j'ai changé la version 2.18 par 2.19 et ça fonctionne !

Msmili commented

Hello, i have the same problem, i try different solution but nothing work, anyone in same case ? Other solution ?
Thanks you

My api_platform.yaml :

api_platform:
    title: 'API Platform'
    description: 'API Platform Description'
    version: '1.0.0'
    formats:
        jsonld: ['application/ld+json']

My lexik_jwt_authentication.yaml :

lexik_jwt_authentication:
    secret_key: '%env(resolve:JWT_SECRET_KEY)%'
    public_key: '%env(resolve:JWT_PUBLIC_KEY)%'
    pass_phrase: '%env(JWT_PASSPHRASE)%'

My composer.json :

{
    "type": "project",
    "license": "proprietary",
    "minimum-stability": "stable",
    "prefer-stable": true,
    "require": {
        "php": ">=8.1",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "api-platform/core": "^3.1",
        "doctrine/doctrine-bundle": "^2.10",
        "doctrine/doctrine-migrations-bundle": "^3.2",
        "doctrine/orm": "^2.16",
        "firebase/php-jwt": "*",
        "lexik/jwt-authentication-bundle": "*",
        "nelmio/cors-bundle": "^2.3",
        "paragonie/sodium_compat": "*",
        "phpdocumentor/reflection-docblock": "^5.3",
        "phpstan/phpdoc-parser": "^1.23",
        "symfony/asset": "6.3.*",
        "symfony/console": "6.3.*",
        "symfony/dotenv": "6.3.*",
        "symfony/expression-language": "6.3.*",
        "symfony/flex": "^2",
        "symfony/form": "6.3.*",
        "symfony/framework-bundle": "6.3.*",
        "symfony/property-access": "6.3.*",
        "symfony/property-info": "6.3.*",
        "symfony/runtime": "6.3.*",
        "symfony/security-bundle": "6.3.*",
        "symfony/serializer": "6.3.*",
        "symfony/twig-bundle": "6.3.*",
        "symfony/validator": "6.3.*",
        "symfony/yaml": "6.3.*"
    },
    "config": {
        "allow-plugins": {
            "php-http/discovery": true,
            "symfony/flex": true,
            "symfony/runtime": true
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php72": "*",
        "symfony/polyfill-php73": "*",
        "symfony/polyfill-php74": "*",
        "symfony/polyfill-php80": "*",
        "symfony/polyfill-php81": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "6.3.*"
        }
    },
    "require-dev": {
        "symfony/maker-bundle": "^1.50"
    }
}

Hi, try
"lexik/jwt-authentication-bundle": "2.19",
And update your composer

Msmili commented

Thanks you !! I was lost in my configuration... I had modified the wrong php.ini, moreover, but now everything is fine, I can finally move forward :D

Solutionné en enlevant le commentaire sur l'extension sodium (extension=sodium) dans le fichier php.ini, comment mentionné plus haut.


Solved by removing the comment about the sodium extension (extension=sodium) in the php.ini file, as mentioned above.

Solutionné en enlevant le commentaire sur l'extension sodium (extension=sodium) dans le fichier php.ini, comment mentionné plus haut.

Solved by removing the comment about the sodium extension (extension=sodium) in the php.ini file, as mentioned above.

faire derrière un "composer update" avant de relancer la commande "composer require lexik/jwt-authentication-bundle"

The issue

I got the same issue when i try to require api (composer require api)
Full message :

Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 1
!!
!!  In ArrayNode.php line 322:
!!
!!    Unrecognized option "user_indentity_field" under "lexik_jwt_authentication". Did you mean "user_identity_field"?
!!
!!
!!
Script @auto-scripts was called via post-update-cmd

Informations

PHP : 8.1.10
Symfony : 6.1.12
Windows : 11

Solution

  1. Enable the sodium extension in the php.ini file (;extension=sodium to extension=sodium)
  2. If you use xamp : restart the apache service (stop then start)
  3. Make an update of composer (composer update)

hello, it's not function for me the same error come back every time

Upgrading from 2.18.* to 2.19.1 and enabling php=sodium
Helped me thank you guys