JWT-Secrets as Environment Variables

When using Shopware 6.6 in a dockerized or cluster setup, you may want to use env vars in lieu of files for your JWT keys. This is how convert your keys.

In your shopware.yaml (or any other valid configuration file), create or amend the following entry:

shopware:
    api:                                                                                                               
        jwt_key:                                                                                                       
            private_key_path: '%env(base64:JWT_PRIVATE_KEY)%'                                                          
            public_key_path: '%env(base64:JWT_PUBLIC_KEY)%'

The easiest way to generate JWT secrets is using shopware-cli with the following command:

shopware-cli project generate-jwt --env

If you have already generated your file-based JWT keys, use these commands to create the base64 equivalent to be specified in .env:

cat shopware/config/jwt/private.pem | base64 | tr -d '\n'
cat shopware/config/jwt/public.pem | base64 | tr -d '\n'

and paste the corresponding results as values for JWT_PRIVATE_KEY and JWT_PUBLIC_KEY, respectively, in your .env.local.

Last updated