Trying to get a token not currently working

Rom*_*CIA 1 token symfony jwt api-platform.com

I am trying to put a JWT Auth to access my API : /api/docs But I am currently getting an error while trying to get the token with this command :

curl -X POST -H "Content-Type: application/json" http://localhost/login_check -d '{"username":"johndoe","password":"test"}'
Run Code Online (Sandbox Code Playgroud)

Of course I replace username and password

Signature key "/var/www/config/jwt/private.pem" does not exist or is not readable. Did you correctly set the "lexik_jwt_authentication.signature_key" configuration key? (500 Internal Server Error)

security.yaml

    firewalls:
        login:
            pattern:  ^/login
            stateless: true
            anonymous: true
            provider: fos_userbundle_2
            json_login:
                check_path: /login_check
                username_path: username
                password_path: password
                success_handler: 
    lexik_jwt_authentication.handler.authentication_success
                failure_handler: 
    lexik_jwt_authentication.handler.authentication_failure

        main:
            pattern:   ^/
            provider: fos_userbundle_2
            stateless: true
            anonymous: true
            guard:
                authenticators:
                    - lexik_jwt_authentication.jwt_token_authenticator

        dev:
            pattern:  ^/(_(profiler|wdt)|css|images|js)/
            security: false
Run Code Online (Sandbox Code Playgroud)

Signature key "/var/www/config/jwt/private.pem" does not exist or is not readable. Did you correctly set the "lexik_jwt_authentication.signature_key" configuration key? (500 Internal Server Error)

Dan*_*iel 8

检查读取和写入由 openssl 生成的文件的权限。

$ mkdir -p config/jwt
$ openssl genpkey -out config/jwt/private.pem -aes256 -algorithm rsa -pkeyopt rsa_keygen_bits:4096
$ openssl pkey -in config/jwt/private.pem -out config/jwt/public.pem -pubout
Run Code Online (Sandbox Code Playgroud)

在我之前的情况下:

-rw-------    1 root     root          3434 Jul 26 21:21 private.pem
-rw-r--r--    1 root     root           800 Jul 26 21:21 public.pem
Run Code Online (Sandbox Code Playgroud)

然后我跑

chmod 644 public.pem private.pem
Run Code Online (Sandbox Code Playgroud)

现在:

-rw-r--r--    1 root     root          3434 Jul 26 21:21 private.pem
-rw-r--r--    1 root     root           800 Jul 26 21:21 public.pem
Run Code Online (Sandbox Code Playgroud)

它有效。


文档:

https://github.com/lexik/LexikJWTAuthenticationBundle/blob/master/Resources/doc/index.md#generate-the-ssh-keys