Skip to content

Commit 0a6df27

Browse files
matej21claude
andcommitted
fix: reduce token TTL to 14 days with 3-day refresh threshold
The previous 30-day TTL with 14-day refresh threshold left a narrow window for refresh and kept stolen tokens valid for too long. New values: 14-day TTL with 3-day refresh — active clients refresh early and live indefinitely, inactive clients survive up to 2 weeks. Supersedes #80 which proposed 24h TTL (too aggressive for paired desktops that may be unused for a week). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 81e4863 commit 0a6df27

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

crates/okena-core/src/client/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ pub enum ConnectionEvent {
8585
},
8686
}
8787

88-
/// Token age threshold for refresh (14 days).
89-
pub const TOKEN_REFRESH_AGE_SECS: i64 = 14 * 24 * 3600;
88+
/// Token age threshold for refresh (3 days). Must be well under the 14-day server TTL.
89+
pub const TOKEN_REFRESH_AGE_SECS: i64 = 3 * 24 * 3600;
9090

9191
#[cfg(test)]
9292
mod tests {

crates/okena-remote-client/src/manager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ impl RemoteConnectionManager {
362362
}
363363

364364
/// Start a periodic token refresh task.
365-
/// Checks every 10 minutes and refreshes tokens older than 20 hours.
365+
/// Checks every 10 minutes and refreshes tokens older than 3 days.
366366
pub fn start_token_refresh_task(&self, cx: &mut Context<Self>) {
367367
let event_tx = self.event_tx.clone();
368368
let runtime = self.runtime.clone();

src/remote/auth.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use std::time::{Duration, Instant, SystemTime};
1111

1212
type HmacSha256 = Hmac<Sha256>;
1313

14-
/// Token time-to-live in seconds (30 days).
15-
pub const TOKEN_TTL_SECS: u64 = 30 * 24 * 3600;
14+
/// Token time-to-live in seconds (14 days).
15+
pub const TOKEN_TTL_SECS: u64 = 14 * 24 * 3600;
1616

1717
/// A stored token record.
1818
#[allow(dead_code)]

0 commit comments

Comments
 (0)