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
{{ message }}
This repository was archived by the owner on Aug 7, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+77-3Lines changed: 77 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,9 +7,12 @@
7
7
8
8
## About
9
9
10
-
This bundle provides JWT authentication for request forwarded by Istio sidecar.
10
+
The Symfony bundle provides JWT authentication for request forwarded by Istio sidecar.
11
11
12
-
> To use this bundle, ensure your application container had injected Istio sidecar and Istio [RequestAuthentication](https://istio.io/latest/docs/reference/config/security/request_authentication/) CRD had configured, if not your application **IS NOT SECURE**.
12
+
> To use this bundle, make sure your K8S application pod had injected Istio sidecar and [RequestAuthentication](https://istio.io/latest/docs/reference/config/security/request_authentication/) CRD had configured, if not your application **IS NOT SECURE**.
13
+
14
+
The difference between this bundle and the awesome [Lexik JWT Authentication](https://github.com/lexik/LexikJWTAuthenticationBundle) bundle is it's **NOT** validate JWT token because Istio sidecar proxy had validated before forward request to your application,
15
+
so that your application don't need to hold public key and double validate JWT token.
user_identifier_claim: sub #Default is `sub` claim
59
+
origin_token_headers: [authorization] #Required at least once of `origin_token_headers`, `origin_token_query_params` or `base64_headers`. Use this option when your Istio JWTRule CRD using `forwardOriginalToken`.
60
+
origin_token_query_params: [token] #Use this option when your Istio JWTRule CRD using `forwardOriginalToken` and your JWT token in query param.
61
+
base64_headers: [x-istio-jwt-payload] # Use this option when your Istio JWTRule CRD using `outputPayloadToHeader`.
62
+
```
63
+
64
+
In case your application have multi issuers:
65
+
66
+
```yaml
67
+
#....
68
+
main:
69
+
stateless: true
70
+
istio_jwt_authenticator:
71
+
- issuer: issuer_1
72
+
origin_token_headers: [authorization]
73
+
- issuer: issuer_2
74
+
user_identifier_claim: aud
75
+
base64_headers: [x-istio-jwt-payload]
76
+
#....
77
+
```
78
+
79
+
80
+
## Usages
81
+
82
+
Generate mock JWT token forwarded by Istio sidecar:
In case [stateless user provider](stateless-user-provider.md) not fit to your requirements, you can create your own [custom user provider](https://symfony.com/doc/current/security/user_provider.html#creating-a-custom-user-provider)
This feature inspired by the awesome [Lexik JWT Authentication](https://github.com/lexik/LexikJWTAuthenticationBundle) bundle.
5
+
6
+
Stateless user provider help to create user instances from the JWT payload.
7
+
8
+
Configuring the user provider
9
+
-----------------------------
10
+
11
+
First, you need to config `istio_jwt_stateless` provider in `security.yaml`:
12
+
13
+
```yaml
14
+
# config/packages/security.yaml
15
+
security:
16
+
providers:
17
+
jwt:
18
+
istio_jwt_stateless:
19
+
class: App\Security\User # your user class, you can change it if you want.
20
+
```
21
+
22
+
Then, create a user class `istio_jwt_stateless.class` had set in config, in this case is `App\Security\User`, this class need to implement [StatelessUserInterface](/src/User/StatelessUserInterface.php).
23
+
This interface contains only a `fromPayload(array $payload)` method returns an instance of the class.
24
+
25
+
#### Sample implementation
26
+
27
+
```php
28
+
namespace App\Security;
29
+
30
+
use Istio\Symfony\JWTAuthentication\User\StatelessUserInterface;
31
+
32
+
final class User implements StatelessUserInterface
33
+
{
34
+
//....
35
+
36
+
public static function fromPayload(array $payload): static
0 commit comments