Skip to content

Commit 501c7f4

Browse files
committed
Add LexikJWTAuthenticationBundle for JWT Authentication in Symfony
1 parent 711b975 commit 501c7f4

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
generate-jwt-keys:
2+
ifeq (, $(shell which openssl))
3+
$(error "Unable to generate keys (needs OpenSSL)")
4+
endif
5+
mkdir -p etc/jwt
6+
openssl genrsa -passout pass:${JWT_PASSPHRASE} -out ${JWT_PRIVATE_KEY_PATH} -aes256 4096
7+
openssl rsa -passin pass:${JWT_PASSPHRASE} -pubout -in ${JWT_PRIVATE_KEY_PATH} -out ${JWT_PUBLIC_KEY_PATH}
8+
@echo "\033[32mRSA key pair successfully generated\033[39m"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
lexik_jwt_authentication:
2+
private_key_path: "%env(JWT_PRIVATE_KEY_PATH)%"
3+
public_key_path: "%env(JWT_PUBLIC_KEY_PATH)%"
4+
pass_phrase: "%env(JWT_PASSPHRASE)%"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"bundles": {
3+
"Lexik\\Bundle\\JWTAuthenticationBundle\\LexikJWTAuthenticationBundle": ["all"]
4+
},
5+
"copy-from-recipe": {
6+
"etc/": "%ETC_DIR%"
7+
},
8+
"env": {
9+
"JWT_PRIVATE_KEY_PATH": "%ETC_DIR%/jwt/private.pem",
10+
"JWT_PUBLIC_KEY_PATH": "%ETC_DIR%/jwt/public.pem",
11+
"JWT_PASSPHRASE": "%generate(secret)%"
12+
}
13+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<bg=blue;fg=white> </>
2+
<bg=blue;fg=white> What's next? </>
3+
<bg=blue;fg=white> </>
4+
5+
* <fg=blue>Execute</> the <comment>make generate-jwt-keys</> command to generate your key pair
6+
7+
* <fg=blue>Read</> the documentation at <comment>https://github.com/lexik/LexikJWTAuthenticationBundle#documentation</>

0 commit comments

Comments
 (0)