Skip to content

Commit e8614b8

Browse files
authored
feat: extend LAN session cookie lifetime to 30 days (#326)
1 parent 8d99cfe commit e8614b8

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ Run the server on any always-on machine and access the dashboard from your phone
225225
cargo run -p tuitbot-server -- --host 0.0.0.0
226226
```
227227

228-
The server prints a 4-word passphrase to the terminal on first start. Open `http://<server-ip>:3001` from any device on your network and enter the passphrase to log in. Sessions last 7 days. Full setup guide: [LAN Mode](https://aramirez087.github.io/TuitBot/lan-mode/).
228+
The server prints a 4-word passphrase to the terminal on first start. Open `http://<server-ip>:3001` from any device on your network and enter the passphrase to log in. Sessions last 30 days. Full setup guide: [LAN Mode](https://aramirez087.github.io/TuitBot/lan-mode/).
229229

230230
### 3. Self-Hosted Docker
231231

crates/tuitbot-core/src/auth/session.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use sha2::{Digest, Sha256};
1111
use super::error::AuthError;
1212
use crate::storage::DbPool;
1313

14-
/// Session lifetime: 7 days.
15-
const SESSION_LIFETIME_DAYS: i64 = 7;
14+
/// Session lifetime: 30 days.
15+
pub const SESSION_LIFETIME_DAYS: i64 = 30;
1616

1717
/// A session record as stored in the database.
1818
#[derive(Debug)]

crates/tuitbot-server/src/auth/routes.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,9 @@ pub async fn login(
168168
match session::create_session(&state.db).await {
169169
Ok(new_session) => {
170170
let cookie = format!(
171-
"tuitbot_session={}; HttpOnly; SameSite=Strict; Path=/; Max-Age=604800",
171+
"tuitbot_session={}; HttpOnly; SameSite=Strict; Path=/; Max-Age={}",
172172
new_session.raw_token,
173+
session::SESSION_LIFETIME_DAYS * 24 * 60 * 60,
173174
);
174175

175176
let response = LoginResponse {

crates/tuitbot-server/src/routes/settings/handlers.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,9 @@ pub async fn init_settings(
237237
.map_err(|e| ApiError::Internal(format!("failed to create session: {e}")))?;
238238

239239
let cookie = format!(
240-
"tuitbot_session={}; HttpOnly; SameSite=Strict; Path=/; Max-Age=604800",
240+
"tuitbot_session={}; HttpOnly; SameSite=Strict; Path=/; Max-Age={}",
241241
new_session.raw_token,
242+
session::SESSION_LIFETIME_DAYS * 24 * 60 * 60,
242243
);
243244

244245
tracing::info!("instance claimed via /settings/init");

docs/lan-mode.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ Tuitbot has two authentication strategies that coexist:
4545
| Mode | Who uses it | How it works |
4646
|------|------------|--------------|
4747
| **Bearer token** | Tauri desktop app, dev mode, API/MCP clients | Reads `~/.tuitbot/api_token` file, sends as `Authorization: Bearer` header |
48-
| **Session cookie** | Web browsers over LAN | Enter passphrase once, server sets an `HttpOnly` cookie valid for 7 days |
48+
| **Session cookie** | Web browsers over LAN | Enter passphrase once, server sets an `HttpOnly` cookie valid for 30 days |
4949

50-
When you open the dashboard in a browser without a bearer token on a fresh install, you're directed to the onboarding wizard. At the end of setup, you'll create a passphrase that protects future browser sessions. A session cookie is set automatically, so you're logged in immediately after onboarding. On subsequent visits, if your session has expired, you'll see a login screen where you enter the same passphrase. Sessions last 7 days.
50+
When you open the dashboard in a browser without a bearer token on a fresh install, you're directed to the onboarding wizard. At the end of setup, you'll create a passphrase that protects future browser sessions. A session cookie is set automatically, so you're logged in immediately after onboarding. On subsequent visits, if your session has expired, you'll see a login screen where you enter the same passphrase. Sessions last 30 days.
5151

5252
## CLI Flags
5353

@@ -187,7 +187,7 @@ Drive connector flow instead of a local file picker.
187187
- Or from Settings → LAN Access → Reset Passphrase (requires an active session)
188188

189189
**Session expired / redirected to login**
190-
- Sessions last 7 days. Log in again with the same passphrase
190+
- Sessions last 30 days. Log in again with the same passphrase
191191
- If the server was restarted, existing sessions remain valid (they're stored in the database)
192192

193193
**WebSocket not connecting in browser**

0 commit comments

Comments
 (0)