-
Notifications
You must be signed in to change notification settings - Fork 63
Security hardening: session login + CSRF protection + auth robustness (Cloudflare Free compatible) #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
renebell0
wants to merge
6
commits into
TooonyChen:main
from
renebell0:codex/security-session-hardening-upstream-pr
Closed
Security hardening: session login + CSRF protection + auth robustness (Cloudflare Free compatible) #8
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4909267
feat: harden worker security and add cloudflare smoke QA
renebell0 8de80cc
fix: remove unsupported worker limits from free-plan templates
renebell0 467c3f3
feat: ship gmail-style UI with v2 api and production hardening
renebell0 4c21c27
Harden auth with session login, CSRF, and security QA
renebell0 02723e1
Fix login route redirect loop on assets fallback
renebell0 e6e05d6
Address PR review feedback for session auth flow
renebell0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| -- Gmail-like UI state and user settings for AuthInbox | ||
| CREATE TABLE IF NOT EXISTS mail_states ( | ||
| raw_id INTEGER PRIMARY KEY, | ||
| is_read INTEGER NOT NULL DEFAULT 0, | ||
| is_starred INTEGER NOT NULL DEFAULT 0, | ||
| is_archived INTEGER NOT NULL DEFAULT 0, | ||
| is_deleted INTEGER NOT NULL DEFAULT 0, | ||
| is_important INTEGER NOT NULL DEFAULT 0, | ||
| is_muted INTEGER NOT NULL DEFAULT 0, | ||
| category TEXT, | ||
| labels_json TEXT, | ||
| snoozed_until DATETIME, | ||
| updated_at DATETIME DEFAULT CURRENT_TIMESTAMP, | ||
| FOREIGN KEY (raw_id) REFERENCES raw_mails(id) ON DELETE CASCADE | ||
| ); | ||
|
|
||
| CREATE TABLE IF NOT EXISTS ui_settings ( | ||
| id INTEGER PRIMARY KEY CHECK (id = 1), | ||
| density TEXT NOT NULL DEFAULT 'default', | ||
| reading_pane TEXT NOT NULL DEFAULT 'right', | ||
| theme TEXT NOT NULL DEFAULT 'dark', | ||
| shortcuts_enabled INTEGER NOT NULL DEFAULT 1, | ||
| updated_at DATETIME DEFAULT CURRENT_TIMESTAMP | ||
| ); | ||
|
|
||
| INSERT OR IGNORE INTO ui_settings (id, density, reading_pane, theme, shortcuts_enabled) | ||
| VALUES (1, 'default', 'right', 'dark', 1); | ||
|
|
||
| CREATE INDEX IF NOT EXISTS idx_mail_states_archived ON mail_states (is_archived, updated_at DESC); | ||
| CREATE INDEX IF NOT EXISTS idx_mail_states_deleted ON mail_states (is_deleted, updated_at DESC); | ||
| CREATE INDEX IF NOT EXISTS idx_mail_states_read ON mail_states (is_read, updated_at DESC); | ||
| CREATE INDEX IF NOT EXISTS idx_mail_states_starred ON mail_states (is_starred, updated_at DESC); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| -- Session auth and login throttling tables for AuthInbox | ||
| CREATE TABLE IF NOT EXISTS auth_sessions ( | ||
| session_id TEXT PRIMARY KEY, | ||
| username TEXT NOT NULL, | ||
| csrf_token TEXT NOT NULL, | ||
| ip_hash TEXT, | ||
| user_agent_hash TEXT, | ||
| expires_at DATETIME NOT NULL, | ||
| revoked INTEGER NOT NULL DEFAULT 0, | ||
| created_at DATETIME DEFAULT CURRENT_TIMESTAMP, | ||
| last_seen_at DATETIME DEFAULT CURRENT_TIMESTAMP | ||
| ); | ||
|
|
||
| CREATE TABLE IF NOT EXISTS auth_login_attempts ( | ||
| ip_key TEXT PRIMARY KEY, | ||
| attempt_count INTEGER NOT NULL DEFAULT 0, | ||
| blocked_until DATETIME, | ||
| updated_at DATETIME DEFAULT CURRENT_TIMESTAMP | ||
| ); | ||
|
|
||
| CREATE INDEX IF NOT EXISTS idx_auth_sessions_expires ON auth_sessions (expires_at); | ||
| CREATE INDEX IF NOT EXISTS idx_auth_sessions_revoked ON auth_sessions (revoked, expires_at); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked
.github/workflows/main.yml: this step now uploads onlyFrontEndAdminPassword, AI keys, and Bark tokens, but the new session flow insrc/index.tsrequiresSESSION_SIGNING_KEYforAUTH_MODE=sessionandAUTH_MODE=both. On a fresh CI-managed deployment,/auth/loginwill return503and the worker will silently fall back to basic auth because the required secret is never provisioned.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in
e6e05d6. CI now syncsSESSION_SIGNING_KEYviawrangler secret putin the workflow, so fresh deployments support session auth (AUTH_MODE=session|both) without manual secret drift.