Commit 74f4860
Re-work JWT Validation and Generation to use public/private key and official claims (apache#46981)
Since requests to Task Execution API can originate out-of-"cluser" so to
speak, this PR re-works the JWTSigner class so that it is possible to use
public/private keys (vs just a simple pre-shared secret). This is useful in
many cloud environments where many companies have security requirements that
ingress gateways must validate the JWT tokens on the way in, and the only way
of doing this is with public keys
So that we don't have two different ways of generating JWT tokens I have
totally replaced the old "JWTSigner" class (which it turns out didn't have any
unit test of its own, it was only tested indirectly through test_serve_logs
etc).
As part of this change I have also changed the JWT that was generated by the
SimpleAuthManager and the AwsAuthManager (the only two we have that use JWT)
to use the offical `sub` (subject) clain to place the user identifer rather
than a custom claim name.
And although it might seem slightly strange at first, I have made the
JWTValidator an async class internally. (Hence `avalidated_claims` -- the `a`
prefix signifies async, much like `aclose` or `aread` on HTTPX async
responses). This allows us to periodically refresh the JWK document if
configured in the background, and using asgiref's async_to_sync means we only
have one version.
Co-authored-by: Jens Scheffler <jscheffl@apache.org>1 parent 4b85cb6 commit 74f4860
File tree
34 files changed
+1055
-256
lines changed- airflow
- api_fastapi
- auth
- managers
- simple
- routes
- services
- core_api
- cli/commands/local_commands
- config_templates
- utils
- log
- docs
- kubernetes_tests
- providers
- amazon/src/airflow/providers/amazon/aws/auth_manager
- router
- edge/src/airflow/providers/edge
- cli
- worker_api
- fab
- src/airflow/providers/fab
- auth_manager
- api_fastapi
- routes
- services
- www
- tests/unit/fab/auth_manager
- api_fastapi/services
- tests
- api_fastapi
- auth
- managers
- simple
- core_api
- core
- utils
34 files changed
+1055
-256
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
29 | 36 | | |
30 | 37 | | |
31 | 38 | | |
32 | 39 | | |
33 | | - | |
34 | 40 | | |
35 | 41 | | |
36 | 42 | | |
| |||
86 | 92 | | |
87 | 93 | | |
88 | 94 | | |
89 | | - | |
| 95 | + | |
90 | 96 | | |
91 | | - | |
| 97 | + | |
92 | 98 | | |
93 | 99 | | |
94 | | - | |
| 100 | + | |
95 | 101 | | |
96 | 102 | | |
97 | | - | |
| 103 | + | |
98 | 104 | | |
99 | 105 | | |
100 | | - | |
101 | | - | |
| 106 | + | |
| 107 | + | |
102 | 108 | | |
103 | 109 | | |
104 | | - | |
105 | | - | |
106 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
107 | 113 | | |
108 | 114 | | |
109 | 115 | | |
| |||
450 | 456 | | |
451 | 457 | | |
452 | 458 | | |
453 | | - | |
| 459 | + | |
| 460 | + | |
454 | 461 | | |
455 | | - | |
456 | | - | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
457 | 465 | | |
458 | 466 | | |
459 | 467 | | |
460 | 468 | | |
461 | 469 | | |
462 | 470 | | |
463 | 471 | | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
468 | 490 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
| 142 | + | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
| 145 | + | |
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| |||
0 commit comments