File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change 11<?php
22return array(
3- 'jwtKey' => '', // Key for signing the JWT's, I suggest generate it with base64_encode(openssl_random_pseudo_bytes(64))
3+ 'jwt' => array(
4+ 'key' => '', // Key for signing the JWT's, I suggest generate it with base64_encode(openssl_random_pseudo_bytes(64))
5+ 'algorithm' => 'HS512' // Algorithm used to sign the token, see https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40#section-3
6+ ),
47 'database' => array(
58 'user' => '', // Database username
69 'password' => '', // Database password
Original file line number Diff line number Diff line change 8686 * keep it secure! You'll need the exact key to verify the
8787 * token later.
8888 */
89- $ secretKey = base64_decode ($ config ->get ('jwtKey ' ));
89+ $ secretKey = base64_decode ($ config ->get ('jwt ' )->get ('key ' ));
90+
91+ /*
92+ * Extract the algorithm from the config file too
93+ */
94+ $ algorithm = $ config ->get ('jwt ' )->get ('algorithm ' );
9095
9196 /*
9297 * Encode the array to a JWT string.
97102 $ jwt = JWT ::encode (
98103 $ data , //Data to be encoded in the JWT
99104 $ secretKey , // The signing key
100- ' HS512 ' // Algorithm used to sign the token, see https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40#section-3
105+ $ algorithm // Algorithm used to sign the token, see https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40#section-3
101106 );
102107
103108 $ unencodedArray = ['jwt ' => $ jwt ];
Original file line number Diff line number Diff line change 3131 /*
3232 * decode the jwt using the key from config
3333 */
34- $ secretKey = base64_decode ($ config ->get ('jwtKey ' ));
34+ $ secretKey = base64_decode ($ config ->get ('jwt ' )-> get ( ' key ' ));
3535
36- $ token = JWT ::decode ($ jwt , $ secretKey , array ( ' HS512 ' ) );
36+ $ token = JWT ::decode ($ jwt , $ secretKey , [ $ config -> get ( ' jwt ' )-> get ( ' algorithm ' )] );
3737
3838 $ asset = base64_encode (file_get_contents ('http://lorempixel.com/200/300/cats/ ' ));
3939
You can’t perform that action at this time.
0 commit comments