Add LexikJWTAuthenticationBundle for JWT Authentication in Symfony

This commit is contained in:
Robin Chalas
2017-05-01 12:03:29 +02:00
parent 711b975c94
commit 9fdecab5ce
4 changed files with 26 additions and 0 deletions
@@ -0,0 +1,8 @@
generate-jwt-keys:
ifeq (, $(shell which openssl))
$(error "Unable to generate keys (needs OpenSSL)")
endif
mkdir -p etc/jwt
openssl genrsa -passout pass:${JWT_PASSPHRASE} -out ${JWT_PRIVATE_KEY_PATH} -aes256 4096
openssl rsa -passin pass:${JWT_PASSPHRASE} -pubout -in ${JWT_PRIVATE_KEY_PATH} -out ${JWT_PUBLIC_KEY_PATH}
@echo "\033[32mRSA key pair successfully generated\033[39m"
@@ -0,0 +1,4 @@
lexik_jwt_authentication:
private_key_path: "%env(JWT_PRIVATE_KEY_PATH)%"
public_key_path: "%env(JWT_PUBLIC_KEY_PATH)%"
pass_phrase: "%env(JWT_PASSPHRASE)%"
@@ -0,0 +1,13 @@
{
"bundles": {
"Lexik\\Bundle\\JWTAuthenticationBundle\\LexikJWTAuthenticationBundle": ["all"]
},
"copy-from-recipe": {
"etc/": "%ETC_DIR%"
},
"env": {
"JWT_PRIVATE_KEY_PATH": "%ETC_DIR%/jwt/private.pem",
"JWT_PUBLIC_KEY_PATH": "%ETC_DIR%/jwt/public.pem",
"JWT_PASSPHRASE": "%generate(secret)%"
}
}
@@ -0,0 +1 @@
<bg=blue;fg=white>Now</>, run <comment>make generate-jwt-keys</> to generate a key pair for LexikJWTAuthenticationBundle.