Skip to content

Commit 4cd9a1a

Browse files
authored
feat: use JWT bundle's command to create keys (#1448)
1 parent a09283e commit 4cd9a1a

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

core/jwt.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,15 @@ Then we need to generate the public and private keys used for signing JWT tokens
2424
docker-compose exec php sh -c '
2525
set -e
2626
apk add openssl
27-
mkdir -p config/jwt
28-
jwt_passphrase=${JWT_PASSPHRASE:-$(grep ''^JWT_PASSPHRASE='' .env | cut -f 2 -d ''='')}
29-
echo "$jwt_passphrase" | openssl genpkey -out config/jwt/private.pem -pass stdin -aes256 -algorithm rsa -pkeyopt rsa_keygen_bits:4096
30-
echo "$jwt_passphrase" | openssl pkey -in config/jwt/private.pem -passin stdin -out config/jwt/public.pem -pubout
27+
php bin/console lexik:jwt:generate-keypair
3128
setfacl -R -m u:www-data:rX -m u:"$(whoami)":rwX config/jwt
3229
setfacl -dR -m u:www-data:rX -m u:"$(whoami)":rwX config/jwt
3330
'
3431
```
3532

3633
Note that the `setfacl` command relies on the `acl` package. This is installed by default when using the API Platform docker distribution but may need be installed in your working environment in order to execute the `setfacl` command.
3734

38-
This takes care of using the correct passphrase to encrypt the private key, and setting the correct permissions on the
39-
keys allowing the web server to read them.
35+
This takes care of keypair creation (including using the correct passphrase to encrypt the private key), and setting the correct permissions on the keys allowing the web server to read them.
4036

4137
Since these keys are created by the `root` user from a container, your host user will not be able to read them during the `docker-compose build caddy` process. Add the `config/jwt/` folder to the `api/.dockerignore` file so that they are skipped from the result image.
4238

0 commit comments

Comments
 (0)