Commit 210e562
committed
fix(auth): auto-clear session credentials after 30 minutes of inactivity
Sessions had no expiration: once a username and optional PAT were
entered they remained in React state indefinitely. An unattended browser
tab with a valid PAT stored in state remained exploitable for the entire
browser session.
Add an inactivity timer via useEffect. After 30 minutes without a user
interaction event (mousemove, keydown, click, scroll, touchstart) the
timer fires clearSession(), zeroing both username and token. The timer
resets on every qualifying event so active sessions are not disrupted.
When no username is set the timer is inactive and no listeners are
registered.
Closes #6881 parent 53f820b commit 210e562
1 file changed
Lines changed: 54 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
4 | 10 | | |
5 | 11 | | |
6 | 12 | | |
7 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
8 | 58 | | |
9 | 59 | | |
10 | | - | |
11 | | - | |
| 60 | + | |
| 61 | + | |
12 | 62 | | |
13 | 63 | | |
14 | 64 | | |
| |||
20 | 70 | | |
21 | 71 | | |
22 | 72 | | |
| 73 | + | |
23 | 74 | | |
24 | 75 | | |
25 | 76 | | |
0 commit comments