@@ -202,6 +202,44 @@ $decoded = JWT::decode($jwt, new Key($publicKey, 'EdDSA'));
202
202
echo "Decode:\n" . print_r((array) $decoded, true) . "\n";
203
203
````
204
204
205
+ Example with multiple keys
206
+ --------------------------
207
+ ```php
208
+ use Firebase\JWT\JWT;
209
+ use Firebase\JWT\Key;
210
+
211
+ // Example RSA keys from previous example
212
+ // $privateKey1 = '...';
213
+ // $publicKey1 = '...';
214
+
215
+ // Example EdDSA keys from previous example
216
+ // $privateKey2 = '...';
217
+ // $publicKey2 = '...';
218
+
219
+ $payload = [
220
+ 'iss' => 'example.org',
221
+ 'aud' => 'example.com',
222
+ 'iat' => 1356999524,
223
+ 'nbf' => 1357000000
224
+ ];
225
+
226
+ $jwt1 = JWT::encode($payload, $privateKey1, 'RS256', 'kid1');
227
+ $jwt2 = JWT::encode($payload, $privateKey2, 'EdDSA', 'kid2');
228
+ echo "Encode 1:\n" . print_r($jwt1, true) . "\n";
229
+ echo "Encode 2:\n" . print_r($jwt2, true) . "\n";
230
+
231
+ $keys = [
232
+ 'kid1' => new Key($publicKey1, 'RS256'),
233
+ 'kid2' => new Key($publicKey2, 'EdDSA'),
234
+ ];
235
+
236
+ $decoded1 = JWT::decode($jwt1, $keys);
237
+ $decoded2 = JWT::decode($jwt2, $keys);
238
+
239
+ echo "Decode 1:\n" . print_r((array) $decoded1, true) . "\n";
240
+ echo "Decode 2:\n" . print_r((array) $decoded2, true) . "\n";
241
+ ```
242
+
205
243
Using JWKs
206
244
----------
207
245
0 commit comments