Commit a03bee9
[Core] Migrate to HttpOnly cookie-based authentication for enhanced security (ray-project#58591)
Migrates Ray dashboard authentication from JavaScript-managed cookies to
server-side HttpOnly cookies to enhance security against XSS attacks.
This addresses code review feedback to improve the authentication
implementation (ray-project#58368)
main changes:
- authentication middleware first looks for `Authorization` header, if
not found it then looks at cookies to look for the auth token
- new `api/authenticate` endpoint for verifying token and setting the
auth token cookie (with `HttpOnly=true`, `SameSite=Strict` and
`secure=true` (when using https))
- removed javascript based cookie manipulation utils and axios
interceptors (were previously responsible for setting cookies)
- cookies are deleted when connecting to a cluster with
`AUTH_MODE=disabled`. connecting to a different ray cluster (with
different auth token) using the same endpoint (eg due to port-forwarding
or local testing) will reshow the popup and ask users to input the right
token.
---------
Signed-off-by: sampan <sampan@anyscale.com>
Co-authored-by: sampan <sampan@anyscale.com>1 parent f040088 commit a03bee9
File tree
9 files changed
+172
-257
lines changed- python/ray
- _private/authentication
- dashboard
- client/src
- authentication
- service
9 files changed
+172
-257
lines changedLines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
49 | 62 | | |
50 | 63 | | |
51 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | | - | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | 12 | | |
18 | 13 | | |
19 | 14 | | |
| |||
245 | 240 | | |
246 | 241 | | |
247 | 242 | | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
256 | 246 | | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
| 247 | + | |
262 | 248 | | |
263 | 249 | | |
264 | 250 | | |
| |||
294 | 280 | | |
295 | 281 | | |
296 | 282 | | |
297 | | - | |
298 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
299 | 286 | | |
300 | 287 | | |
301 | | - | |
302 | | - | |
| 288 | + | |
303 | 289 | | |
304 | 290 | | |
305 | 291 | | |
| |||
314 | 300 | | |
315 | 301 | | |
316 | 302 | | |
317 | | - | |
| 303 | + | |
318 | 304 | | |
319 | | - | |
| 305 | + | |
320 | 306 | | |
321 | 307 | | |
322 | 308 | | |
| |||
Lines changed: 16 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
33 | 34 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
| 35 | + | |
| 36 | + | |
41 | 37 | | |
42 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
43 | 41 | | |
44 | | - | |
45 | | - | |
46 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| |||
Lines changed: 0 additions & 107 deletions
This file was deleted.
Lines changed: 0 additions & 78 deletions
This file was deleted.
Lines changed: 3 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
| |||
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | 36 | | |
52 | 37 | | |
53 | 38 | | |
| |||
57 | 42 | | |
58 | 43 | | |
59 | 44 | | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
64 | 49 | | |
65 | 50 | | |
66 | 51 | | |
| |||
0 commit comments