Commit 7bcd97e
committed
oauth2: add allowed_redirect_domains and original_request_uri
Adds two new fields to the OAuth2 filter config:
* `original_request_uri`: an optional formatter-supported base URI used to
build the original request URL that is encoded into the OAuth2 `state`
parameter. Useful when Envoy sits behind a gateway that terminates the
user-facing hostname, so the post-authentication redirect uses the public
host rather than Envoy's internal `:authority`.
* `allowed_redirect_domains`: an optional case-insensitive allow-list
(exact match or `*.` wildcard) applied to the host of the formatted
`redirect_uri`, the formatted `original_request_uri`, and the URL decoded
from the `state` parameter on callback. Mitigates open-redirect attacks
via injected `x-forwarded-host` headers or forged `state` values. Empty
list (default) disables the check for backward compatibility.
The formatted `redirect_uri` and `original_request_uri` are now also
required to be parseable absolute URLs: an unparseable template output is
rejected with 401 rather than silently passing through the allow-list.
Authority parsing uses `Http::Utility::parseAuthority` so IPv6 literals
are handled consistently.
Signed-off-by: Mohammed Shetaya <mohammed.shetaya@procore.com>1 parent 70765d7 commit 7bcd97e
5 files changed
Lines changed: 560 additions & 5 deletions
File tree
- api/envoy/extensions/filters/http/oauth2/v3
- changelogs
- source/extensions/filters/http/oauth2
- test/extensions/filters/http/oauth2
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | | - | |
| 154 | + | |
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| |||
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
307 | 345 | | |
308 | 346 | | |
309 | 347 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
21 | 38 | | |
22 | 39 | | |
23 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
305 | 333 | | |
306 | 334 | | |
307 | 335 | | |
| |||
456 | 484 | | |
457 | 485 | | |
458 | 486 | | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
459 | 490 | | |
460 | 491 | | |
461 | 492 | | |
| |||
950 | 981 | | |
951 | 982 | | |
952 | 983 | | |
953 | | - | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
954 | 1023 | | |
955 | 1024 | | |
956 | 1025 | | |
| |||
984 | 1053 | | |
985 | 1054 | | |
986 | 1055 | | |
987 | | - | |
988 | | - | |
989 | | - | |
990 | 1056 | | |
991 | 1057 | | |
992 | 1058 | | |
| |||
1598 | 1664 | | |
1599 | 1665 | | |
1600 | 1666 | | |
| 1667 | + | |
| 1668 | + | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
1601 | 1674 | | |
1602 | 1675 | | |
1603 | 1676 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
177 | 181 | | |
178 | 182 | | |
179 | 183 | | |
| |||
245 | 249 | | |
246 | 250 | | |
247 | 251 | | |
| 252 | + | |
| 253 | + | |
248 | 254 | | |
249 | 255 | | |
250 | 256 | | |
| |||
0 commit comments