feat: Auto-lock session after inactivity timeout#44
Merged
patchmemory merged 7 commits intomainfrom Feb 8, 2026
Merged
Conversation
Refactored the large index.html file (2848 lines) by extracting 7 settings
sections into self-contained partial templates:
**New partial templates in settings/ directory:**
- _general.html (989 lines): System info, config export/import, security,
user management, audit log with 4 JS init functions
- _neo4j.html (177 lines): Neo4j connection settings with connection
management JS
- _chat.html (265 lines): LLM provider configuration with initChatSettings
- _interpreters.html (118 lines): Interpreter mappings and toggles with
dynamic table
- _plugins.html (8 lines): Plugin registry summary
- _rclone.html (146 lines): Rclone interpretation and mount management with JS
- _integrations.html (1015 lines): API endpoints, table formats, fuzzy
matching with 3 JS init functions
**Main index.html changes:**
- Reduced from 2848 to 141 lines (95% reduction)
- Now uses {% include %} directives to compose sections
- Keeps only shared CSS and tab navigation JavaScript
- All section-specific JS moved into respective partials
**Cleanup:**
- Deleted obsolete settings.html file (2067 lines)
- /settings route already redirects to / (landing page)
**Tests:**
- All pytest tests pass (25/25)
- Added TODO placeholders in E2E tests for future updates
**Benefits:**
- Easier to find and edit specific settings sections
- Reduced merge conflicts
- Each partial is self-contained with HTML + JS
- Maintained identical functionality and appearance
Related: task:ui/settings/modularization
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Adds comprehensive session locking functionality with: - Server-side session lock/unlock API endpoints - Client-side activity monitoring with configurable timeouts - Lock screen overlay with password verification - Auto-lock settings in Security section (1-120 minutes) - Session lock state tracking in auth_sessions table - Audit logging for lock/unlock events - Failed unlock attempt tracking - Middleware integration (returns 423 when locked) Backend changes: - Add locked/locked_at columns to auth_sessions table - Add lock_session(), unlock_session(), is_session_locked() methods - Add get_session_lock_info() for retrieving lock state - Add migration for existing databases - Add /api/auth/lock and /api/auth/unlock endpoints - Add /api/settings/security/auto-lock GET/POST endpoints - Update auth middleware to check session lock state Frontend changes: - Add ActivityMonitor JavaScript class in base.html - Track mouse, keyboard, scroll, touch activity - Auto-lock session after configured inactivity period - Show lock screen overlay with username and lock time - Password-only unlock (no username required) - Auto-load lock screen if session already locked - Add auto-lock enable/disable toggle in Settings - Add timeout configuration (1-120 minutes) Testing: - 12 unit tests covering lock/unlock functionality - Test session locking and unlocking - Test password verification - Test audit logging - Test settings storage - All tests passing Acceptance criteria met: ✅ User can enable auto-lock in Settings > General > Security ✅ User can configure inactivity timeout (1-120 minutes) ✅ After configured inactivity, session is locked ✅ Locked session shows lock screen with password prompt ✅ User can unlock with password (no username required) ✅ Activity tracking includes mouse/keyboard/scroll/touch ✅ Lock screen shows username and time of lock ✅ Failed unlock attempts logged for security ✅ Unit tests verify functionality 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Resolved conflicts in: - scidk/ui/templates/settings/_general.html (kept auto-lock features) - dev submodule (updated to latest)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Implements task:security/auth/auto-lock-inactivity (RICE: 18) - comprehensive session auto-lock functionality with configurable inactivity timeouts.
Features Implemented
Backend
lockedandlocked_atcolumns toauth_sessionstablePOST /api/auth/lock- Lock current sessionPOST /api/auth/unlock- Unlock with password verificationGET /api/settings/security/auto-lock- Get auto-lock configurationPOST /api/settings/security/auto-lock- Save auto-lock configurationlock_session(token)- Lock a sessionunlock_session(token, password)- Unlock with password validationis_session_locked(token)- Check if session is lockedget_session_lock_info(token)- Get lock state and metadataFrontend
Testing
Unit Tests (12 passing)
All tests passing:
pytest tests/test_auto_lock.py -vAcceptance Criteria
✅ User can enable auto-lock in Settings > General > Security
✅ User can configure inactivity timeout (1-120 minutes)
✅ After configured inactivity period, session is locked
✅ Locked session shows lock screen overlay requiring password
✅ User can unlock with password (no username required)
✅ Activity tracking includes mouse moves, clicks, keyboard input, API calls
✅ Lock screen shows username and time of lock
✅ Failed unlock attempts logged for security
✅ Unit tests verify functionality
Demo Steps
Files Changed
scidk/core/auth.py- Session lock/unlock methods and database migrationscidk/web/routes/api_auth.py- Lock/unlock API endpointsscidk/web/routes/api_settings.py- Auto-lock settings endpointsscidk/web/auth_middleware.py- Session lock checkingscidk/ui/templates/base.html- Activity monitor and lock screen UIscidk/ui/templates/settings/_general.html- Auto-lock settings controlstests/test_auto_lock.py- Comprehensive unit tests (12 tests)Related Tasks
🤖 Generated with Claude Code