feat: Implement Phase 4 Web Interface with bugfixes (v0.5.2)
## Phase 4: Web Interface Implementation Implemented complete web interface with public and admin routes, templates, CSS, and development authentication. ### Core Features **Public Routes**: - Homepage with recent published notes - Note permalinks with microformats2 - Server-side rendering (Jinja2) **Admin Routes**: - Login via IndieLogin - Dashboard with note management - Create, edit, delete notes - Protected with @require_auth decorator **Development Authentication**: - Dev login bypass for local testing (DEV_MODE only) - Security safeguards per ADR-011 - Returns 404 when disabled **Templates & Frontend**: - Base layouts (public + admin) - 8 HTML templates with microformats2 - Custom responsive CSS (114 lines) - Error pages (404, 500) ### Bugfixes (v0.5.1 → v0.5.2) 1. **Cookie collision fix (v0.5.1)**: - Renamed auth cookie from "session" to "starpunk_session" - Fixed redirect loop between dev login and admin dashboard - Flask's session cookie no longer conflicts with auth 2. **HTTP 404 error handling (v0.5.1)**: - Update route now returns 404 for nonexistent notes - Delete route now returns 404 for nonexistent notes - Follows ADR-012 HTTP Error Handling Policy - Pattern consistency across all admin routes 3. **Note model enhancement (v0.5.2)**: - Exposed deleted_at field from database schema - Enables soft deletion verification in tests - Follows ADR-013 transparency principle ### Architecture **New ADRs**: - ADR-011: Development Authentication Mechanism - ADR-012: HTTP Error Handling Policy - ADR-013: Expose deleted_at Field in Note Model **Standards Compliance**: - Uses uv for Python environment - Black formatted, Flake8 clean - Follows git branching strategy - Version incremented per versioning strategy ### Test Results - 405/406 tests passing (99.75%) - 87% code coverage - All security tests passing - Manual testing confirmed working ### Documentation - Complete implementation reports in docs/reports/ - Architecture reviews in docs/reviews/ - Design documents in docs/design/ - CHANGELOG updated for v0.5.2 ### Files Changed **New Modules**: - starpunk/dev_auth.py - starpunk/routes/ (public, admin, auth, dev_auth) **Templates**: 10 files (base, pages, admin, errors) **Static**: CSS and optional JavaScript **Tests**: 4 test files for routes and templates **Docs**: 20+ architectural and implementation documents 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2,11 +2,51 @@
|
||||
|
||||
## Overview
|
||||
|
||||
This document provides a comprehensive, dependency-ordered implementation plan for StarPunk V1, taking the project from its current state (basic infrastructure complete) to a fully functional IndieWeb CMS.
|
||||
This document provides a comprehensive, dependency-ordered implementation plan for StarPunk V1, taking the project from its current state to a fully functional IndieWeb CMS.
|
||||
|
||||
**Current State**: Core infrastructure complete (database schema, config, basic Flask app)
|
||||
**Current State**: Phase 3 Complete - Authentication module implemented (v0.4.0)
|
||||
**Current Version**: 0.4.0
|
||||
**Target State**: Working V1 with all features implemented, tested, and documented
|
||||
**Estimated Total Effort**: ~40-60 hours of focused development
|
||||
**Completed Effort**: ~20 hours (Phases 1-3)
|
||||
**Remaining Effort**: ~20-40 hours (Phases 4-10)
|
||||
|
||||
## Progress Summary
|
||||
|
||||
**Last Updated**: 2025-11-18
|
||||
|
||||
### Completed Phases ✅
|
||||
|
||||
| Phase | Status | Version | Test Coverage | Report |
|
||||
|-------|--------|---------|---------------|--------|
|
||||
| 1.1 - Core Utilities | ✅ Complete | 0.1.0 | >90% | N/A |
|
||||
| 1.2 - Data Models | ✅ Complete | 0.1.0 | >90% | N/A |
|
||||
| 2.1 - Notes Management | ✅ Complete | 0.3.0 | 86% (85 tests) | [Phase 2.1 Report](/home/phil/Projects/starpunk/docs/reports/phase-2.1-implementation-20251118.md) |
|
||||
| 3.1 - Authentication | ✅ Complete | 0.4.0 | 96% (37 tests) | [Phase 3 Report](/home/phil/Projects/starpunk/docs/reports/phase-3-authentication-20251118.md) |
|
||||
|
||||
### Current Phase 🔵
|
||||
|
||||
**Phase 4**: Web Routes and Templates (v0.5.0 target)
|
||||
- **Status**: Design complete, ready for implementation
|
||||
- **Design Docs**: phase-4-web-interface.md, phase-4-architectural-assessment-20251118.md
|
||||
- **New ADR**: ADR-011 (Development Authentication Mechanism)
|
||||
- **Progress**: 0% (not started)
|
||||
|
||||
### Remaining Phases ⏳
|
||||
|
||||
| Phase | Estimated Effort | Priority |
|
||||
|-------|-----------------|----------|
|
||||
| 4 - Web Interface | 34 hours | HIGH |
|
||||
| 5 - RSS Feed | 4-5 hours | HIGH |
|
||||
| 6 - Micropub | 9-12 hours | HIGH |
|
||||
| 7 - API Routes | 3-4 hours | MEDIUM (optional) |
|
||||
| 8 - Testing & QA | 9-12 hours | HIGH |
|
||||
| 9 - Documentation | 5-7 hours | HIGH |
|
||||
| 10 - Release Prep | 3-5 hours | CRITICAL |
|
||||
|
||||
**Overall Progress**: ~33% complete (Phases 1-3 done, 7 phases remaining)
|
||||
|
||||
---
|
||||
|
||||
## Implementation Strategy
|
||||
|
||||
@@ -23,67 +63,79 @@ These utilities are used by all other features. Must be implemented first.
|
||||
|
||||
### 1.1 Utility Functions (`starpunk/utils.py`)
|
||||
|
||||
**Status**: ✅ COMPLETE
|
||||
**Priority**: CRITICAL - Required by all other features
|
||||
**Estimated Effort**: 2-3 hours
|
||||
**Actual Effort**: ~2 hours
|
||||
**Completed**: 2025-11-18
|
||||
**Dependencies**: None
|
||||
|
||||
- [ ] Implement slug generation function
|
||||
- [x] Implement slug generation function
|
||||
- Extract first 5 words from content
|
||||
- Normalize to lowercase with hyphens
|
||||
- Remove special characters, preserve alphanumeric + hyphens
|
||||
- Fallback to timestamp-based slug if content too short
|
||||
- Check uniqueness against database
|
||||
- Add random suffix if slug exists
|
||||
- **References**: ADR-004 (File-Based Storage), project-structure.md
|
||||
- **Acceptance Criteria**: Generates valid, unique, URL-safe slugs
|
||||
- **References**: ADR-004 (File-Based Storage), ADR-007 (Slug Generation)
|
||||
- **Acceptance Criteria**: ✅ Generates valid, unique, URL-safe slugs
|
||||
|
||||
- [ ] Implement content hash calculation
|
||||
- [x] Implement content hash calculation
|
||||
- Use SHA-256 algorithm
|
||||
- Return hex digest string
|
||||
- Handle UTF-8 encoding properly
|
||||
- **Acceptance Criteria**: Consistent hashes for same content
|
||||
- **Acceptance Criteria**: ✅ Consistent hashes for same content
|
||||
|
||||
- [ ] Implement file path helpers
|
||||
- [x] Implement file path helpers
|
||||
- Generate year/month directory structure from timestamp
|
||||
- Build file paths: `data/notes/YYYY/MM/slug.md`
|
||||
- Validate paths (prevent directory traversal)
|
||||
- Ensure paths stay within DATA_PATH
|
||||
- **References**: ADR-004, architecture/security.md
|
||||
- **Acceptance Criteria**: Safe path generation and validation
|
||||
- **Acceptance Criteria**: ✅ Safe path generation and validation
|
||||
|
||||
- [ ] Implement atomic file operations
|
||||
- [x] Implement atomic file operations
|
||||
- Write to temp file first (`.tmp` suffix)
|
||||
- Atomic rename to final destination
|
||||
- Handle errors with rollback
|
||||
- Create parent directories if needed
|
||||
- **References**: ADR-004
|
||||
- **Acceptance Criteria**: Files written safely without corruption risk
|
||||
- **Acceptance Criteria**: ✅ Files written safely without corruption risk
|
||||
|
||||
- [ ] Implement date/time utilities
|
||||
- [x] Implement date/time utilities
|
||||
- RFC-822 date formatting (for RSS)
|
||||
- ISO 8601 formatting (for timestamps)
|
||||
- Timezone handling (UTC)
|
||||
- **Acceptance Criteria**: Correct date formatting for all use cases
|
||||
- **Acceptance Criteria**: ✅ Correct date formatting for all use cases
|
||||
|
||||
- [ ] Write comprehensive tests (`tests/test_utils.py`)
|
||||
- [x] Implement URL validation utility (`is_valid_url()`)
|
||||
- Added in Phase 3 for authentication
|
||||
- Validates HTTP/HTTPS URLs
|
||||
- **Acceptance Criteria**: ✅ Validates URLs correctly
|
||||
|
||||
- [x] Write comprehensive tests (`tests/test_utils.py`)
|
||||
- Test slug generation with various inputs
|
||||
- Test uniqueness enforcement
|
||||
- Test content hash consistency
|
||||
- Test path validation (including security tests)
|
||||
- Test atomic file operations
|
||||
- Test date formatting
|
||||
- **Result**: ✅ All tests passing with excellent coverage
|
||||
|
||||
**Completion Criteria**: All utility functions implemented and tested with >90% coverage
|
||||
**Completion Criteria**: ✅ All utility functions implemented and tested with >90% coverage
|
||||
|
||||
---
|
||||
|
||||
### 1.2 Data Models (`starpunk/models.py`)
|
||||
|
||||
**Status**: ✅ COMPLETE
|
||||
**Priority**: CRITICAL - Used by all feature modules
|
||||
**Estimated Effort**: 3-4 hours
|
||||
**Actual Effort**: ~3 hours
|
||||
**Completed**: 2025-11-18
|
||||
**Dependencies**: `utils.py`
|
||||
|
||||
- [ ] Implement `Note` model class
|
||||
- [x] Implement `Note` model class
|
||||
- Properties: id, slug, file_path, published, created_at, updated_at, content_hash
|
||||
- Method: `from_row()` - Create Note from database row
|
||||
- Method: `to_dict()` - Serialize to dictionary
|
||||
@@ -91,39 +143,42 @@ These utilities are used by all other features. Must be implemented first.
|
||||
- Property: `html` - Render markdown to HTML (cached)
|
||||
- Method: `permalink()` - Generate public URL
|
||||
- **References**: ADR-004, architecture/overview.md
|
||||
- **Acceptance Criteria**: Clean interface for note data access
|
||||
- **Acceptance Criteria**: ✅ Clean interface for note data access
|
||||
|
||||
- [ ] Implement `Session` model class
|
||||
- Properties: id, session_token, me, created_at, expires_at, last_used_at
|
||||
- [x] Implement `Session` model class
|
||||
- Properties: id, session_token_hash, me, created_at, expires_at, last_used_at, user_agent, ip_address
|
||||
- Method: `from_row()` - Create Session from database row
|
||||
- Property: `is_expired` - Check if session expired
|
||||
- Method: `is_valid()` - Comprehensive validation
|
||||
- **References**: ADR-005
|
||||
- **Acceptance Criteria**: Session validation works correctly
|
||||
- **References**: ADR-005, ADR-010
|
||||
- **Note**: Uses token hash instead of plaintext for security
|
||||
- **Acceptance Criteria**: ✅ Session validation works correctly
|
||||
|
||||
- [ ] Implement `Token` model class (Micropub)
|
||||
- [x] Implement `Token` model class (Micropub)
|
||||
- Properties: token, me, client_id, scope, created_at, expires_at
|
||||
- Method: `from_row()` - Create Token from database row
|
||||
- Property: `is_expired` - Check if token expired
|
||||
- Method: `has_scope()` - Check if token has required scope
|
||||
- **References**: Micropub spec
|
||||
- **Acceptance Criteria**: Token scope checking works
|
||||
- **Note**: Ready for Phase 6 implementation
|
||||
- **Acceptance Criteria**: ✅ Token scope checking works
|
||||
|
||||
- [ ] Implement `AuthState` model class
|
||||
- Properties: state, created_at, expires_at
|
||||
- [x] Implement `AuthState` model class
|
||||
- Properties: state, created_at, expires_at, redirect_uri
|
||||
- Method: `from_row()` - Create AuthState from database row
|
||||
- Property: `is_expired` - Check if state expired
|
||||
- **References**: ADR-005
|
||||
- **Acceptance Criteria**: State token validation works
|
||||
- **References**: ADR-005, ADR-010
|
||||
- **Acceptance Criteria**: ✅ State token validation works
|
||||
|
||||
- [ ] Write model tests (`tests/test_models.py`)
|
||||
- [x] Write model tests (`tests/test_models.py`)
|
||||
- Test all model creation methods
|
||||
- Test property access
|
||||
- Test expiration logic
|
||||
- Test serialization/deserialization
|
||||
- Test edge cases (None values, invalid data)
|
||||
- **Result**: ✅ All tests passing with excellent coverage
|
||||
|
||||
**Completion Criteria**: All models implemented with clean interfaces and full test coverage
|
||||
**Completion Criteria**: ✅ All models implemented with clean interfaces and full test coverage
|
||||
|
||||
---
|
||||
|
||||
@@ -133,11 +188,15 @@ This is the heart of the application. File operations + database sync.
|
||||
|
||||
### 2.1 Notes Module (`starpunk/notes.py`)
|
||||
|
||||
**Status**: ✅ COMPLETE
|
||||
**Priority**: CRITICAL - Core functionality
|
||||
**Estimated Effort**: 6-8 hours
|
||||
**Actual Effort**: ~6 hours
|
||||
**Completed**: 2025-11-18
|
||||
**Dependencies**: `utils.py`, `models.py`, `database.py`
|
||||
**Test Coverage**: 86% (85 tests passing)
|
||||
|
||||
- [ ] Implement `create_note()` function
|
||||
- [x] Implement `create_note()` function
|
||||
- Accept: content (markdown), published (boolean), created_at (optional)
|
||||
- Generate unique slug using utils
|
||||
- Determine file path (year/month from timestamp)
|
||||
@@ -148,10 +207,10 @@ This is the heart of the application. File operations + database sync.
|
||||
- Insert note record with metadata
|
||||
- If DB insert fails: delete file, raise error
|
||||
- If successful: commit transaction, return Note object
|
||||
- **References**: ADR-004, architecture/data-flow.md
|
||||
- **Acceptance Criteria**: Note created with file + database entry in sync
|
||||
- **References**: ADR-004, docs/reports/phase-2.1-implementation-20251118.md
|
||||
- **Acceptance Criteria**: ✅ Note created with file + database entry in sync
|
||||
|
||||
- [ ] Implement `get_note()` function
|
||||
- [x] Implement `get_note()` function
|
||||
- Accept: slug (string) or id (int)
|
||||
- Query database for note metadata
|
||||
- If not found: return None
|
||||
@@ -159,52 +218,61 @@ This is the heart of the application. File operations + database sync.
|
||||
- Verify content hash (optional, log if mismatch)
|
||||
- Return Note object with content loaded
|
||||
- **References**: ADR-004
|
||||
- **Acceptance Criteria**: Note retrieved with content from file
|
||||
- **Acceptance Criteria**: ✅ Note retrieved with content from file
|
||||
|
||||
- [ ] Implement `list_notes()` function
|
||||
- [x] Implement `list_notes()` function
|
||||
- Accept: published_only (boolean), limit (int), offset (int)
|
||||
- Query database with filters and sorting (created_at DESC)
|
||||
- Return list of Note objects (metadata only, no content)
|
||||
- Support pagination
|
||||
- SQL injection prevention (validated order_by field)
|
||||
- **References**: ADR-004
|
||||
- **Acceptance Criteria**: Efficient listing with proper filtering
|
||||
- **Acceptance Criteria**: ✅ Efficient listing with proper filtering
|
||||
|
||||
- [ ] Implement `update_note()` function
|
||||
- [x] Implement `update_note()` function
|
||||
- Accept: slug or id, new content, published status
|
||||
- Query database for existing note
|
||||
- Create backup of original file (optional)
|
||||
- Write new content to file atomically
|
||||
- Calculate new content hash
|
||||
- Update database record (updated_at, content_hash, published)
|
||||
- If DB update fails: restore backup, raise error
|
||||
- Return updated Note object
|
||||
- **References**: ADR-004
|
||||
- **Acceptance Criteria**: Note updated safely with sync maintained
|
||||
- **Acceptance Criteria**: ✅ Note updated safely with sync maintained
|
||||
|
||||
- [ ] Implement `delete_note()` function
|
||||
- [x] Implement `delete_note()` function
|
||||
- Accept: slug or id, hard_delete (boolean, default False)
|
||||
- Query database for note
|
||||
- If soft delete: update deleted_at timestamp, optionally move file to .trash/
|
||||
- If hard delete: delete database record, delete file
|
||||
- Idempotent operation (safe to call multiple times)
|
||||
- **References**: ADR-004
|
||||
- **Acceptance Criteria**: Note deleted (soft or hard) correctly
|
||||
- **Acceptance Criteria**: ✅ Note deleted (soft or hard) correctly
|
||||
|
||||
- [ ] Implement `search_notes()` function (optional for V1)
|
||||
- Accept: query string
|
||||
- Search file content using grep or Python search
|
||||
- Return matching Note objects
|
||||
- **Priority**: LOW - Can defer to V2
|
||||
- **Acceptance Criteria**: Basic text search works
|
||||
- **Priority**: LOW - Deferred to V2
|
||||
- **Status**: Not implemented in Phase 2.1
|
||||
- **Acceptance Criteria**: N/A - Deferred
|
||||
|
||||
- [ ] Handle edge cases
|
||||
- [x] Handle edge cases
|
||||
- Orphaned files (file exists, no DB record)
|
||||
- Orphaned records (DB record exists, no file)
|
||||
- File read/write errors
|
||||
- Permission errors
|
||||
- Disk full errors
|
||||
- **References**: architecture/security.md
|
||||
- **Result**: ✅ Comprehensive error handling implemented
|
||||
|
||||
- [ ] Write comprehensive tests (`tests/test_notes.py`)
|
||||
- [x] Implement custom exceptions
|
||||
- `NoteError` - Base exception
|
||||
- `NoteNotFoundError` - Note not found
|
||||
- `InvalidNoteDataError` - Invalid data
|
||||
- `NoteSyncError` - Sync failure
|
||||
- **Result**: ✅ Complete exception hierarchy
|
||||
|
||||
- [x] Write comprehensive tests (`tests/test_notes.py`)
|
||||
- Test create with various content
|
||||
- Test slug uniqueness enforcement
|
||||
- Test file/database sync
|
||||
@@ -215,8 +283,11 @@ This is the heart of the application. File operations + database sync.
|
||||
- Test error handling (DB failure, file failure)
|
||||
- Test edge cases (empty content, very long content, special characters)
|
||||
- Integration test: create → read → update → delete cycle
|
||||
- **Result**: ✅ 85 tests, 86% coverage, all passing
|
||||
|
||||
**Completion Criteria**: Full CRUD operations working with file+database sync, comprehensive tests passing
|
||||
**Completion Criteria**: ✅ Full CRUD operations working with file+database sync, comprehensive tests passing
|
||||
|
||||
**Report**: See `/home/phil/Projects/starpunk/docs/reports/phase-2.1-implementation-20251118.md`
|
||||
|
||||
---
|
||||
|
||||
@@ -226,70 +297,76 @@ Implements the IndieLogin OAuth flow for admin access.
|
||||
|
||||
### 3.1 Authentication Module (`starpunk/auth.py`)
|
||||
|
||||
**Status**: ✅ COMPLETE
|
||||
**Priority**: HIGH - Required for admin interface
|
||||
**Estimated Effort**: 5-6 hours
|
||||
**Actual Effort**: ~5 hours
|
||||
**Completed**: 2025-11-18
|
||||
**Dependencies**: `models.py`, `database.py`, `httpx` library
|
||||
**Test Coverage**: 96% (37 tests passing)
|
||||
|
||||
- [ ] Implement state token management
|
||||
- `generate_state()` - Create random CSRF token (32 bytes)
|
||||
- `store_state()` - Save to database with 5-minute expiry
|
||||
- `verify_state()` - Check validity and delete (single-use)
|
||||
- `cleanup_expired_states()` - Remove old tokens
|
||||
- **References**: ADR-005
|
||||
- **Acceptance Criteria**: State tokens prevent CSRF attacks
|
||||
- [x] Implement state token management
|
||||
- Helper functions for state token generation and verification
|
||||
- Single-use tokens with 5-minute expiry
|
||||
- Automatic cleanup of expired tokens
|
||||
- **References**: ADR-005, ADR-010
|
||||
- **Acceptance Criteria**: ✅ State tokens prevent CSRF attacks
|
||||
|
||||
- [ ] Implement session token management
|
||||
- `generate_session_token()` - Create random token (32 bytes)
|
||||
- `create_session()` - Store session with user 'me' URL
|
||||
- `get_session()` - Retrieve session by token
|
||||
- `validate_session()` - Check if valid and not expired
|
||||
- `update_session_activity()` - Update last_used_at
|
||||
- `delete_session()` - Logout
|
||||
- `cleanup_expired_sessions()` - Remove old sessions
|
||||
- **References**: ADR-005, architecture/security.md
|
||||
- **Acceptance Criteria**: Sessions work for 30 days, extend on use
|
||||
- [x] Implement session token management
|
||||
- `create_session()` - Create session with SHA-256 hashed token
|
||||
- `verify_session()` - Validate session and check expiration
|
||||
- `destroy_session()` - Delete session (logout)
|
||||
- Session metadata tracking (user_agent, ip_address)
|
||||
- Automatic cleanup of expired sessions
|
||||
- 30-day expiry with activity-based refresh
|
||||
- **References**: ADR-005, ADR-010, architecture/security.md
|
||||
- **Note**: Uses token hashing for security (never stores plaintext)
|
||||
- **Acceptance Criteria**: ✅ Sessions work for 30 days, extend on use
|
||||
|
||||
- [ ] Implement IndieLogin OAuth flow
|
||||
- `initiate_login()` - Build authorization URL, store state, redirect
|
||||
- Validate 'me' URL format
|
||||
- Generate state token
|
||||
- Build indielogin.com authorization URL with params
|
||||
- Return redirect response
|
||||
- [x] Implement IndieLogin OAuth flow
|
||||
- `initiate_login()` - Build authorization URL, store state
|
||||
- Validates 'me' URL format using `is_valid_url()`
|
||||
- Generates cryptographically secure state token
|
||||
- Stores state in database with 5-minute expiry
|
||||
- Builds indielogin.com authorization URL
|
||||
- Returns authorization URL for redirect
|
||||
- `handle_callback()` - Exchange code for identity
|
||||
- Verify state token (CSRF check)
|
||||
- POST to indielogin.com/auth with code
|
||||
- Verify HTTP response (200 OK)
|
||||
- Extract 'me' from JSON response
|
||||
- Verify 'me' matches ADMIN_ME config
|
||||
- Create session if authorized
|
||||
- Set secure HttpOnly cookie
|
||||
- Redirect to admin dashboard
|
||||
- **References**: ADR-005, IndieLogin API docs
|
||||
- **Acceptance Criteria**: Full OAuth flow works with indielogin.com
|
||||
- Verifies state token (CSRF check, single-use)
|
||||
- POSTs to indielogin.com/auth with code
|
||||
- Validates HTTP response (200 OK)
|
||||
- Extracts 'me' from JSON response
|
||||
- Verifies 'me' matches ADMIN_ME config
|
||||
- Creates session if authorized
|
||||
- Returns session token for cookie setting
|
||||
- **References**: ADR-005, ADR-010, IndieLogin API docs
|
||||
- **Acceptance Criteria**: ✅ Full OAuth flow works with indielogin.com
|
||||
|
||||
- [ ] Implement authentication decorator
|
||||
- [x] Implement authentication decorator
|
||||
- `require_auth()` - Decorator for protected routes
|
||||
- Check session cookie
|
||||
- Validate session
|
||||
- Store user info in Flask `g` context
|
||||
- Redirect to login if not authenticated
|
||||
- **Acceptance Criteria**: Protects admin routes correctly
|
||||
- Extracts session token from cookie
|
||||
- Validates session using `verify_session()`
|
||||
- Stores user info in Flask `g.user`
|
||||
- Returns 401/redirect if not authenticated
|
||||
- **Acceptance Criteria**: ✅ Protects admin routes correctly
|
||||
|
||||
- [ ] Implement logout
|
||||
- `logout()` - Delete session from database
|
||||
- Clear session cookie
|
||||
- Redirect to homepage
|
||||
- **Acceptance Criteria**: Logout works completely
|
||||
- [x] Implement custom exceptions
|
||||
- `AuthError` - Base exception
|
||||
- `InvalidStateError` - CSRF validation failed
|
||||
- `UnauthorizedError` - User not authorized
|
||||
- `IndieLoginError` - External service error
|
||||
- **Result**: ✅ Complete exception hierarchy
|
||||
|
||||
- [ ] Error handling
|
||||
- Invalid state token
|
||||
- IndieLogin API errors
|
||||
- Network timeouts
|
||||
- Unauthorized users (wrong 'me' URL)
|
||||
- Expired sessions
|
||||
- **References**: architecture/security.md
|
||||
- [x] Error handling
|
||||
- Invalid state token rejection
|
||||
- IndieLogin API error handling
|
||||
- Network timeout handling (10s timeout)
|
||||
- Unauthorized user rejection (wrong 'me')
|
||||
- Expired session handling
|
||||
- Comprehensive logging for all auth events
|
||||
- **References**: architecture/security.md, ADR-010
|
||||
- **Result**: ✅ Comprehensive error handling
|
||||
|
||||
- [ ] Write comprehensive tests (`tests/test_auth.py`)
|
||||
- [x] Write comprehensive tests (`tests/test_auth.py`)
|
||||
- Test state token generation and validation
|
||||
- Test session creation and validation
|
||||
- Test session expiry
|
||||
@@ -300,8 +377,13 @@ Implements the IndieLogin OAuth flow for admin access.
|
||||
- Test session cookie security (HttpOnly, Secure flags)
|
||||
- Test logout functionality
|
||||
- Test decorator on protected routes
|
||||
- **Result**: ✅ 37 tests, 96% coverage, all passing
|
||||
|
||||
**Completion Criteria**: Authentication works end-to-end, all security measures tested
|
||||
**Completion Criteria**: ✅ Authentication works end-to-end, all security measures tested
|
||||
|
||||
**Report**: See `/home/phil/Projects/starpunk/docs/reports/phase-3-authentication-20251118.md`
|
||||
|
||||
**New ADRs**: ADR-010 (Authentication Module Design)
|
||||
|
||||
---
|
||||
|
||||
@@ -309,8 +391,24 @@ Implements the IndieLogin OAuth flow for admin access.
|
||||
|
||||
User-facing interface (public site + admin interface).
|
||||
|
||||
**Status**: 🔵 IN PROGRESS - Design complete, ready for implementation
|
||||
**Design Complete**: 2025-11-18
|
||||
**Documentation**:
|
||||
- `/home/phil/Projects/starpunk/docs/design/phase-4-web-interface.md`
|
||||
- `/home/phil/Projects/starpunk/docs/reports/phase-4-architectural-assessment-20251118.md`
|
||||
- `/home/phil/Projects/starpunk/docs/decisions/ADR-011-development-authentication-mechanism.md`
|
||||
|
||||
**Key Decisions**:
|
||||
- Development authentication mechanism approved (ADR-011)
|
||||
- Template structure defined
|
||||
- Route organization finalized
|
||||
- CSS architecture specified
|
||||
|
||||
**Target Version**: 0.5.0
|
||||
|
||||
### 4.1 Public Routes Blueprint (`starpunk/routes/public.py`)
|
||||
|
||||
**Status**: ⏳ NOT STARTED
|
||||
**Priority**: HIGH - Public interface
|
||||
**Estimated Effort**: 3-4 hours
|
||||
**Dependencies**: `notes.py`, `models.py`
|
||||
@@ -1141,30 +1239,65 @@ Final steps before V1 release.
|
||||
## Summary Checklist
|
||||
|
||||
### Core Features (Must Have)
|
||||
- [ ] Notes CRUD operations (file + database sync)
|
||||
- [ ] IndieLogin authentication
|
||||
- [ ] Admin web interface
|
||||
- [ ] Public web interface
|
||||
- [ ] RSS feed generation
|
||||
- [ ] Micropub endpoint
|
||||
- [ ] All tests passing
|
||||
- [ ] Standards compliance (HTML, RSS, Microformats, Micropub)
|
||||
- [ ] Documentation complete
|
||||
- [x] **Notes CRUD operations (file + database sync)** ✅ v0.3.0
|
||||
- 86% test coverage, 85 tests passing
|
||||
- Full file/database synchronization
|
||||
- Soft and hard delete support
|
||||
- [x] **IndieLogin authentication** ✅ v0.4.0
|
||||
- 96% test coverage, 37 tests passing
|
||||
- CSRF protection, session management
|
||||
- Token hashing for security
|
||||
- [ ] **Admin web interface** ⏳ Designed, not implemented
|
||||
- Design complete (Phase 4)
|
||||
- Routes specified
|
||||
- Templates planned
|
||||
- [ ] **Public web interface** ⏳ Designed, not implemented
|
||||
- Design complete (Phase 4)
|
||||
- Microformats2 markup planned
|
||||
- [ ] **RSS feed generation** ⏳ Not started
|
||||
- Phase 5
|
||||
- [ ] **Micropub endpoint** ⏳ Not started
|
||||
- Phase 6
|
||||
- Token model ready
|
||||
- [x] **Core tests passing** ✅ Phases 1-3 complete
|
||||
- Utils: >90% coverage
|
||||
- Models: >90% coverage
|
||||
- Notes: 86% coverage
|
||||
- Auth: 96% coverage
|
||||
- [ ] **Standards compliance** ⏳ Partial
|
||||
- HTML5: Not yet tested
|
||||
- RSS: Not yet implemented
|
||||
- Microformats: Planned in Phase 4
|
||||
- Micropub: Not yet implemented
|
||||
- [x] **Documentation complete (Phases 1-3)** ✅
|
||||
- ADRs 001-011 complete
|
||||
- Design docs for Phases 1-4
|
||||
- Implementation reports for Phases 2-3
|
||||
|
||||
### Optional Features (Nice to Have)
|
||||
- [ ] Markdown preview (JavaScript)
|
||||
- [ ] Notes search
|
||||
- [ ] Media uploads (Micropub)
|
||||
- [ ] JSON REST API
|
||||
- [ ] Feed caching
|
||||
- [ ] Markdown preview (JavaScript) - Phase 4.5
|
||||
- [ ] Notes search - Deferred to V2
|
||||
- [ ] Media uploads (Micropub) - Deferred to V2
|
||||
- [ ] JSON REST API - Phase 7 (optional)
|
||||
- [ ] Feed caching - Deferred to V2
|
||||
|
||||
### Quality Gates
|
||||
- [ ] Test coverage >80%
|
||||
- [ ] All validators pass (HTML, RSS, Microformats, Micropub)
|
||||
- [ ] Security tests pass
|
||||
- [ ] Manual testing complete
|
||||
- [ ] Performance targets met (<300ms responses)
|
||||
- [ ] Production deployment tested
|
||||
- [x] **Test coverage >80%** ✅ Phases 1-3 achieve 86-96%
|
||||
- [ ] **All validators pass** ⏳ Not yet tested
|
||||
- HTML validator: Phase 8
|
||||
- RSS validator: Phase 8
|
||||
- Microformats validator: Phase 8
|
||||
- Micropub validator: Phase 8
|
||||
- [x] **Security tests pass** ✅ Phases 1-3
|
||||
- SQL injection prevention tested
|
||||
- Path traversal prevention tested
|
||||
- CSRF protection tested
|
||||
- Token hashing tested
|
||||
- [ ] **Manual testing complete** ⏳ Not yet performed
|
||||
- [ ] **Performance targets met** ⏳ Not yet tested
|
||||
- [ ] **Production deployment tested** ⏳ Not yet performed
|
||||
|
||||
**Current Status**: 3/10 phases complete (33%), foundation solid, ready for Phase 4
|
||||
|
||||
---
|
||||
|
||||
@@ -1184,12 +1317,20 @@ Final steps before V1 release.
|
||||
- Phase 9 (Documentation): 5-7 hours
|
||||
- Phase 10 (Release): 3-5 hours
|
||||
|
||||
**Recommended Schedule**:
|
||||
- Week 1: Phases 1-3 (foundation and auth)
|
||||
- Week 2: Phase 4 (web interface)
|
||||
**Original Schedule**:
|
||||
- ~~Week 1: Phases 1-3 (foundation and auth)~~ ✅ Complete
|
||||
- Week 2: Phase 4 (web interface) ⏳ Current
|
||||
- Week 3: Phases 5-6 (RSS and Micropub)
|
||||
- Week 4: Phases 8-10 (testing, docs, release)
|
||||
|
||||
**Revised Schedule** (from 2025-11-18):
|
||||
- **Completed**: Phases 1-3 (utilities, models, notes, auth) - ~20 hours
|
||||
- **Next**: Phase 4 (web interface) - ~34 hours (~5 days)
|
||||
- **Then**: Phases 5-6 (RSS + Micropub) - ~15 hours (~2 days)
|
||||
- **Finally**: Phases 8-10 (QA + docs + release) - ~20 hours (~3 days)
|
||||
|
||||
**Estimated Completion**: ~10-12 development days from 2025-11-18
|
||||
|
||||
---
|
||||
|
||||
## Development Notes
|
||||
@@ -1231,8 +1372,21 @@ Final steps before V1 release.
|
||||
- [ADR-004: File-Based Storage](/home/phil/Projects/starpunk/docs/decisions/ADR-004-file-based-note-storage.md)
|
||||
- [ADR-005: IndieLogin Authentication](/home/phil/Projects/starpunk/docs/decisions/ADR-005-indielogin-authentication.md)
|
||||
- [ADR-006: Python Virtual Environment](/home/phil/Projects/starpunk/docs/decisions/ADR-006-python-virtual-environment-uv.md)
|
||||
- [ADR-007: Slug Generation Algorithm](/home/phil/Projects/starpunk/docs/decisions/ADR-007-slug-generation-algorithm.md)
|
||||
- [ADR-008: Versioning Strategy](/home/phil/Projects/starpunk/docs/decisions/ADR-008-versioning-strategy.md)
|
||||
- [ADR-009: Git Branching Strategy](/home/phil/Projects/starpunk/docs/decisions/ADR-009-git-branching-strategy.md)
|
||||
- [ADR-010: Authentication Module Design](/home/phil/Projects/starpunk/docs/decisions/ADR-010-authentication-module-design.md)
|
||||
- [ADR-011: Development Authentication Mechanism](/home/phil/Projects/starpunk/docs/decisions/ADR-011-development-authentication-mechanism.md)
|
||||
- [Project Structure](/home/phil/Projects/starpunk/docs/design/project-structure.md)
|
||||
- [Phase 4 Web Interface Design](/home/phil/Projects/starpunk/docs/design/phase-4-web-interface.md)
|
||||
- [Python Coding Standards](/home/phil/Projects/starpunk/docs/standards/python-coding-standards.md)
|
||||
- [Versioning Strategy](/home/phil/Projects/starpunk/docs/standards/versioning-strategy.md)
|
||||
- [Git Branching Strategy](/home/phil/Projects/starpunk/docs/standards/git-branching-strategy.md)
|
||||
|
||||
### Implementation Reports
|
||||
- [Phase 2.1 Implementation Report](/home/phil/Projects/starpunk/docs/reports/phase-2.1-implementation-20251118.md)
|
||||
- [Phase 3 Authentication Report](/home/phil/Projects/starpunk/docs/reports/phase-3-authentication-20251118.md)
|
||||
- [Phase 4 Architectural Assessment](/home/phil/Projects/starpunk/docs/reports/phase-4-architectural-assessment-20251118.md)
|
||||
|
||||
### External Standards
|
||||
- [Micropub Specification](https://micropub.spec.indieweb.org/)
|
||||
|
||||
Reference in New Issue
Block a user