You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/upgrading.md
+111Lines changed: 111 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,33 @@ We're building on the version `v3.4.0` a forward compatibility layer to help use
10
10
To help on the migration process, all deprecated components are being marked with `@deprecated` and deprecated behaviour will trigger a `E_USER_DEPRECATED` error.
11
11
However, you can also find here the instructions on how to make your code compatible with both versions.
12
12
13
+
### General migration strategy
14
+
15
+
Update your existing software to the latest 3.4.x version using composer:
16
+
17
+
```sh
18
+
composer require lcobucci/jwt ^3.4
19
+
```
20
+
21
+
Then run your tests and fix all deprecation notices.
22
+
Also change all calls to deprecated methods, even if they are not triggering any notices.
23
+
Tools like [`phpstan/phpstan-deprecation-rules`](https://github.com/phpstan/phpstan-deprecation-rules) can help finding them.
24
+
25
+
Note that PHPUnit tests will only fail if you have the `E_USER_DEPRECATED` error level activated - it is a good practice to run tests using `E_ALL`.
26
+
Data providers that trigger deprecation messages will not fail tests at all, only print the message to the console.
27
+
Make sure you do not see any of them before you continue.
28
+
29
+
Now you can upgrade to the latest 4.x version:
30
+
31
+
```sh
32
+
composer require lcobucci/jwt ^4.0
33
+
```
34
+
35
+
Remember that some deprecation messages from the 3.4 version may have notified you that things still are different in 4.0, so you may find you need to adapt your own code once more at this stage.
36
+
37
+
While you are at it, consider using the new configuration object.
38
+
The details are listed below.
39
+
13
40
### Inject the configuration object instead of builder/parser/key
14
41
15
42
This object serves as a small service locator that centralises the JWT-related dependencies.
Even though we didn't officially support multiple audiences, it was technically possible to achieve that by manually setting the `aud` claim to an array with multiple strings.
184
+
185
+
If you parse a token with 3.4, and read its contents with `\Lcobucci\JWT\Token#getClaim()` or`\Lcobucci\JWT\Token#getClaims()`, you will only get the first element of such an array back.
186
+
If the audience claim does only contain a string, or only contains one string in the array, nothing changes.
187
+
Please [upgrade to the new Token API](#use-the-new-token-api) for accessing claims in order to get the full audience array again (e.g. call `Token#claims()->get('aud')`).
188
+
189
+
When creating a token, use the new method `Builder#permittedFor()` as detailed below.
0 commit comments