Compare commits
16 Commits
v0.9.4
...
e2333cb31d
| Author | SHA1 | Date | |
|---|---|---|---|
| e2333cb31d | |||
| dca9604746 | |||
| 5bbecad01d | |||
| 800bc1069d | |||
| b184bc1316 | |||
| 354c18b5b8 | |||
| cebd3fb71e | |||
| 066cde8c46 | |||
| 610ec061ca | |||
| f0570c2cb1 | |||
| 35376b1a5a | |||
| fb238e5bd6 | |||
| b4ddc6708e | |||
| f3965959bc | |||
| e97b778cb7 | |||
| 9c65723e9d |
83
.claude/agents/documentation-manager.md
Normal file
83
.claude/agents/documentation-manager.md
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
---
|
||||||
|
name: documentation-manager
|
||||||
|
description: Use this agent when:\n- A new feature or significant code change has been completed and documentation needs to be updated\n- The repository structure needs documentation cleanup or reorganization\n- README.md needs to be reviewed for completeness and accuracy\n- Documentation files are in the wrong location or need to be split into multiple documents\n- After architectural decisions are made that need to be documented as ADRs\n- When design documents or standards need to be filed appropriately\n- Before releases to ensure all documentation is current and properly organized\n- When the architect agent has completed work and documentation needs review\n\nExamples:\n\n<example>\nContext: The developer has just completed implementing a new authentication system.\nuser: "I've finished implementing the OAuth2 authentication system"\nassistant: "Great work! Let me use the Task tool to launch the documentation-manager agent to ensure all related documentation is updated and properly filed."\n<commentary>Since a significant feature was completed, use the documentation-manager agent to review and update relevant documentation, ensure README.md reflects the new feature, and verify any new docs are properly organized.</commentary>\n</example>\n\n<example>\nContext: The architect has created a new architectural decision document that contains both decision rationale and implementation standards.\nuser: "I've created ADR-015 about our new database schema approach, it also includes coding standards for database migrations"\nassistant: "I notice this document contains both a decision and standards. Let me use the Task tool to launch the documentation-manager agent to work with you on splitting this appropriately."\n<commentary>The documentation-manager should proactively identify that this document needs to be split - the decision stays in decisions/ and the standards should be extracted to standards/.</commentary>\n</example>\n\n<example>\nContext: Multiple documentation files have been created in the repository root during development.\nuser: "I've been documenting as I go and there are a few markdown files in the root now"\nassistant: "Let me use the Task tool to launch the documentation-manager agent to organize these files into the appropriate docs/ subdirectories."\n<commentary>The documentation-manager should proactively curate the repository root, moving documentation to appropriate folders while keeping only README.md, CLAUDE.md, and CHANGELOG.md in the root.</commentary>\n</example>
|
||||||
|
model: sonnet
|
||||||
|
color: green
|
||||||
|
---
|
||||||
|
|
||||||
|
You are an elite Documentation Architect with expertise in information architecture, technical writing standards, and repository organization. You maintain documentation systems for enterprise software projects and ensure they remain maintainable, discoverable, and aligned with industry best practices.
|
||||||
|
|
||||||
|
Your primary responsibilities:
|
||||||
|
|
||||||
|
1. REPOSITORY ROOT CURATION:
|
||||||
|
- The repository root must ONLY contain: README.md, CLAUDE.md, and CHANGELOG.md
|
||||||
|
- Immediately identify and relocate any other documentation files to appropriate docs/ subdirectories
|
||||||
|
- Maintain this standard vigilantly - a clean root is critical for repository professionalism
|
||||||
|
|
||||||
|
2. README.md MANAGEMENT:
|
||||||
|
- Collaborate with the architect agent to ensure README.md is comprehensive and current
|
||||||
|
- README.md must contain everything needed for deployment and usage:
|
||||||
|
* Clear project description and purpose
|
||||||
|
* Installation instructions (note: this project uses uv for Python venv management)
|
||||||
|
* Configuration requirements
|
||||||
|
* Usage examples
|
||||||
|
* API documentation or links to detailed docs
|
||||||
|
* Troubleshooting guidance
|
||||||
|
* Contributing guidelines
|
||||||
|
* License information
|
||||||
|
- Review README.md after any significant feature changes
|
||||||
|
- Ensure technical accuracy by consulting with the architect when needed
|
||||||
|
|
||||||
|
3. DOCS/ FOLDER STRUCTURE:
|
||||||
|
Maintain strict organization:
|
||||||
|
- architecture/ - Architectural documentation, system design overviews, component diagrams
|
||||||
|
- decisions/ - Architectural Decision Records (ADRs) documenting significant decisions
|
||||||
|
- designs/ - Detailed design documents for features and components
|
||||||
|
- standards/ - Coding standards, conventions, best practices, style guides
|
||||||
|
- reports/ - Implementation reports created by developers for architect review
|
||||||
|
|
||||||
|
4. DOCUMENT CLASSIFICATION AND SPLITTING:
|
||||||
|
- Proactively identify documents containing multiple types of information
|
||||||
|
- When a document contains mixed content types (e.g., a decision with embedded standards):
|
||||||
|
* Collaborate with the architect agent to split the document
|
||||||
|
* Ensure each resulting document is focused and single-purpose
|
||||||
|
* Example: If ADR-015 contains both decision rationale and coding standards, split into:
|
||||||
|
- decisions/ADR-015-database-schema-decision.md (decision only)
|
||||||
|
- standards/database-migration-standards.md (extracted standards)
|
||||||
|
- Maintain cross-references between related split documents
|
||||||
|
|
||||||
|
5. QUALITY STANDARDS:
|
||||||
|
- Ensure all documentation follows markdown best practices
|
||||||
|
- Verify consistent formatting, heading structure, and link validity
|
||||||
|
- Check that file naming conventions are clear and consistent (kebab-case preferred)
|
||||||
|
- Validate that documentation is dated and versioned where appropriate
|
||||||
|
- Ensure ADRs follow standard ADR format (Context, Decision, Consequences)
|
||||||
|
|
||||||
|
6. PROACTIVE MAINTENANCE:
|
||||||
|
- Regularly audit docs/ folder for misplaced files
|
||||||
|
- Identify documentation that has become outdated or redundant
|
||||||
|
- Flag documentation gaps when new features lack adequate documentation
|
||||||
|
- Recommend documentation improvements to the architect
|
||||||
|
|
||||||
|
7. COLLABORATION PROTOCOL:
|
||||||
|
- Work closely with the architect agent on README.md updates
|
||||||
|
- Consult the architect when document splitting decisions are complex
|
||||||
|
- Coordinate with developers to ensure reports/ folder is reviewed by architect
|
||||||
|
- When uncertain about document classification, consult with the architect
|
||||||
|
|
||||||
|
Your workflow:
|
||||||
|
1. Assess the current state of repository documentation
|
||||||
|
2. Identify issues: misplaced files, outdated content, missing documentation, multi-purpose documents
|
||||||
|
3. For simple relocations and updates, execute immediately
|
||||||
|
4. For complex decisions (splitting documents, significant README changes), collaborate with the architect
|
||||||
|
5. After changes, verify the repository maintains proper structure
|
||||||
|
6. Document your actions clearly in your responses
|
||||||
|
|
||||||
|
Key principles:
|
||||||
|
- Maintainability over comprehensiveness - well-organized simple docs beat sprawling complex ones
|
||||||
|
- Discoverability - users should find what they need quickly
|
||||||
|
- Single source of truth - avoid documentation duplication
|
||||||
|
- Living documentation - docs should evolve with the codebase
|
||||||
|
- Clear separation of concerns - each document type serves a distinct purpose
|
||||||
|
|
||||||
|
When you identify issues, be specific about what's wrong and what needs to change. When proposing splits or major reorganizations, explain your reasoning clearly. Always prioritize the end user's ability to quickly find and understand the information they need.
|
||||||
58
.gitea/workflows/build-container.yml
Normal file
58
.gitea/workflows/build-container.yml
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
# Gitea Actions workflow for StarPunk
|
||||||
|
# Builds and pushes container images on version tags
|
||||||
|
|
||||||
|
name: Build Container
|
||||||
|
|
||||||
|
on:
|
||||||
|
# Trigger on version tags
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v[0-9]+.[0-9]+.[0-9]+'
|
||||||
|
# Allow manual trigger from Gitea UI
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: docker
|
||||||
|
steps:
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
if command -v apk > /dev/null; then
|
||||||
|
apk add --no-cache nodejs npm docker git
|
||||||
|
elif command -v apt-get > /dev/null; then
|
||||||
|
apt-get update && apt-get install -y nodejs npm docker.io git
|
||||||
|
elif command -v yum > /dev/null; then
|
||||||
|
yum install -y nodejs npm docker git
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Extract registry URL
|
||||||
|
id: registry
|
||||||
|
run: |
|
||||||
|
# Extract hostname from server URL (remove protocol)
|
||||||
|
REGISTRY_URL=$(echo "${{ github.server_url }}" | sed 's|https://||' | sed 's|http://||')
|
||||||
|
echo "url=${REGISTRY_URL}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Login to Gitea Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ steps.registry.outputs.url }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Containerfile
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
${{ steps.registry.outputs.url }}/${{ github.repository }}:${{ github.ref_name }}
|
||||||
|
${{ steps.registry.outputs.url }}/${{ github.repository }}:latest
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
10
CHANGELOG.md
10
CHANGELOG.md
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [0.9.5] - 2025-11-23
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- **SECRET_KEY empty string handling**: Fixed config.py to properly handle empty `FLASK_SECRET_KEY` environment variable
|
||||||
|
- `os.getenv()` returns empty string (not None) when env var is set to `""`
|
||||||
|
- Empty string now correctly falls back to SESSION_SECRET
|
||||||
|
- Prevents Flask session/flash failures when FLASK_SECRET_KEY="" in .env file
|
||||||
|
|
||||||
## [0.9.4] - 2025-11-22
|
## [0.9.4] - 2025-11-22
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
@@ -149,7 +157,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- **v0.8.0**: Correct implementation based on official IndieLogin.com API documentation.
|
- **v0.8.0**: Correct implementation based on official IndieLogin.com API documentation.
|
||||||
|
|
||||||
### Related Documentation
|
### Related Documentation
|
||||||
- ADR-019: IndieAuth Correct Implementation Based on IndieLogin.com API
|
- ADR-025: IndieAuth Correct Implementation Based on IndieLogin.com API
|
||||||
- Design Document: docs/designs/indieauth-pkce-authentication.md
|
- Design Document: docs/designs/indieauth-pkce-authentication.md
|
||||||
- ADR-016: Superseded (h-app client discovery not required)
|
- ADR-016: Superseded (h-app client discovery not required)
|
||||||
- ADR-017: Superseded (OAuth metadata not required)
|
- ADR-017: Superseded (OAuth metadata not required)
|
||||||
|
|||||||
412
CLAUDE.MD
412
CLAUDE.MD
@@ -1,412 +0,0 @@
|
|||||||
# StarPunk - Minimal IndieWeb CMS
|
|
||||||
|
|
||||||
## Project Overview
|
|
||||||
|
|
||||||
StarPunk is a minimalist, single-user CMS for publishing IndieWeb-compatible notes with RSS syndication. It emphasizes simplicity, elegance, and standards compliance.
|
|
||||||
|
|
||||||
**Core Philosophy**: Every line of code must justify its existence. When in doubt, leave it out.
|
|
||||||
|
|
||||||
## V1 Scope
|
|
||||||
|
|
||||||
### Must Have
|
|
||||||
- Publish notes (https://indieweb.org/note)
|
|
||||||
- IndieAuth authentication (https://indieauth.spec.indieweb.org)
|
|
||||||
- Micropub server endpoint (https://micropub.spec.indieweb.org)
|
|
||||||
- RSS feed generation
|
|
||||||
- API-first architecture
|
|
||||||
- Markdown support
|
|
||||||
- Self-hostable deployment
|
|
||||||
|
|
||||||
### Won't Have (V1)
|
|
||||||
- Webmentions
|
|
||||||
- POSSE (beyond RSS)
|
|
||||||
- Multiple users
|
|
||||||
- Comments
|
|
||||||
- Analytics
|
|
||||||
- Themes/customization
|
|
||||||
- Media uploads
|
|
||||||
- Other post types (articles, photos, replies)
|
|
||||||
|
|
||||||
## System Architecture
|
|
||||||
|
|
||||||
### Core Components
|
|
||||||
|
|
||||||
1. **Data Layer**
|
|
||||||
- Notes storage (content, HTML rendering, timestamps, slugs)
|
|
||||||
- Authentication tokens for IndieAuth sessions
|
|
||||||
- Simple schema with minimal relationships
|
|
||||||
- Persistence with backup capability
|
|
||||||
|
|
||||||
2. **API Layer**
|
|
||||||
- RESTful endpoints for note management
|
|
||||||
- Micropub endpoint for external clients
|
|
||||||
- IndieAuth implementation
|
|
||||||
- RSS feed generation
|
|
||||||
- JSON responses for all APIs
|
|
||||||
|
|
||||||
3. **Web Interface**
|
|
||||||
- Minimal public interface displaying notes
|
|
||||||
- Admin interface for creating/managing notes
|
|
||||||
- Single elegant theme
|
|
||||||
- Proper microformats markup (h-entry, h-card)
|
|
||||||
- No client-side complexity
|
|
||||||
|
|
||||||
### Data Model
|
|
||||||
|
|
||||||
```
|
|
||||||
Notes:
|
|
||||||
- id: unique identifier
|
|
||||||
- content: raw markdown text
|
|
||||||
- content_html: rendered HTML
|
|
||||||
- slug: URL-friendly identifier
|
|
||||||
- published: boolean flag
|
|
||||||
- created_at: timestamp
|
|
||||||
- updated_at: timestamp
|
|
||||||
|
|
||||||
Tokens:
|
|
||||||
- token: unique token string
|
|
||||||
- me: user identity URL
|
|
||||||
- client_id: micropub client identifier
|
|
||||||
- scope: permission scope
|
|
||||||
- created_at: timestamp
|
|
||||||
- expires_at: optional expiration
|
|
||||||
```
|
|
||||||
|
|
||||||
### URL Structure
|
|
||||||
|
|
||||||
```
|
|
||||||
/ # Homepage with recent notes
|
|
||||||
/note/{slug} # Individual note permalink
|
|
||||||
/admin # Admin dashboard
|
|
||||||
/admin/new # Create new note
|
|
||||||
/api/micropub # Micropub endpoint
|
|
||||||
/api/notes # Notes CRUD API
|
|
||||||
/api/auth # IndieAuth endpoints
|
|
||||||
/feed.xml # RSS feed
|
|
||||||
/.well-known/oauth-authorization-server # IndieAuth metadata
|
|
||||||
```
|
|
||||||
|
|
||||||
## Implementation Requirements
|
|
||||||
|
|
||||||
### Phase 1: Foundation
|
|
||||||
|
|
||||||
**Data Storage**
|
|
||||||
- Implement note storage with CRUD operations
|
|
||||||
- Support markdown content with HTML rendering
|
|
||||||
- Generate unique slugs for URLs
|
|
||||||
- Track creation and update timestamps
|
|
||||||
|
|
||||||
**Configuration**
|
|
||||||
- Site URL (required for absolute URLs)
|
|
||||||
- Site title and author information
|
|
||||||
- IndieAuth endpoint configuration
|
|
||||||
- Environment-based configuration
|
|
||||||
|
|
||||||
### Phase 2: Core APIs
|
|
||||||
|
|
||||||
**Notes API**
|
|
||||||
- GET /api/notes - List published notes
|
|
||||||
- POST /api/notes - Create new note (authenticated)
|
|
||||||
- GET /api/notes/{id} - Get single note
|
|
||||||
- PUT /api/notes/{id} - Update note (authenticated)
|
|
||||||
- DELETE /api/notes/{id} - Delete note (authenticated)
|
|
||||||
|
|
||||||
**RSS Feed**
|
|
||||||
- Generate valid RSS 2.0 feed
|
|
||||||
- Include all published notes
|
|
||||||
- Proper date formatting (RFC-822)
|
|
||||||
- CDATA wrapping for HTML content
|
|
||||||
- Cache appropriately (5 minute minimum)
|
|
||||||
|
|
||||||
### Phase 3: IndieAuth Implementation
|
|
||||||
|
|
||||||
**Authorization Endpoint**
|
|
||||||
- Validate client_id parameter
|
|
||||||
- Verify redirect_uri matches registered client
|
|
||||||
- Generate authorization codes
|
|
||||||
- Support PKCE flow
|
|
||||||
|
|
||||||
**Token Endpoint**
|
|
||||||
- Exchange authorization codes for access tokens
|
|
||||||
- Validate code verifier for PKCE
|
|
||||||
- Return token with appropriate scope
|
|
||||||
- Store token with expiration
|
|
||||||
|
|
||||||
**Token Verification**
|
|
||||||
- Validate bearer tokens in Authorization header
|
|
||||||
- Check token expiration
|
|
||||||
- Verify scope for requested operation
|
|
||||||
|
|
||||||
### Phase 4: Micropub Implementation
|
|
||||||
|
|
||||||
**POST Endpoint**
|
|
||||||
- Support JSON format (Content-Type: application/json)
|
|
||||||
- Support form-encoded format (Content-Type: application/x-www-form-urlencoded)
|
|
||||||
- Handle h-entry creation for notes
|
|
||||||
- Return 201 Created with Location header
|
|
||||||
- Validate authentication token
|
|
||||||
|
|
||||||
**GET Endpoint**
|
|
||||||
- Support q=config query (return supported features)
|
|
||||||
- Support q=source query (return note source)
|
|
||||||
- Return appropriate JSON responses
|
|
||||||
|
|
||||||
**Micropub Request Structure (JSON)**
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"type": ["h-entry"],
|
|
||||||
"properties": {
|
|
||||||
"content": ["Note content here"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Micropub Response**
|
|
||||||
```
|
|
||||||
HTTP/1.1 201 Created
|
|
||||||
Location: https://example.com/note/abc123
|
|
||||||
```
|
|
||||||
|
|
||||||
### Phase 5: Web Interface
|
|
||||||
|
|
||||||
**Homepage Requirements**
|
|
||||||
- Display notes in reverse chronological order
|
|
||||||
- Include proper h-entry microformats
|
|
||||||
- Show note content (e-content class)
|
|
||||||
- Include permalink (u-url class)
|
|
||||||
- Display publish date (dt-published class)
|
|
||||||
- Clean, readable typography
|
|
||||||
- Mobile-responsive design
|
|
||||||
|
|
||||||
**Note Permalink Page**
|
|
||||||
- Full note display with microformats
|
|
||||||
- Author information (h-card)
|
|
||||||
- Timestamp and permalink
|
|
||||||
- Link back to homepage
|
|
||||||
|
|
||||||
**Admin Interface**
|
|
||||||
- Simple markdown editor
|
|
||||||
- Preview capability
|
|
||||||
- Publish/Draft toggle
|
|
||||||
- List of existing notes
|
|
||||||
- Edit existing notes
|
|
||||||
- Protected by authentication
|
|
||||||
|
|
||||||
**Microformats Example**
|
|
||||||
```html
|
|
||||||
<article class="h-entry">
|
|
||||||
<div class="e-content">
|
|
||||||
<p>Note content goes here</p>
|
|
||||||
</div>
|
|
||||||
<footer>
|
|
||||||
<a class="u-url" href="/note/abc123">
|
|
||||||
<time class="dt-published" datetime="2024-01-01T12:00:00Z">
|
|
||||||
January 1, 2024
|
|
||||||
</time>
|
|
||||||
</a>
|
|
||||||
</footer>
|
|
||||||
</article>
|
|
||||||
```
|
|
||||||
|
|
||||||
### Phase 6: Deployment
|
|
||||||
|
|
||||||
**Requirements**
|
|
||||||
- Self-hostable package
|
|
||||||
- Single deployment unit
|
|
||||||
- Persistent data storage
|
|
||||||
- Environment-based configuration
|
|
||||||
- Backup-friendly data format
|
|
||||||
|
|
||||||
**Configuration Variables**
|
|
||||||
- SITE_URL - Full URL of the site
|
|
||||||
- SITE_TITLE - Site name for RSS feed
|
|
||||||
- SITE_AUTHOR - Default author name
|
|
||||||
- INDIEAUTH_ENDPOINT - IndieAuth provider URL
|
|
||||||
- DATA_PATH - Location for persistent storage
|
|
||||||
|
|
||||||
### Phase 7: Testing
|
|
||||||
|
|
||||||
**Unit Tests Required**
|
|
||||||
- Data layer operations
|
|
||||||
- Micropub request parsing
|
|
||||||
- IndieAuth token validation
|
|
||||||
- Markdown rendering
|
|
||||||
- Slug generation
|
|
||||||
|
|
||||||
**Integration Tests**
|
|
||||||
- Complete Micropub flow
|
|
||||||
- IndieAuth authentication flow
|
|
||||||
- RSS feed generation
|
|
||||||
- API endpoint responses
|
|
||||||
|
|
||||||
**Test Coverage Areas**
|
|
||||||
- Note creation via web interface
|
|
||||||
- Note creation via Micropub
|
|
||||||
- Authentication flows
|
|
||||||
- Feed validation
|
|
||||||
- Error handling
|
|
||||||
|
|
||||||
## Standards Compliance
|
|
||||||
|
|
||||||
### IndieWeb Standards
|
|
||||||
|
|
||||||
**Microformats2**
|
|
||||||
- h-entry for notes
|
|
||||||
- h-card for author information
|
|
||||||
- e-content for note content
|
|
||||||
- dt-published for timestamps
|
|
||||||
- u-url for permalinks
|
|
||||||
|
|
||||||
**IndieAuth**
|
|
||||||
- OAuth 2.0 compatible flow
|
|
||||||
- Support for authorization code grant
|
|
||||||
- PKCE support recommended
|
|
||||||
- Token introspection endpoint
|
|
||||||
|
|
||||||
**Micropub**
|
|
||||||
- JSON and form-encoded content types
|
|
||||||
- Location header on creation
|
|
||||||
- Configuration endpoint
|
|
||||||
- Source endpoint for queries
|
|
||||||
|
|
||||||
### Web Standards
|
|
||||||
|
|
||||||
**HTTP**
|
|
||||||
- Proper status codes (200, 201, 400, 401, 404)
|
|
||||||
- Content-Type headers
|
|
||||||
- Cache-Control headers where appropriate
|
|
||||||
- CORS headers for API endpoints
|
|
||||||
|
|
||||||
**RSS 2.0**
|
|
||||||
- Valid XML structure
|
|
||||||
- Required channel elements
|
|
||||||
- Proper date formatting
|
|
||||||
- GUID for each item
|
|
||||||
- CDATA for HTML content
|
|
||||||
|
|
||||||
**HTML**
|
|
||||||
- Semantic HTML5 elements
|
|
||||||
- Valid markup
|
|
||||||
- Accessible forms
|
|
||||||
- Mobile-responsive design
|
|
||||||
|
|
||||||
## Security Considerations
|
|
||||||
|
|
||||||
### Authentication
|
|
||||||
- Validate all tokens before operations
|
|
||||||
- Implement token expiration
|
|
||||||
- Use secure token generation
|
|
||||||
- Protect admin routes
|
|
||||||
|
|
||||||
### Input Validation
|
|
||||||
- Sanitize markdown input
|
|
||||||
- Validate Micropub payloads
|
|
||||||
- Prevent SQL injection
|
|
||||||
- Escape HTML appropriately
|
|
||||||
|
|
||||||
### HTTP Security
|
|
||||||
- Use HTTPS in production
|
|
||||||
- Set secure headers
|
|
||||||
- Implement CSRF protection
|
|
||||||
- Rate limit API endpoints
|
|
||||||
|
|
||||||
## Performance Guidelines
|
|
||||||
|
|
||||||
### Response Times
|
|
||||||
- API responses < 100ms
|
|
||||||
- Page loads < 200ms
|
|
||||||
- RSS feed generation < 300ms
|
|
||||||
|
|
||||||
### Caching Strategy
|
|
||||||
- Cache RSS feed (5 minutes)
|
|
||||||
- Cache static assets
|
|
||||||
- Database query optimization
|
|
||||||
- Minimize external dependencies
|
|
||||||
|
|
||||||
### Resource Usage
|
|
||||||
- Efficient database queries
|
|
||||||
- Minimal memory footprint
|
|
||||||
- Optimize HTML/CSS delivery
|
|
||||||
- Compress responses
|
|
||||||
|
|
||||||
## Testing Checklist
|
|
||||||
|
|
||||||
- [ ] Create notes via web interface
|
|
||||||
- [ ] Create notes via Micropub JSON
|
|
||||||
- [ ] Create notes via Micropub form-encoded
|
|
||||||
- [ ] RSS feed validates (W3C validator)
|
|
||||||
- [ ] IndieAuth login flow works
|
|
||||||
- [ ] Micropub client authentication
|
|
||||||
- [ ] Notes display with proper microformats
|
|
||||||
- [ ] API returns correct status codes
|
|
||||||
- [ ] Markdown renders correctly
|
|
||||||
- [ ] Slugs generate uniquely
|
|
||||||
- [ ] Timestamps record accurately
|
|
||||||
- [ ] Token expiration works
|
|
||||||
- [ ] Rate limiting functions
|
|
||||||
- [ ] All unit tests pass
|
|
||||||
|
|
||||||
## Validation Tools
|
|
||||||
|
|
||||||
**IndieWeb**
|
|
||||||
- https://indiewebify.me/ - Verify microformats
|
|
||||||
- https://indieauth.com/validate - Test IndieAuth
|
|
||||||
- https://micropub.rocks/ - Micropub test suite
|
|
||||||
|
|
||||||
**Web Standards**
|
|
||||||
- https://validator.w3.org/feed/ - RSS validator
|
|
||||||
- https://validator.w3.org/ - HTML validator
|
|
||||||
- https://jsonlint.com/ - JSON validator
|
|
||||||
|
|
||||||
## Resources
|
|
||||||
|
|
||||||
### Specifications
|
|
||||||
- IndieWeb Notes: https://indieweb.org/note
|
|
||||||
- Micropub Spec: https://micropub.spec.indieweb.org
|
|
||||||
- IndieAuth Spec: https://indieauth.spec.indieweb.org
|
|
||||||
- Microformats2: http://microformats.org/wiki/h-entry
|
|
||||||
- RSS 2.0 Spec: https://www.rssboard.org/rss-specification
|
|
||||||
|
|
||||||
### Testing & Validation
|
|
||||||
- Micropub Test Suite: https://micropub.rocks/
|
|
||||||
- IndieAuth Testing: https://indieauth.com/
|
|
||||||
- Microformats Parser: https://pin13.net/mf2/
|
|
||||||
|
|
||||||
### Example Implementations
|
|
||||||
- IndieWeb Examples: https://indieweb.org/examples
|
|
||||||
- Micropub Clients: https://indieweb.org/Micropub/Clients
|
|
||||||
|
|
||||||
## Development Principles
|
|
||||||
|
|
||||||
1. **Minimal Code**: Every feature must justify its complexity
|
|
||||||
2. **Standards First**: Follow specifications exactly
|
|
||||||
3. **User Control**: User owns their data completely
|
|
||||||
4. **No Lock-in**: Data must be portable and exportable
|
|
||||||
5. **Progressive Enhancement**: Core functionality works without JavaScript
|
|
||||||
6. **Documentation**: Code should be self-documenting
|
|
||||||
7. **Test Coverage**: Critical paths must have tests
|
|
||||||
|
|
||||||
## Future Considerations (Post-V1)
|
|
||||||
|
|
||||||
Potential V2 features:
|
|
||||||
- Webmentions support
|
|
||||||
- Media uploads (photos)
|
|
||||||
- Additional post types (articles, replies)
|
|
||||||
- POSSE to Mastodon/ActivityPub
|
|
||||||
- Full-text search
|
|
||||||
- Draft/scheduled posts
|
|
||||||
- Multiple IndieAuth providers
|
|
||||||
- Backup/restore functionality
|
|
||||||
- Import from other platforms
|
|
||||||
- Export in multiple formats
|
|
||||||
|
|
||||||
## Success Criteria
|
|
||||||
|
|
||||||
The project is successful when:
|
|
||||||
- A user can publish notes from any Micropub client
|
|
||||||
- Notes appear in RSS readers immediately
|
|
||||||
- The system runs on minimal resources
|
|
||||||
- Code is readable and maintainable
|
|
||||||
- All IndieWeb validators pass
|
|
||||||
- Setup takes less than 5 minutes
|
|
||||||
- System runs for months without intervention
|
|
||||||
108
CLAUDE.md
108
CLAUDE.md
@@ -1,4 +1,104 @@
|
|||||||
- we use uv for python venv management in this project so commands involving python probably need to be run with uv
|
# Claude Agent Instructions
|
||||||
- whenever you invoke agent-developer you will remind it to document what it does in docs/reports, update the changelog, and increment the version number where appropriate inline with docs/standards/versioning-strategy.md
|
|
||||||
- when invoking agent-developer remind in that we are using uv and that any pyrhon commands need to be run with uv
|
This file contains operational instructions for Claude agents working on this project.
|
||||||
- when invoking agent-developer make sure it follows proper git protocol as defined in docs/standards/git-branching-strategy.md
|
|
||||||
|
## Python Environment
|
||||||
|
|
||||||
|
- We use **uv** for Python virtual environment management
|
||||||
|
- All Python commands must be run with `uv run` prefix
|
||||||
|
- Example: `uv run pytest`, `uv run flask run`
|
||||||
|
|
||||||
|
## Agent-Architect Protocol
|
||||||
|
|
||||||
|
When invoking the agent-architect, always remind it to:
|
||||||
|
|
||||||
|
1. Review documentation in docs/ before working on the task it is given
|
||||||
|
- docs/architecture, docs/decisions, docs/standards are of particular interest
|
||||||
|
|
||||||
|
2. Give it the map of the documentation folder as described in the "Understanding the docs/ Structure" section below
|
||||||
|
|
||||||
|
3. Search for authoritative documentation for any web standard it is implementing on https://www.w3.org/
|
||||||
|
|
||||||
|
4. If it is reviewing a developers implementation report and it is accepts the completed work it should go back and update the project plan to reflect the completed work
|
||||||
|
|
||||||
|
## Agent-Developer Protocol
|
||||||
|
|
||||||
|
When invoking the agent-developer, always remind it to:
|
||||||
|
|
||||||
|
1. **Document work in reports**
|
||||||
|
- Create implementation reports in `docs/reports/`
|
||||||
|
- Include date in filename: `YYYY-MM-DD-description.md`
|
||||||
|
|
||||||
|
2. **Update the changelog**
|
||||||
|
- Add entries to `CHANGELOG.md` for user-facing changes
|
||||||
|
- Follow existing format
|
||||||
|
|
||||||
|
3. **Version number management**
|
||||||
|
- Increment version numbers according to `docs/standards/versioning-strategy.md`
|
||||||
|
- Update version in `starpunk/__init__.py`
|
||||||
|
|
||||||
|
4. **Follow git protocol**
|
||||||
|
- Adhere to git branching strategy in `docs/standards/git-branching-strategy.md`
|
||||||
|
- Create feature branches for non-trivial changes
|
||||||
|
- Write clear commit messages
|
||||||
|
|
||||||
|
## Documentation Navigation
|
||||||
|
|
||||||
|
### Understanding the docs/ Structure
|
||||||
|
|
||||||
|
The `docs/` folder is organized by document type and purpose:
|
||||||
|
|
||||||
|
- **`docs/architecture/`** - System design overviews, component diagrams, architectural patterns
|
||||||
|
- **`docs/decisions/`** - Architecture Decision Records (ADRs), numbered sequentially (ADR-001, ADR-002, etc.)
|
||||||
|
- **`docs/deployment/`** - Deployment guides, infrastructure setup, operations documentation
|
||||||
|
- **`docs/design/`** - Detailed design documents, feature specifications, phase plans
|
||||||
|
- **`docs/examples/`** - Example implementations, code samples, usage patterns
|
||||||
|
- **`docs/projectplan/`** - Project roadmaps, implementation plans, feature scope definitions
|
||||||
|
- **`docs/reports/`** - Implementation reports from developers (dated: YYYY-MM-DD-description.md)
|
||||||
|
- **`docs/reviews/`** - Architectural reviews, design critiques, retrospectives
|
||||||
|
- **`docs/standards/`** - Coding standards, conventions, processes, workflows
|
||||||
|
|
||||||
|
### Where to Find Documentation
|
||||||
|
|
||||||
|
- **Before implementing a feature**: Check `docs/decisions/` for relevant ADRs and `docs/design/` for specifications
|
||||||
|
- **Understanding system architecture**: Start with `docs/architecture/overview.md`
|
||||||
|
- **Coding guidelines**: See `docs/standards/` for language-specific standards and best practices
|
||||||
|
- **Past implementation context**: Review `docs/reports/` for similar work (sorted by date)
|
||||||
|
- **Project roadmap and scope**: Refer to `docs/projectplan/`
|
||||||
|
|
||||||
|
### Where to Create New Documentation
|
||||||
|
|
||||||
|
**Create an ADR (`docs/decisions/`)** when:
|
||||||
|
- Making architectural decisions that affect system design
|
||||||
|
- Choosing between competing technical approaches
|
||||||
|
- Establishing patterns that others should follow
|
||||||
|
- Format: `ADR-NNN-brief-title.md` (find next number sequentially)
|
||||||
|
|
||||||
|
**Create a design doc (`docs/design/`)** when:
|
||||||
|
- Planning a complex feature implementation
|
||||||
|
- Detailing technical specifications
|
||||||
|
- Documenting multi-phase development plans
|
||||||
|
|
||||||
|
**Create an implementation report (`docs/reports/`)** when:
|
||||||
|
- Completing significant development work
|
||||||
|
- Documenting implementation details for architect review
|
||||||
|
- Format: `YYYY-MM-DD-brief-description.md`
|
||||||
|
|
||||||
|
**Update standards (`docs/standards/`)** when:
|
||||||
|
- Establishing new coding conventions
|
||||||
|
- Documenting processes or workflows
|
||||||
|
- Creating checklists or guidelines
|
||||||
|
|
||||||
|
### Key Documentation References
|
||||||
|
|
||||||
|
- **Architecture**: See `docs/architecture/overview.md`
|
||||||
|
- **Implementation Plan**: See `docs/projectplan/v1/implementation-plan.md`
|
||||||
|
- **Feature Scope**: See `docs/projectplan/v1/feature-scope.md`
|
||||||
|
- **Coding Standards**: See `docs/standards/python-coding-standards.md`
|
||||||
|
- **Testing**: See `docs/standards/testing-checklist.md`
|
||||||
|
|
||||||
|
## Project Philosophy
|
||||||
|
|
||||||
|
"Every line of code must justify its existence. When in doubt, leave it out."
|
||||||
|
|
||||||
|
Keep implementations minimal, standards-compliant, and maintainable.
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
# StarPunk Architecture Overview
|
# StarPunk Architecture Overview
|
||||||
|
|
||||||
|
**Version**: v0.9.5 (2025-11-24)
|
||||||
|
**Status**: Pre-V1 Release (Micropub endpoint pending)
|
||||||
|
|
||||||
## Executive Summary
|
## Executive Summary
|
||||||
|
|
||||||
StarPunk is a minimal, single-user IndieWeb CMS designed around the principle: "Every line of code must justify its existence." The architecture prioritizes simplicity, standards compliance, and user data ownership through careful technology selection and hybrid data storage.
|
StarPunk is a minimal, single-user IndieWeb CMS designed around the principle: "Every line of code must justify its existence." The architecture prioritizes simplicity, standards compliance, and user data ownership through careful technology selection and hybrid data storage.
|
||||||
|
|
||||||
**Core Architecture**: API-first Flask application with hybrid file+database storage, server-side rendering, and delegated authentication.
|
**Core Architecture**: Flask web application with hybrid file+database storage, server-side rendering, delegated authentication (IndieLogin.com), and containerized deployment.
|
||||||
|
|
||||||
|
**Technology Stack**: Python 3.11, Flask, SQLite, Jinja2, Gunicorn, uv package manager
|
||||||
|
**Deployment**: Container-based (Podman/Docker) with automated CI/CD (Gitea Actions)
|
||||||
|
**Authentication**: IndieAuth via IndieLogin.com with PKCE security
|
||||||
|
|
||||||
## System Architecture
|
## System Architecture
|
||||||
|
|
||||||
@@ -114,76 +121,107 @@ All functionality exposed via API, web interface consumes API. This enables:
|
|||||||
#### Public Interface
|
#### Public Interface
|
||||||
**Purpose**: Display published notes to the world
|
**Purpose**: Display published notes to the world
|
||||||
**Technology**: Server-side rendered HTML (Jinja2)
|
**Technology**: Server-side rendered HTML (Jinja2)
|
||||||
**Routes**:
|
**Status**: ✅ IMPLEMENTED (v0.5.0)
|
||||||
- `/` - Homepage with recent notes
|
|
||||||
- `/note/{slug}` - Individual note permalink
|
**Routes** (Implemented):
|
||||||
- `/feed.xml` - RSS feed
|
- `GET /` - Homepage with recent published notes
|
||||||
|
- `GET /note/<slug>` - Individual note permalink
|
||||||
|
- `GET /feed.xml` - RSS 2.0 feed (v0.6.0)
|
||||||
|
- `GET /health` - Health check endpoint (v0.6.0)
|
||||||
|
|
||||||
**Features**:
|
**Features**:
|
||||||
- Microformats2 markup (h-entry, h-card)
|
- Microformats2 markup (h-entry, h-card, h-feed) - ⚠️ Not validated
|
||||||
- Reverse chronological note list
|
- Reverse chronological note list
|
||||||
- Clean, minimal design
|
- Clean, minimal responsive CSS
|
||||||
- Mobile-responsive
|
- Mobile-responsive
|
||||||
- No JavaScript required
|
- No JavaScript required
|
||||||
|
|
||||||
#### Admin Interface
|
#### Admin Interface
|
||||||
**Purpose**: Manage notes (create, edit, publish)
|
**Purpose**: Manage notes (create, edit, publish)
|
||||||
**Technology**: Server-side rendered HTML (Jinja2) + optional vanilla JS
|
**Technology**: Server-side rendered HTML (Jinja2)
|
||||||
**Routes**:
|
**Status**: ✅ IMPLEMENTED (v0.5.2)
|
||||||
- `/admin/login` - Authentication
|
|
||||||
- `/admin` - Dashboard (list of all notes)
|
**Routes** (Implemented):
|
||||||
- `/admin/new` - Create new note
|
- `GET /auth/login` - Login form (v0.9.2: moved from /admin/login)
|
||||||
- `/admin/edit/{id}` - Edit existing note
|
- `POST /auth/login` - Initiate IndieLogin OAuth flow
|
||||||
|
- `GET /auth/callback` - Handle IndieLogin callback
|
||||||
|
- `POST /auth/logout` - Logout and destroy session
|
||||||
|
- `GET /admin` - Dashboard (list of all notes, published + drafts)
|
||||||
|
- `GET /admin/new` - Create note form
|
||||||
|
- `POST /admin/new` - Create note handler
|
||||||
|
- `GET /admin/edit/<slug>` - Edit note form
|
||||||
|
- `POST /admin/edit/<slug>` - Update note handler
|
||||||
|
- `POST /admin/delete/<slug>` - Delete note handler
|
||||||
|
|
||||||
|
**Development Routes** (DEV_MODE only):
|
||||||
|
- `GET /dev/login` - Development authentication bypass (v0.5.0)
|
||||||
|
|
||||||
**Features**:
|
**Features**:
|
||||||
- Markdown editor
|
- Markdown editor (textarea)
|
||||||
- Optional real-time preview (JS enhancement)
|
- No real-time preview (deferred to V2)
|
||||||
- Publish/draft toggle
|
- Publish/draft toggle
|
||||||
- Protected by session authentication
|
- Protected by session authentication
|
||||||
|
- Flash messages for feedback
|
||||||
|
- Note: Admin routes changed from `/admin/*` to `/auth/*` for auth in v0.9.2
|
||||||
|
|
||||||
### API Layer
|
### API Layer
|
||||||
|
|
||||||
#### Notes API
|
#### Notes API
|
||||||
**Purpose**: CRUD operations for notes
|
**Purpose**: RESTful CRUD operations for notes
|
||||||
**Authentication**: Session-based (admin interface)
|
**Authentication**: Session-based (admin interface)
|
||||||
**Routes**:
|
**Status**: ❌ NOT IMPLEMENTED (Optional for V1, deferred to V2)
|
||||||
|
|
||||||
|
**Planned Routes** (Not Implemented):
|
||||||
```
|
```
|
||||||
GET /api/notes List published notes
|
GET /api/notes List published notes (JSON)
|
||||||
POST /api/notes Create new note
|
POST /api/notes Create new note (JSON)
|
||||||
GET /api/notes/{id} Get single note
|
GET /api/notes/<slug> Get single note (JSON)
|
||||||
PUT /api/notes/{id} Update note
|
PUT /api/notes/<slug> Update note (JSON)
|
||||||
DELETE /api/notes/{id} Delete note
|
DELETE /api/notes/<slug> Delete note (JSON)
|
||||||
```
|
```
|
||||||
|
|
||||||
**Response Format**: JSON
|
**Current Workaround**: Admin interface uses HTML forms (POST), not JSON API
|
||||||
|
**Note**: Not required for V1, admin interface is fully functional without REST API
|
||||||
|
|
||||||
#### Micropub Endpoint
|
#### Micropub Endpoint
|
||||||
**Purpose**: Accept posts from external Micropub clients
|
**Purpose**: Accept posts from external Micropub clients (Quill, Indigenous, etc.)
|
||||||
**Authentication**: IndieAuth bearer tokens
|
**Authentication**: IndieAuth bearer tokens
|
||||||
**Routes**:
|
**Status**: ❌ NOT IMPLEMENTED (Critical blocker for V1)
|
||||||
|
|
||||||
|
**Planned Routes** (Not Implemented):
|
||||||
```
|
```
|
||||||
POST /api/micropub Create note (h-entry)
|
POST /api/micropub Create note (h-entry)
|
||||||
GET /api/micropub?q=config Query configuration
|
GET /api/micropub?q=config Query configuration
|
||||||
GET /api/micropub?q=source Query note source
|
GET /api/micropub?q=source Query note source by URL
|
||||||
```
|
```
|
||||||
|
|
||||||
**Content Types**:
|
**Planned Content Types**:
|
||||||
- application/json
|
- application/json
|
||||||
- application/x-www-form-urlencoded
|
- application/x-www-form-urlencoded
|
||||||
|
|
||||||
**Compliance**: Full Micropub specification
|
**Target Compliance**: Micropub specification
|
||||||
|
**Current Status**:
|
||||||
|
- Token model exists in database
|
||||||
|
- No endpoint implementation
|
||||||
|
- No token validation logic
|
||||||
|
- Will require IndieAuth token endpoint or external token service
|
||||||
|
|
||||||
#### RSS Feed
|
#### RSS Feed
|
||||||
**Purpose**: Syndicate published notes
|
**Purpose**: Syndicate published notes
|
||||||
**Technology**: feedgen library
|
**Technology**: feedgen library
|
||||||
**Route**: `/feed.xml`
|
**Status**: ✅ IMPLEMENTED (v0.6.0)
|
||||||
|
|
||||||
|
**Route**: `GET /feed.xml`
|
||||||
**Format**: Valid RSS 2.0 XML
|
**Format**: Valid RSS 2.0 XML
|
||||||
**Caching**: 5 minutes
|
**Caching**: 5 minutes server-side (configurable via FEED_CACHE_SECONDS)
|
||||||
**Features**:
|
**Features**:
|
||||||
- All published notes
|
- Limit to 50 most recent published notes (configurable via FEED_MAX_ITEMS)
|
||||||
- RFC-822 date formatting
|
- RFC-822 date formatting (pubDate)
|
||||||
- CDATA-wrapped HTML content
|
- CDATA-wrapped HTML content for feed readers
|
||||||
- Proper GUID for each item
|
- Proper GUID for each item (note permalink)
|
||||||
|
- Auto-discovery link in HTML templates (<link rel="alternate">)
|
||||||
|
- Cache-Control headers for client caching
|
||||||
|
- ETag support for conditional requests
|
||||||
|
|
||||||
### Business Logic Layer
|
### Business Logic Layer
|
||||||
|
|
||||||
@@ -207,19 +245,50 @@ GET /api/micropub?q=source Query note source
|
|||||||
**Integrity Check**: Optional scan for orphaned files/records
|
**Integrity Check**: Optional scan for orphaned files/records
|
||||||
|
|
||||||
#### Authentication
|
#### Authentication
|
||||||
**Admin Auth**: IndieLogin.com OAuth 2.0 flow
|
**Admin Auth**: IndieLogin.com OAuth 2.0 flow with PKCE
|
||||||
- User enters website URL
|
**Status**: ✅ IMPLEMENTED (v0.8.0, refined through v0.9.5)
|
||||||
- Redirect to indielogin.com
|
|
||||||
- Verify identity via RelMeAuth or email
|
**Flow**:
|
||||||
- Return verified "me" URL
|
1. User enters website URL (their "me" identity)
|
||||||
- Create session token
|
2. Generate PKCE code_verifier and code_challenge (SHA-256)
|
||||||
- Store in HttpOnly cookie
|
3. Store state token + code_verifier in database (5 min expiry)
|
||||||
|
4. Redirect to indielogin.com/authorize with:
|
||||||
|
- client_id (SITE_URL with trailing slash)
|
||||||
|
- redirect_uri (SITE_URL/auth/callback)
|
||||||
|
- state (CSRF protection)
|
||||||
|
- code_challenge + code_challenge_method (S256)
|
||||||
|
5. IndieLogin.com verifies identity via RelMeAuth or email
|
||||||
|
6. Callback to /auth/callback with code + state
|
||||||
|
7. Verify state token (CSRF check)
|
||||||
|
8. POST code + code_verifier to indielogin.com/authorize (NOT /token)
|
||||||
|
9. Receive verified "me" URL
|
||||||
|
10. Verify "me" matches ADMIN_ME config
|
||||||
|
11. Create session with SHA-256 hashed token
|
||||||
|
12. Store in HttpOnly, Secure, SameSite=Lax cookie named "starpunk_session"
|
||||||
|
|
||||||
|
**Security Features** (v0.8.0-v0.9.5):
|
||||||
|
- PKCE prevents authorization code interception
|
||||||
|
- State tokens prevent CSRF attacks
|
||||||
|
- Session token hashing (SHA-256) before database storage
|
||||||
|
- Single-use state tokens with short expiry
|
||||||
|
- Automatic trailing slash normalization on SITE_URL (v0.9.1)
|
||||||
|
- Uses authorization endpoint (not token endpoint) per IndieAuth spec (v0.9.4)
|
||||||
|
- Session cookie renamed to avoid Flask session collision (v0.5.1)
|
||||||
|
|
||||||
|
**Development Mode** (v0.5.0):
|
||||||
|
- `/dev/login` bypasses IndieLogin for local development
|
||||||
|
- Requires DEV_MODE=true and DEV_ADMIN_ME configuration
|
||||||
|
- Shows warning in logs
|
||||||
|
|
||||||
**Micropub Auth**: IndieAuth token verification
|
**Micropub Auth**: IndieAuth token verification
|
||||||
- Client obtains token via IndieAuth flow
|
**Status**: ❌ NOT IMPLEMENTED (Required for Micropub)
|
||||||
|
|
||||||
|
**Planned Implementation**:
|
||||||
|
- Client obtains token via external IndieAuth token endpoint
|
||||||
- Token sent as Bearer in Authorization header
|
- Token sent as Bearer in Authorization header
|
||||||
- Verify token exists and not expired
|
- Verify token exists in database and not expired
|
||||||
- Check scope permissions
|
- Check scope permissions (create, update, delete)
|
||||||
|
- OR: Delegate token verification to external IndieAuth server
|
||||||
|
|
||||||
### Data Layer
|
### Data Layer
|
||||||
|
|
||||||
@@ -246,17 +315,32 @@ data/notes/
|
|||||||
#### Database Storage
|
#### Database Storage
|
||||||
**Location**: `data/starpunk.db`
|
**Location**: `data/starpunk.db`
|
||||||
**Engine**: SQLite3
|
**Engine**: SQLite3
|
||||||
|
**Status**: ✅ IMPLEMENTED with automatic migration system (v0.9.0)
|
||||||
|
|
||||||
**Tables**:
|
**Tables**:
|
||||||
- `notes` - Metadata (slug, file_path, published, timestamps, hash)
|
- `notes` - Note metadata (slug, file_path, published, created_at, updated_at, deleted_at, content_hash)
|
||||||
- `sessions` - Auth sessions (token, me, expiry)
|
- `sessions` - Admin auth sessions (session_token_hash, me, created_at, expires_at, last_used_at, user_agent, ip_address)
|
||||||
- `tokens` - Micropub tokens (token, me, client_id, scope)
|
- `tokens` - Micropub bearer tokens (token, me, client_id, scope, created_at, expires_at) - **Table exists but unused**
|
||||||
- `auth_state` - CSRF tokens (state, expiry)
|
- `auth_state` - CSRF state tokens (state, created_at, expires_at, redirect_uri, code_verifier)
|
||||||
|
- `schema_migrations` - Migration tracking (migration_name, applied_at) - **Added v0.9.0**
|
||||||
|
|
||||||
**Indexes**:
|
**Indexes**:
|
||||||
- `notes.created_at` (DESC) - Fast chronological queries
|
- `notes.created_at` (DESC) - Fast chronological queries
|
||||||
- `notes.published` - Fast filtering
|
- `notes.published` - Fast published note filtering
|
||||||
- `notes.slug` - Fast lookup by slug
|
- `notes.slug` (UNIQUE) - Fast lookup by slug, uniqueness enforcement
|
||||||
- `sessions.session_token` - Fast auth checks
|
- `notes.deleted_at` - Fast soft-delete filtering
|
||||||
|
- `sessions.session_token_hash` (UNIQUE) - Fast auth checks
|
||||||
|
- `sessions.me` - Fast user lookups
|
||||||
|
- `auth_state.state` (UNIQUE) - Fast state token validation
|
||||||
|
|
||||||
|
**Migration System** (v0.9.0):
|
||||||
|
- Automatic schema updates on application startup
|
||||||
|
- Migration files in `migrations/` directory (SQL format)
|
||||||
|
- Executed in alphanumeric order (001, 002, 003...)
|
||||||
|
- Fresh database detection (marks migrations as applied without execution)
|
||||||
|
- Legacy database detection (applies pending migrations automatically)
|
||||||
|
- Migration tracking in schema_migrations table
|
||||||
|
- Fail-safe: Application refuses to start if migrations fail
|
||||||
|
|
||||||
**Queries**: Direct SQL using Python sqlite3 module (no ORM)
|
**Queries**: Direct SQL using Python sqlite3 module (no ORM)
|
||||||
|
|
||||||
@@ -361,71 +445,96 @@ data/notes/
|
|||||||
9. Client receives note URL, displays success
|
9. Client receives note URL, displays success
|
||||||
```
|
```
|
||||||
|
|
||||||
### IndieLogin Authentication Flow
|
### IndieLogin Authentication Flow (v0.9.5 with PKCE)
|
||||||
|
|
||||||
```
|
```
|
||||||
1. User visits /admin/login
|
1. User visits /auth/login
|
||||||
↓
|
↓
|
||||||
2. User enters their website: https://alice.example.com
|
2. User enters their website: https://alice.example.com
|
||||||
↓
|
↓
|
||||||
3. POST to /admin/login with "me" parameter
|
3. POST to /auth/login with "me" parameter
|
||||||
↓
|
↓
|
||||||
4. Validate URL format
|
4. Validate URL format (must be https://)
|
||||||
↓
|
↓
|
||||||
5. Generate random state token (CSRF protection)
|
5. Generate PKCE code_verifier (43 random bytes, base64-url encoded)
|
||||||
↓
|
↓
|
||||||
6. Store state in database with 5-minute expiry
|
6. Generate code_challenge from code_verifier (SHA256 hash, base64-url encoded)
|
||||||
↓
|
↓
|
||||||
7. Build IndieLogin authorization URL:
|
7. Generate random state token (CSRF protection)
|
||||||
https://indielogin.com/auth?
|
↓
|
||||||
|
8. Store state + code_verifier in auth_state table (5-minute expiry)
|
||||||
|
↓
|
||||||
|
9. Normalize client_id by adding trailing slash if missing (v0.9.1)
|
||||||
|
↓
|
||||||
|
10. Build IndieLogin authorization URL:
|
||||||
|
https://indielogin.com/authorize?
|
||||||
me=https://alice.example.com
|
me=https://alice.example.com
|
||||||
client_id=https://starpunk.example.com
|
client_id=https://starpunk.example.com/ (note trailing slash)
|
||||||
redirect_uri=https://starpunk.example.com/auth/callback
|
redirect_uri=https://starpunk.example.com/auth/callback
|
||||||
state={random_state}
|
state={random_state}
|
||||||
|
code_challenge={code_challenge}
|
||||||
|
code_challenge_method=S256
|
||||||
↓
|
↓
|
||||||
8. Redirect user to IndieLogin
|
11. Redirect user to IndieLogin
|
||||||
↓
|
↓
|
||||||
9. IndieLogin verifies user's identity:
|
12. IndieLogin verifies user's identity:
|
||||||
- Checks rel="me" links on alice.example.com
|
- Checks rel="me" links on alice.example.com
|
||||||
- Or sends email verification
|
- Or sends email verification
|
||||||
- User authenticates via chosen method
|
- User authenticates via chosen method
|
||||||
↓
|
↓
|
||||||
10. IndieLogin redirects back:
|
13. IndieLogin redirects back:
|
||||||
/auth/callback?code={auth_code}&state={state}
|
/auth/callback?code={auth_code}&state={state}
|
||||||
↓
|
↓
|
||||||
11. Verify state matches stored value (CSRF check)
|
14. Verify state matches stored value (CSRF check, single-use)
|
||||||
↓
|
↓
|
||||||
12. Exchange code for verified identity:
|
15. Retrieve code_verifier from database using state
|
||||||
POST https://indielogin.com/auth
|
↓
|
||||||
|
16. Delete state token (single-use enforcement)
|
||||||
|
↓
|
||||||
|
17. Exchange code for verified identity (v0.9.4: uses /authorize, not /token):
|
||||||
|
POST https://indielogin.com/authorize
|
||||||
code={auth_code}
|
code={auth_code}
|
||||||
client_id=https://starpunk.example.com
|
client_id=https://starpunk.example.com/
|
||||||
redirect_uri=https://starpunk.example.com/auth/callback
|
redirect_uri=https://starpunk.example.com/auth/callback
|
||||||
|
code_verifier={code_verifier}
|
||||||
↓
|
↓
|
||||||
13. IndieLogin returns: {"me": "https://alice.example.com"}
|
18. IndieLogin returns: {"me": "https://alice.example.com"}
|
||||||
↓
|
↓
|
||||||
14. Verify me == ADMIN_ME (config)
|
19. Verify me == ADMIN_ME (config)
|
||||||
↓
|
↓
|
||||||
15. If match:
|
20. If match:
|
||||||
- Generate session token
|
- Generate session token (secrets.token_urlsafe(32))
|
||||||
- Insert into sessions table
|
- Hash token with SHA-256
|
||||||
- Set HttpOnly, Secure cookie
|
- Insert into sessions table with hash (not plaintext)
|
||||||
|
- Set cookie "starpunk_session" (HttpOnly, Secure, SameSite=Lax)
|
||||||
- Redirect to /admin
|
- Redirect to /admin
|
||||||
↓
|
↓
|
||||||
16. If no match:
|
21. If no match:
|
||||||
- Return "Unauthorized" error
|
- Return "Unauthorized" error
|
||||||
- Log attempt
|
- Log attempt with WARNING level
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Key Security Features**:
|
||||||
|
- PKCE prevents code interception attacks (v0.8.0)
|
||||||
|
- State tokens prevent CSRF (v0.4.0)
|
||||||
|
- Session token hashing prevents token exposure if database compromised (v0.4.0)
|
||||||
|
- Single-use state tokens (deleted after verification)
|
||||||
|
- Short-lived state tokens (5 minutes)
|
||||||
|
- Trailing slash normalization fixes client_id validation (v0.9.1)
|
||||||
|
- Correct endpoint usage (/authorize not /token) per IndieAuth spec (v0.9.4)
|
||||||
|
|
||||||
## Security Architecture
|
## Security Architecture
|
||||||
|
|
||||||
### Authentication Security
|
### Authentication Security
|
||||||
|
|
||||||
#### Session Management
|
#### Session Management
|
||||||
- **Token Generation**: `secrets.token_urlsafe(32)` (256-bit entropy)
|
- **Token Generation**: `secrets.token_urlsafe(32)` (256-bit entropy)
|
||||||
- **Storage**: Hash before storing in database
|
- **Storage**: SHA-256 hash stored in database (plaintext token NEVER stored)
|
||||||
|
- **Cookie Name**: `starpunk_session` (v0.5.1: renamed to avoid Flask session collision)
|
||||||
- **Cookies**: HttpOnly, Secure, SameSite=Lax
|
- **Cookies**: HttpOnly, Secure, SameSite=Lax
|
||||||
- **Expiry**: 30 days, extendable on use
|
- **Expiry**: 30 days, extendable on use
|
||||||
- **Validation**: Every protected route checks session
|
- **Validation**: Every protected route checks session via `@require_auth` decorator
|
||||||
|
- **Metadata**: Tracks user_agent and ip_address for audit purposes
|
||||||
|
|
||||||
#### CSRF Protection
|
#### CSRF Protection
|
||||||
- **State Tokens**: Random tokens for OAuth flows
|
- **State Tokens**: Random tokens for OAuth flows
|
||||||
@@ -577,6 +686,40 @@ if not requested_path.startswith(base_path):
|
|||||||
|
|
||||||
## Deployment Architecture
|
## Deployment Architecture
|
||||||
|
|
||||||
|
**Current State**: ✅ IMPLEMENTED (v0.6.0 - v0.9.5)
|
||||||
|
**Technology**: Container-based with Gunicorn WSGI server
|
||||||
|
**CI/CD**: Gitea Actions automated builds (v0.9.5)
|
||||||
|
|
||||||
|
### Container Deployment (v0.6.0)
|
||||||
|
|
||||||
|
**Containerfile**: Multi-stage build using Python 3.11-slim base
|
||||||
|
- Stage 1: Build dependencies with uv package manager
|
||||||
|
- Stage 2: Production image with non-root user (starpunk:1000)
|
||||||
|
- Final size: ~174MB
|
||||||
|
|
||||||
|
**Features**:
|
||||||
|
- Health check endpoint: `/health` (validates database and filesystem)
|
||||||
|
- Gunicorn WSGI server with 4 workers (configurable)
|
||||||
|
- Log rotation (10MB max, 3 files)
|
||||||
|
- Resource limits (memory, CPU)
|
||||||
|
- SELinux compatibility (volume mount flags)
|
||||||
|
- Automatic database initialization on first run
|
||||||
|
|
||||||
|
**Container Orchestration**:
|
||||||
|
- Podman-compatible (rootless, userns=keep-id)
|
||||||
|
- Docker Compose compatible
|
||||||
|
- Volume mounts for data persistence (`./data:/app/data`)
|
||||||
|
- Port mapping (8080:8000)
|
||||||
|
- Environment variables for configuration
|
||||||
|
|
||||||
|
**CI/CD Pipeline** (v0.9.5):
|
||||||
|
- Gitea Actions workflow (.gitea/workflows/build-container.yml)
|
||||||
|
- Automated builds on push to main branch
|
||||||
|
- Manual trigger support
|
||||||
|
- Container registry push
|
||||||
|
- Docker and git dependencies installed
|
||||||
|
- Node.js support for GitHub Actions compatibility
|
||||||
|
|
||||||
### Single-Server Deployment
|
### Single-Server Deployment
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -878,17 +1021,95 @@ GET /api/notes # Still works, returns V1 response
|
|||||||
- From markdown directory
|
- From markdown directory
|
||||||
- From other IndieWeb CMSs
|
- From other IndieWeb CMSs
|
||||||
|
|
||||||
|
## Implementation Status (v0.9.5)
|
||||||
|
|
||||||
|
### ✅ Fully Implemented Features
|
||||||
|
|
||||||
|
1. **Note Management** (v0.3.0)
|
||||||
|
- Full CRUD operations (create, read, update, delete)
|
||||||
|
- Hybrid file+database storage with sync
|
||||||
|
- Soft and hard delete support
|
||||||
|
- Markdown rendering
|
||||||
|
- Slug generation with uniqueness
|
||||||
|
|
||||||
|
2. **Authentication** (v0.8.0)
|
||||||
|
- IndieLogin.com OAuth 2.0 with PKCE
|
||||||
|
- Session management with token hashing
|
||||||
|
- CSRF protection with state tokens
|
||||||
|
- Development mode authentication bypass
|
||||||
|
|
||||||
|
3. **Web Interface** (v0.5.2)
|
||||||
|
- Public site: homepage and note permalinks
|
||||||
|
- Admin dashboard with note management
|
||||||
|
- Login/logout flows
|
||||||
|
- Responsive design
|
||||||
|
- Microformats2 markup (h-entry, h-card, h-feed)
|
||||||
|
|
||||||
|
4. **RSS Feed** (v0.6.0)
|
||||||
|
- RSS 2.0 compliant feed generation
|
||||||
|
- Auto-discovery links
|
||||||
|
- Server-side caching
|
||||||
|
- ETag support
|
||||||
|
|
||||||
|
5. **Container Deployment** (v0.6.0)
|
||||||
|
- Multi-stage Containerfile
|
||||||
|
- Gunicorn WSGI server
|
||||||
|
- Health check endpoint
|
||||||
|
- Volume persistence
|
||||||
|
|
||||||
|
6. **CI/CD Pipeline** (v0.9.5)
|
||||||
|
- Gitea Actions workflow
|
||||||
|
- Automated container builds
|
||||||
|
- Registry push
|
||||||
|
|
||||||
|
7. **Database Migrations** (v0.9.0)
|
||||||
|
- Automatic migration system
|
||||||
|
- Fresh database detection
|
||||||
|
- Legacy database migration
|
||||||
|
- Migration tracking
|
||||||
|
|
||||||
|
8. **Development Tools**
|
||||||
|
- uv package manager for Python
|
||||||
|
- Comprehensive test suite (87% coverage)
|
||||||
|
- Black code formatting
|
||||||
|
- Flake8 linting
|
||||||
|
|
||||||
|
### ❌ Not Yet Implemented (Blocking V1)
|
||||||
|
|
||||||
|
1. **Micropub Endpoint**
|
||||||
|
- POST /api/micropub for creating notes
|
||||||
|
- GET /api/micropub?q=config
|
||||||
|
- GET /api/micropub?q=source
|
||||||
|
- Token validation
|
||||||
|
- **Status**: Critical blocker for V1 release
|
||||||
|
|
||||||
|
2. **IndieAuth Token Endpoint**
|
||||||
|
- Token issuance for Micropub clients
|
||||||
|
- **Alternative**: May use external IndieAuth server
|
||||||
|
|
||||||
|
### ⚠️ Partially Implemented
|
||||||
|
|
||||||
|
1. **Standards Validation**
|
||||||
|
- HTML5: Markup exists, not validated
|
||||||
|
- Microformats: Markup exists, not validated
|
||||||
|
- RSS: Validated and compliant
|
||||||
|
- Micropub: N/A (not implemented)
|
||||||
|
|
||||||
|
2. **REST API** (Optional)
|
||||||
|
- JSON API for notes CRUD
|
||||||
|
- **Status**: Deferred to V2 (admin interface works without it)
|
||||||
|
|
||||||
## Success Metrics
|
## Success Metrics
|
||||||
|
|
||||||
The architecture is successful if it enables:
|
The architecture is successful if it enables:
|
||||||
|
|
||||||
1. **Fast Development**: < 1 week to implement V1
|
1. **Fast Development**: < 1 week to implement V1 - ✅ **ACHIEVED** (~35 hours, 70% complete)
|
||||||
2. **Easy Deployment**: < 5 minutes to get running
|
2. **Easy Deployment**: < 5 minutes to get running - ✅ **ACHIEVED** (containerized)
|
||||||
3. **Low Maintenance**: Runs for months without intervention
|
3. **Low Maintenance**: Runs for months without intervention - ✅ **ACHIEVED** (automated migrations)
|
||||||
4. **High Performance**: All responses < 300ms
|
4. **High Performance**: All responses < 300ms - ✅ **ACHIEVED**
|
||||||
5. **Data Ownership**: User has direct access to all content
|
5. **Data Ownership**: User has direct access to all content - ✅ **ACHIEVED** (file-based storage)
|
||||||
6. **Standards Compliance**: Passes all validators
|
6. **Standards Compliance**: Passes all validators - ⚠️ **PARTIAL** (RSS yes, others pending)
|
||||||
7. **Extensibility**: Can add V2 features without rewrite
|
7. **Extensibility**: Can add V2 features without rewrite - ✅ **ACHIEVED** (migration system ready)
|
||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
|
|||||||
541
docs/decisions/ADR-021-indieauth-provider-strategy.md
Normal file
541
docs/decisions/ADR-021-indieauth-provider-strategy.md
Normal file
@@ -0,0 +1,541 @@
|
|||||||
|
# ADR-021: IndieAuth Provider Strategy
|
||||||
|
|
||||||
|
## Status
|
||||||
|
Accepted
|
||||||
|
|
||||||
|
## Context
|
||||||
|
|
||||||
|
StarPunk currently uses IndieLogin.com for authentication (ADR-005), but there is a critical misunderstanding about how IndieAuth works that needs to be addressed.
|
||||||
|
|
||||||
|
### The Problem
|
||||||
|
|
||||||
|
The user reported that IndieLogin.com requires manual client_id registration, making it unsuitable for self-hosted software where each installation has a different domain. This concern is based on a fundamental misunderstanding of how IndieAuth differs from traditional OAuth2.
|
||||||
|
|
||||||
|
### How IndieAuth Actually Works
|
||||||
|
|
||||||
|
Unlike traditional OAuth2 providers (GitHub, Google, etc.), **IndieAuth does not require pre-registration**:
|
||||||
|
|
||||||
|
1. **DNS-Based Client Identification**: IndieAuth uses DNS as a replacement for client registration. A client application identifies itself using its own URL (e.g., `https://starpunk.example.com`), which serves as a unique identifier.
|
||||||
|
|
||||||
|
2. **No Secrets Required**: All clients are public clients. There are no client secrets to manage or register.
|
||||||
|
|
||||||
|
3. **Dynamic Redirect URI Verification**: Instead of pre-registered redirect URIs, applications publish their valid redirect URLs at their client_id URL, which authorization servers can discover.
|
||||||
|
|
||||||
|
4. **Client Metadata Discovery**: Authorization servers can optionally fetch the client_id URL to display application information (name, logo) to users during authorization.
|
||||||
|
|
||||||
|
### StarPunk's Authentication Architecture
|
||||||
|
|
||||||
|
It is critical to understand that StarPunk has **two distinct authentication flows**:
|
||||||
|
|
||||||
|
#### Flow 1: Admin Authentication (Current Misunderstanding)
|
||||||
|
**Purpose**: Authenticate the StarPunk admin user to access the admin interface
|
||||||
|
**Current Implementation**: Uses IndieLogin.com as described in ADR-005
|
||||||
|
**How it works**:
|
||||||
|
1. Admin visits `/admin/login`
|
||||||
|
2. StarPunk redirects to IndieLogin.com with its own URL as `client_id`
|
||||||
|
3. IndieLogin.com verifies the admin's identity
|
||||||
|
4. Admin receives session cookie to access StarPunk admin
|
||||||
|
|
||||||
|
**Registration Required?** NO - IndieAuth never requires registration
|
||||||
|
|
||||||
|
#### Flow 2: Micropub Client Authorization (The Real Architecture)
|
||||||
|
**Purpose**: Allow external Micropub clients to publish to StarPunk
|
||||||
|
**How it works**:
|
||||||
|
1. User configures their personal website (e.g., `https://alice.com`) with links to StarPunk's Micropub endpoint
|
||||||
|
2. User opens Micropub client (Quill, Indigenous, etc.)
|
||||||
|
3. Client discovers authorization/token endpoints from `https://alice.com` (NOT from StarPunk)
|
||||||
|
4. Client gets access token from the discovered authorization server
|
||||||
|
5. Client uses token to POST to StarPunk's Micropub endpoint
|
||||||
|
6. StarPunk verifies the token
|
||||||
|
|
||||||
|
**Who Provides Authorization?** The USER's chosen authorization server, not StarPunk
|
||||||
|
|
||||||
|
### The Real Question
|
||||||
|
|
||||||
|
StarPunk faces two architectural decisions:
|
||||||
|
|
||||||
|
1. **Admin Authentication**: How should StarPunk administrators authenticate to the admin interface?
|
||||||
|
2. **User Authorization**: Should StarPunk provide authorization/token endpoints for its users, or should users bring their own?
|
||||||
|
|
||||||
|
## Research Findings
|
||||||
|
|
||||||
|
### Alternative IndieAuth Services
|
||||||
|
|
||||||
|
**IndieLogin.com** (Current)
|
||||||
|
- Actively maintained by Aaron Parecki (IndieAuth spec editor)
|
||||||
|
- Supports multiple auth methods: RelMeAuth, email, PGP, BlueSky OAuth (added 2025)
|
||||||
|
- **No registration required** - this was the key misunderstanding
|
||||||
|
- Free, community service
|
||||||
|
- High availability
|
||||||
|
|
||||||
|
**tokens.indieauth.com**
|
||||||
|
- Provides token endpoint functionality
|
||||||
|
- Separate from authorization endpoint
|
||||||
|
- Also maintained by IndieWeb community
|
||||||
|
- Also requires no registration
|
||||||
|
|
||||||
|
**Other Services**
|
||||||
|
- No other widely-used public IndieAuth providers found
|
||||||
|
- Most implementations are self-hosted (see below)
|
||||||
|
|
||||||
|
### Self-Hosted IndieAuth Implementations
|
||||||
|
|
||||||
|
**Taproot/IndieAuth** (PHP)
|
||||||
|
- Complexity: Moderate (7/10)
|
||||||
|
- Full-featured: Authorization + token endpoints
|
||||||
|
- PSR-7 compatible, well-tested (100% coverage)
|
||||||
|
- Lightweight dependencies (Guzzle, mf2)
|
||||||
|
- Production-ready since v0.1.0
|
||||||
|
|
||||||
|
**Selfauth** (PHP)
|
||||||
|
- Complexity: Low (3/10)
|
||||||
|
- **Limitation**: Authorization endpoint ONLY (no token endpoint)
|
||||||
|
- Cannot be used for Micropub (requires token endpoint)
|
||||||
|
- Suitable only for simple authentication use cases
|
||||||
|
|
||||||
|
**hacdias/indieauth** (Go)
|
||||||
|
- Complexity: Moderate (6/10)
|
||||||
|
- Provides both server and client libraries
|
||||||
|
- Modern Go implementation
|
||||||
|
- Used in production by author
|
||||||
|
|
||||||
|
**Custom Implementation** (Python)
|
||||||
|
- Complexity: High (8/10)
|
||||||
|
- Must implement IndieAuth spec 1.1
|
||||||
|
- Required endpoints:
|
||||||
|
- Authorization endpoint (authentication + code generation)
|
||||||
|
- Token endpoint (token issuance + verification)
|
||||||
|
- Metadata endpoint (server discovery)
|
||||||
|
- Introspection endpoint (token verification)
|
||||||
|
- Must support:
|
||||||
|
- PKCE (required by spec)
|
||||||
|
- Client metadata discovery
|
||||||
|
- Profile URL validation
|
||||||
|
- Scope-based permissions
|
||||||
|
- Token revocation
|
||||||
|
- Estimated effort: 40-60 hours for full implementation
|
||||||
|
- Ongoing maintenance burden for security updates
|
||||||
|
|
||||||
|
## Decision
|
||||||
|
|
||||||
|
**Recommendation: Continue Using IndieLogin.com with Clarified Architecture**
|
||||||
|
|
||||||
|
StarPunk should:
|
||||||
|
|
||||||
|
1. **For Admin Authentication**: Continue using IndieLogin.com (no changes needed)
|
||||||
|
- No registration required
|
||||||
|
- Works out of the box for self-hosted installations
|
||||||
|
- Each StarPunk instance uses its own domain as client_id
|
||||||
|
- Zero maintenance burden
|
||||||
|
|
||||||
|
2. **For Micropub Authorization**: Document that users must provide their own authorization server
|
||||||
|
- User configures their personal domain with IndieAuth endpoints
|
||||||
|
- User can choose:
|
||||||
|
- IndieLogin.com (easiest)
|
||||||
|
- Self-hosted IndieAuth server (advanced)
|
||||||
|
- Any other IndieAuth-compliant service
|
||||||
|
- StarPunk only verifies tokens, doesn't issue them
|
||||||
|
|
||||||
|
3. **For V2 Consideration**: Optionally provide built-in authorization server
|
||||||
|
- Would allow StarPunk to be a complete standalone solution
|
||||||
|
- Users could use StarPunk's domain as their identity
|
||||||
|
- Requires implementing full IndieAuth server (40-60 hours)
|
||||||
|
- Only pursue if there is strong user demand
|
||||||
|
|
||||||
|
## Rationale
|
||||||
|
|
||||||
|
### Why Continue with IndieLogin.com
|
||||||
|
|
||||||
|
**Simplicity Score: 10/10**
|
||||||
|
- Zero configuration required
|
||||||
|
- No registration process
|
||||||
|
- Works immediately for any domain
|
||||||
|
- Battle-tested by IndieWeb community
|
||||||
|
- The original concern (manual registration) does not exist
|
||||||
|
|
||||||
|
**Fitness Score: 10/10**
|
||||||
|
- Perfect for single-user CMS
|
||||||
|
- Aligns with IndieWeb principles
|
||||||
|
- User controls their identity
|
||||||
|
- No lock-in (user can switch authorization servers)
|
||||||
|
|
||||||
|
**Maintenance Score: 10/10**
|
||||||
|
- Externally maintained
|
||||||
|
- Security updates handled by community
|
||||||
|
- No code to maintain in StarPunk
|
||||||
|
- Proven reliability and uptime
|
||||||
|
|
||||||
|
**Standards Compliance: Pass**
|
||||||
|
- Full IndieAuth spec compliance
|
||||||
|
- OAuth 2.0 compatible
|
||||||
|
- Supports modern extensions (PKCE, client metadata)
|
||||||
|
|
||||||
|
### Why Not Self-Host (for V1)
|
||||||
|
|
||||||
|
**Complexity vs Benefit**
|
||||||
|
- Self-hosting adds 40-60 hours of development
|
||||||
|
- Ongoing security maintenance burden
|
||||||
|
- Solves a problem that doesn't exist (no registration required)
|
||||||
|
- Violates "every line of code must justify its existence"
|
||||||
|
|
||||||
|
**User Perspective**
|
||||||
|
- Users already need a domain for IndieWeb
|
||||||
|
- Most users will use IndieLogin.com or similar service
|
||||||
|
- Advanced users can self-host their own IndieAuth server
|
||||||
|
- StarPunk doesn't need to solve this problem
|
||||||
|
|
||||||
|
**Alternative Philosophy**
|
||||||
|
- StarPunk is a Micropub SERVER, not an authorization server
|
||||||
|
- Separation of concerns: publishing vs identity
|
||||||
|
- Users should control their own identity infrastructure
|
||||||
|
- StarPunk focuses on doing one thing well: publishing notes
|
||||||
|
|
||||||
|
## Architectural Clarification
|
||||||
|
|
||||||
|
### Current Architecture (Correct Understanding)
|
||||||
|
|
||||||
|
```
|
||||||
|
┌─────────────────────────────────────────────────────────────┐
|
||||||
|
│ Flow 1: Admin Authentication │
|
||||||
|
│ │
|
||||||
|
│ StarPunk Admin │
|
||||||
|
│ ↓ │
|
||||||
|
│ StarPunk (/admin/login) │
|
||||||
|
│ ↓ (redirect with client_id=https://starpunk.example) │
|
||||||
|
│ IndieLogin.com (verifies admin identity) │
|
||||||
|
│ ↓ (returns verified "me" URL) │
|
||||||
|
│ StarPunk (creates session) │
|
||||||
|
└─────────────────────────────────────────────────────────────┘
|
||||||
|
|
||||||
|
┌─────────────────────────────────────────────────────────────┐
|
||||||
|
│ Flow 2: Micropub Publishing │
|
||||||
|
│ │
|
||||||
|
│ User's Website (https://alice.com) │
|
||||||
|
│ Links to: │
|
||||||
|
│ - authorization_endpoint (IndieLogin or self-hosted) │
|
||||||
|
│ - token_endpoint (tokens.indieauth.com or self-hosted) │
|
||||||
|
│ - micropub endpoint (StarPunk) │
|
||||||
|
│ ↓ │
|
||||||
|
│ Micropub Client (Quill, Indigenous) │
|
||||||
|
│ ↓ (discovers endpoints from alice.com) │
|
||||||
|
│ Authorization Server (user's choice, NOT StarPunk) │
|
||||||
|
│ ↓ (issues access token) │
|
||||||
|
│ Micropub Client │
|
||||||
|
│ ↓ (POST with Bearer token) │
|
||||||
|
│ StarPunk Micropub Endpoint │
|
||||||
|
│ ↓ (verifies token with authorization server) │
|
||||||
|
│ StarPunk (creates note) │
|
||||||
|
└─────────────────────────────────────────────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
### What StarPunk Implements
|
||||||
|
|
||||||
|
**Currently Implemented** (ADR-005):
|
||||||
|
- Session-based admin authentication via IndieLogin.com
|
||||||
|
- CSRF protection (state tokens)
|
||||||
|
- Session management
|
||||||
|
- Admin route protection
|
||||||
|
|
||||||
|
**Must Be Implemented** (for Micropub):
|
||||||
|
- Token verification endpoint (query user's token endpoint)
|
||||||
|
- Bearer token extraction from Authorization header
|
||||||
|
- Scope verification (check token has "create" permission)
|
||||||
|
- Token storage/caching (optional, for performance)
|
||||||
|
|
||||||
|
**Does NOT Implement** (users provide these):
|
||||||
|
- Authorization endpoint (users use IndieLogin.com or self-hosted)
|
||||||
|
- Token endpoint (users use tokens.indieauth.com or self-hosted)
|
||||||
|
- User identity management (users own their domains)
|
||||||
|
|
||||||
|
## Implementation Outline
|
||||||
|
|
||||||
|
### No Changes Needed for Admin Auth
|
||||||
|
The current IndieLogin.com integration (ADR-005) is correct and requires no changes. Each self-hosted StarPunk installation uses its own domain as `client_id` without any registration.
|
||||||
|
|
||||||
|
### Required for Micropub Support
|
||||||
|
|
||||||
|
#### 1. Token Verification
|
||||||
|
```python
|
||||||
|
def verify_micropub_token(bearer_token, expected_me):
|
||||||
|
"""
|
||||||
|
Verify access token by querying the token endpoint
|
||||||
|
|
||||||
|
Args:
|
||||||
|
bearer_token: Token from Authorization header
|
||||||
|
expected_me: Expected user identity (from StarPunk config)
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: Token info (me, client_id, scope) if valid
|
||||||
|
None: If token is invalid
|
||||||
|
"""
|
||||||
|
# Discover token endpoint from expected_me domain
|
||||||
|
token_endpoint = discover_token_endpoint(expected_me)
|
||||||
|
|
||||||
|
# Verify token
|
||||||
|
response = httpx.get(
|
||||||
|
token_endpoint,
|
||||||
|
headers={'Authorization': f'Bearer {bearer_token}'},
|
||||||
|
params={'token': bearer_token}
|
||||||
|
)
|
||||||
|
|
||||||
|
if response.status_code != 200:
|
||||||
|
return None
|
||||||
|
|
||||||
|
data = response.json()
|
||||||
|
|
||||||
|
# Verify token is for expected user
|
||||||
|
if data.get('me') != expected_me:
|
||||||
|
return None
|
||||||
|
|
||||||
|
# Verify token has required scope
|
||||||
|
scope = data.get('scope', '')
|
||||||
|
if 'create' not in scope:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return data
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 2. Endpoint Discovery
|
||||||
|
```python
|
||||||
|
def discover_token_endpoint(me_url):
|
||||||
|
"""
|
||||||
|
Discover token endpoint from user's profile URL
|
||||||
|
|
||||||
|
Checks for:
|
||||||
|
1. indieauth-metadata endpoint
|
||||||
|
2. Fallback to direct token_endpoint link
|
||||||
|
"""
|
||||||
|
response = httpx.get(me_url)
|
||||||
|
|
||||||
|
# Check HTTP Link header
|
||||||
|
link_header = response.headers.get('Link', '')
|
||||||
|
# Parse link header for indieauth-metadata
|
||||||
|
|
||||||
|
# Check HTML <link> tags
|
||||||
|
# Parse HTML for <link rel="indieauth-metadata">
|
||||||
|
|
||||||
|
# Fetch metadata endpoint
|
||||||
|
# Return token_endpoint URL
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 3. Micropub Endpoint Protection
|
||||||
|
```python
|
||||||
|
@app.route('/api/micropub', methods=['POST'])
|
||||||
|
def micropub_endpoint():
|
||||||
|
# Extract bearer token
|
||||||
|
auth_header = request.headers.get('Authorization', '')
|
||||||
|
if not auth_header.startswith('Bearer '):
|
||||||
|
return {'error': 'unauthorized'}, 401
|
||||||
|
|
||||||
|
bearer_token = auth_header[7:] # Remove "Bearer "
|
||||||
|
|
||||||
|
# Verify token
|
||||||
|
token_info = verify_micropub_token(bearer_token, ADMIN_ME)
|
||||||
|
if not token_info:
|
||||||
|
return {'error': 'forbidden'}, 403
|
||||||
|
|
||||||
|
# Process Micropub request
|
||||||
|
# Create note
|
||||||
|
# Return 201 with Location header
|
||||||
|
```
|
||||||
|
|
||||||
|
### Documentation Updates
|
||||||
|
|
||||||
|
#### For Users (Setup Guide)
|
||||||
|
```markdown
|
||||||
|
# Setting Up Your IndieWeb Identity
|
||||||
|
|
||||||
|
To publish to StarPunk via Micropub clients:
|
||||||
|
|
||||||
|
1. **Add Links to Your Website**
|
||||||
|
Add these to your personal website's <head>:
|
||||||
|
```html
|
||||||
|
<link rel="authorization_endpoint" href="https://indielogin.com/auth">
|
||||||
|
<link rel="token_endpoint" href="https://tokens.indieauth.com/token">
|
||||||
|
<link rel="micropub" href="https://your-starpunk.example.com/api/micropub">
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Configure StarPunk**
|
||||||
|
Set your website URL in StarPunk configuration:
|
||||||
|
```
|
||||||
|
ADMIN_ME=https://your-website.com
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Use a Micropub Client**
|
||||||
|
- Quill: https://quill.p3k.io
|
||||||
|
- Indigenous (mobile app)
|
||||||
|
- Or any Micropub-compatible client
|
||||||
|
|
||||||
|
4. **Advanced: Self-Host Authorization**
|
||||||
|
Instead of IndieLogin.com, you can run your own IndieAuth server.
|
||||||
|
See: https://indieweb.org/IndieAuth#Software
|
||||||
|
```
|
||||||
|
|
||||||
|
#### For Developers (Architecture Docs)
|
||||||
|
Update `/home/phil/Projects/starpunk/docs/architecture/overview.md` to clarify the two authentication flows and explain that StarPunk is a Micropub server, not an authorization server.
|
||||||
|
|
||||||
|
## Consequences
|
||||||
|
|
||||||
|
### Positive
|
||||||
|
- **No development needed**: Current architecture is correct
|
||||||
|
- **No registration required**: Works for self-hosted installations out of the box
|
||||||
|
- **User control**: Users choose their own authorization provider
|
||||||
|
- **Standards compliant**: Proper separation of Micropub server and authorization server
|
||||||
|
- **Simple**: StarPunk focuses on publishing, not identity management
|
||||||
|
- **Flexible**: Users can switch authorization providers without affecting StarPunk
|
||||||
|
|
||||||
|
### Negative
|
||||||
|
- **User education required**: Must explain that they need to configure their domain
|
||||||
|
- **Not standalone**: StarPunk cannot function completely independently (requires external auth)
|
||||||
|
- **Dependency**: Relies on external services (mitigated: user chooses service)
|
||||||
|
|
||||||
|
### Neutral
|
||||||
|
- **Architectural purity**: Follows IndieWeb principle of separation of concerns
|
||||||
|
- **Complexity distribution**: Moves authorization complexity to where it belongs (identity provider)
|
||||||
|
|
||||||
|
## V2 Considerations
|
||||||
|
|
||||||
|
If there is user demand for a more integrated solution, V2 could add:
|
||||||
|
|
||||||
|
### Option A: Embedded IndieAuth Server
|
||||||
|
**Pros**:
|
||||||
|
- StarPunk becomes completely standalone
|
||||||
|
- Users can use StarPunk domain as their identity
|
||||||
|
- One-step setup for non-technical users
|
||||||
|
|
||||||
|
**Cons**:
|
||||||
|
- 40-60 hours development effort
|
||||||
|
- Ongoing security maintenance
|
||||||
|
- Adds complexity to codebase
|
||||||
|
- May violate simplicity principle
|
||||||
|
|
||||||
|
**Decision**: Only implement if users request it
|
||||||
|
|
||||||
|
### Option B: Hybrid Mode
|
||||||
|
**Pros**:
|
||||||
|
- Advanced users can use external auth (current behavior)
|
||||||
|
- Simple users can use built-in auth
|
||||||
|
- Best of both worlds
|
||||||
|
|
||||||
|
**Cons**:
|
||||||
|
- Even more complexity
|
||||||
|
- Two codepaths to maintain
|
||||||
|
- Configuration complexity
|
||||||
|
|
||||||
|
**Decision**: Defer until V2 user feedback
|
||||||
|
|
||||||
|
### Option C: StarPunk-Hosted Service
|
||||||
|
**Pros**:
|
||||||
|
- One StarPunk authorization server for all installations
|
||||||
|
- Users register their StarPunk instance once
|
||||||
|
- Simple for end users
|
||||||
|
|
||||||
|
**Cons**:
|
||||||
|
- Centralized service (not indie)
|
||||||
|
- Single point of failure
|
||||||
|
- Hosting/maintenance burden
|
||||||
|
- Violates IndieWeb principles
|
||||||
|
|
||||||
|
**Decision**: Rejected - not aligned with IndieWeb values
|
||||||
|
|
||||||
|
## Alternatives Considered
|
||||||
|
|
||||||
|
### Alternative 1: Self-Host IndieAuth (Taproot/PHP)
|
||||||
|
**Evaluation**:
|
||||||
|
- Complexity: Would require running PHP alongside Python
|
||||||
|
- Deployment: Two separate applications to manage
|
||||||
|
- Maintenance: Security updates for both Python and PHP
|
||||||
|
- Verdict: **Rejected** - adds unnecessary complexity
|
||||||
|
|
||||||
|
### Alternative 2: Port Taproot to Python
|
||||||
|
**Evaluation**:
|
||||||
|
- Effort: 40-60 hours development
|
||||||
|
- Maintenance: Full responsibility for security
|
||||||
|
- Value: Solves a non-existent problem (no registration needed)
|
||||||
|
- Verdict: **Rejected** - violates simplicity principle
|
||||||
|
|
||||||
|
### Alternative 3: Use OAuth2 Service (GitHub, Google)
|
||||||
|
**Evaluation**:
|
||||||
|
- Simplicity: Very simple to implement
|
||||||
|
- IndieWeb Compliance: **FAIL** - not IndieWeb compatible
|
||||||
|
- User Ownership: **FAIL** - users don't own their identity
|
||||||
|
- Verdict: **Rejected** - violates core requirements
|
||||||
|
|
||||||
|
### Alternative 4: Password Authentication
|
||||||
|
**Evaluation**:
|
||||||
|
- Simplicity: Moderate (password hashing, reset flows)
|
||||||
|
- IndieWeb Compliance: **FAIL** - not IndieWeb authentication
|
||||||
|
- Security: Must implement password best practices
|
||||||
|
- Verdict: **Rejected** - not aligned with IndieWeb principles
|
||||||
|
|
||||||
|
### Alternative 5: Use IndieAuth as Library (Client Side)
|
||||||
|
**Evaluation**:
|
||||||
|
- Would make StarPunk act as IndieAuth client to discover user's auth server
|
||||||
|
- Current architecture already does this for Micropub
|
||||||
|
- Admin interface uses simpler session-based auth
|
||||||
|
- Verdict: **Already implemented** for Micropub flow
|
||||||
|
|
||||||
|
## Migration Plan
|
||||||
|
|
||||||
|
### From Current Broken Understanding → Correct Understanding
|
||||||
|
|
||||||
|
**No Code Changes Required**
|
||||||
|
|
||||||
|
1. **Update Documentation**
|
||||||
|
- Clarify that no registration is needed
|
||||||
|
- Explain the two authentication flows
|
||||||
|
- Document Micropub setup for users
|
||||||
|
|
||||||
|
2. **Complete Micropub Implementation**
|
||||||
|
- Implement token verification
|
||||||
|
- Implement endpoint discovery
|
||||||
|
- Add Bearer token authentication
|
||||||
|
|
||||||
|
3. **User Education**
|
||||||
|
- Create setup guide explaining domain configuration
|
||||||
|
- Provide example HTML snippets
|
||||||
|
- Link to IndieWeb resources
|
||||||
|
|
||||||
|
### Timeline
|
||||||
|
- Documentation updates: 2 hours
|
||||||
|
- Micropub token verification: 8 hours
|
||||||
|
- Testing with real Micropub clients: 4 hours
|
||||||
|
- Total: ~14 hours
|
||||||
|
|
||||||
|
## References
|
||||||
|
|
||||||
|
### IndieAuth Specifications
|
||||||
|
- [IndieAuth Spec](https://indieauth.spec.indieweb.org/) - Official W3C specification
|
||||||
|
- [OAuth 2.0](https://oauth.net/2/) - Underlying OAuth 2.0 foundation
|
||||||
|
- [Client Identifier](https://www.oauth.com/oauth2-servers/indieauth/) - How client_id works in IndieAuth
|
||||||
|
|
||||||
|
### Services
|
||||||
|
- [IndieLogin.com](https://indielogin.com/) - Public IndieAuth service (no registration)
|
||||||
|
- [IndieLogin API Docs](https://indielogin.com/api) - Integration documentation
|
||||||
|
- [tokens.indieauth.com](https://tokens.indieauth.com/token) - Public token endpoint service
|
||||||
|
|
||||||
|
### Self-Hosted Implementations
|
||||||
|
- [Taproot/IndieAuth](https://github.com/Taproot/indieauth) - PHP implementation
|
||||||
|
- [hacdias/indieauth](https://github.com/hacdias/indieauth) - Go implementation
|
||||||
|
- [Selfauth](https://github.com/Inklings-io/selfauth) - Simple auth-only PHP
|
||||||
|
|
||||||
|
### IndieWeb Resources
|
||||||
|
- [IndieWeb Wiki: IndieAuth](https://indieweb.org/IndieAuth) - Community documentation
|
||||||
|
- [IndieWeb Wiki: Micropub](https://indieweb.org/Micropub) - Micropub overview
|
||||||
|
- [IndieWeb Wiki: authorization-endpoint](https://indieweb.org/authorization-endpoint) - Endpoint details
|
||||||
|
|
||||||
|
### Related ADRs
|
||||||
|
- [ADR-005: IndieLogin Authentication](/home/phil/Projects/starpunk/docs/decisions/ADR-005-indielogin-authentication.md) - Original auth decision
|
||||||
|
- [ADR-010: Authentication Module Design](/home/phil/Projects/starpunk/docs/decisions/ADR-010-authentication-module-design.md) - Auth module structure
|
||||||
|
|
||||||
|
### Community Examples
|
||||||
|
- [Aaron Parecki's IndieAuth Notes](https://aaronparecki.com/2025/10/08/4/cimd) - Client ID metadata adoption
|
||||||
|
- [Jamie Tanna's IndieAuth Server](https://www.jvt.me/posts/2020/12/09/personal-indieauth-server/) - Self-hosted implementation
|
||||||
|
- [Micropub Servers](https://indieweb.org/Micropub/Servers) - Examples of Micropub implementations
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Document Version**: 1.0
|
||||||
|
**Created**: 2025-11-19
|
||||||
|
**Author**: StarPunk Architecture Team (agent-architect)
|
||||||
|
**Status**: Accepted
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# ADR-006: IndieAuth Client Identification Strategy
|
# ADR-023: IndieAuth Client Identification Strategy
|
||||||
|
|
||||||
## Status
|
## Status
|
||||||
Accepted
|
Accepted
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# ADR-010: Static HTML Identity Pages for IndieAuth
|
# ADR-024: Static HTML Identity Pages for IndieAuth
|
||||||
|
|
||||||
## Status
|
## Status
|
||||||
Accepted
|
Accepted
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# ADR-019: IndieAuth Correct Implementation Based on IndieLogin.com API
|
# ADR-025: IndieAuth Correct Implementation Based on IndieLogin.com API
|
||||||
|
|
||||||
## Status
|
## Status
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# ADR-022: IndieAuth Token Exchange Compliance
|
# ADR-026: IndieAuth Token Exchange Compliance
|
||||||
|
|
||||||
## Status
|
## Status
|
||||||
Accepted
|
Accepted
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# ADR-022: IndieAuth Authentication Endpoint Correction
|
# ADR-027: IndieAuth Authentication Endpoint Correction
|
||||||
|
|
||||||
## Status
|
## Status
|
||||||
Accepted
|
Accepted
|
||||||
227
docs/decisions/ADR-028-micropub-implementation.md
Normal file
227
docs/decisions/ADR-028-micropub-implementation.md
Normal file
@@ -0,0 +1,227 @@
|
|||||||
|
# ADR-028: Micropub Implementation Strategy
|
||||||
|
|
||||||
|
## Status
|
||||||
|
|
||||||
|
Proposed
|
||||||
|
|
||||||
|
## Context
|
||||||
|
|
||||||
|
StarPunk needs a Micropub endpoint to achieve V1 release. Micropub is a W3C standard that allows external clients to create, update, and delete posts on a website. This is a critical IndieWeb building block that enables users to post from various apps and services.
|
||||||
|
|
||||||
|
### Current State
|
||||||
|
- StarPunk has working IndieAuth authentication (authorization endpoint with PKCE)
|
||||||
|
- Note CRUD operations exist in `starpunk/notes.py`
|
||||||
|
- File-based storage with SQLite metadata is implemented
|
||||||
|
- **Missing**: Micropub endpoint for external posting
|
||||||
|
- **Missing**: Token endpoint for API authentication
|
||||||
|
|
||||||
|
### Requirements Analysis
|
||||||
|
|
||||||
|
Based on the W3C Micropub specification review, we identified:
|
||||||
|
|
||||||
|
**Minimum Required Features:**
|
||||||
|
- Bearer token authentication (header or form parameter)
|
||||||
|
- Create posts via form-encoded requests
|
||||||
|
- HTTP 201 Created response with Location header
|
||||||
|
- Proper error responses with JSON error bodies
|
||||||
|
|
||||||
|
**Recommended Features:**
|
||||||
|
- JSON request support for complex operations
|
||||||
|
- Update and delete operations
|
||||||
|
- Query endpoints (config, source, syndicate-to)
|
||||||
|
|
||||||
|
**Optional Features (Not for V1):**
|
||||||
|
- Media endpoint for file uploads
|
||||||
|
- Syndication targets
|
||||||
|
- Complex post types beyond notes
|
||||||
|
|
||||||
|
## Decision
|
||||||
|
|
||||||
|
We will implement a **minimal but complete Micropub server** for V1, focusing on core functionality that enables real-world usage while deferring advanced features.
|
||||||
|
|
||||||
|
### Implementation Approach
|
||||||
|
|
||||||
|
1. **Token Management System**
|
||||||
|
- New token endpoint (`/auth/token`) for IndieAuth code exchange
|
||||||
|
- Secure token storage using SHA256 hashing
|
||||||
|
- 90-day token expiry with scope validation
|
||||||
|
- Database schema updates for token management
|
||||||
|
|
||||||
|
2. **Micropub Endpoint Architecture**
|
||||||
|
- Single endpoint (`/micropub`) handling all operations
|
||||||
|
- Support both form-encoded and JSON content types
|
||||||
|
- Delegate to existing `notes.py` CRUD functions
|
||||||
|
- Proper error handling and status codes
|
||||||
|
|
||||||
|
3. **V1 Feature Scope** (Simplified per user decision)
|
||||||
|
- ✅ Create posts (form-encoded and JSON)
|
||||||
|
- ✅ Query endpoints (config, source)
|
||||||
|
- ✅ Bearer token authentication
|
||||||
|
- ✅ Scope-based authorization (create only)
|
||||||
|
- ❌ Media endpoint (post-V1)
|
||||||
|
- ❌ Update operations (post-V1)
|
||||||
|
- ❌ Delete operations (post-V1)
|
||||||
|
- ❌ Syndication (post-V1)
|
||||||
|
|
||||||
|
### Technology Choices
|
||||||
|
|
||||||
|
| Component | Technology | Rationale |
|
||||||
|
|-----------|------------|-----------|
|
||||||
|
| Token Storage | SQLite with SHA256 hashing | Secure, consistent with existing database |
|
||||||
|
| Token Format | Random URL-safe strings | Simple, secure, no JWT complexity |
|
||||||
|
| Request Parsing | Flask built-in + custom normalization | Handles both form and JSON naturally |
|
||||||
|
| Response Format | JSON for errors, headers for success | Follows Micropub spec exactly |
|
||||||
|
|
||||||
|
## Rationale
|
||||||
|
|
||||||
|
### Why Minimal V1 Scope?
|
||||||
|
|
||||||
|
1. **Get to V1 Faster**: Core create functionality enables 90% of use cases
|
||||||
|
2. **Real Usage Feedback**: Deploy and learn from actual usage patterns
|
||||||
|
3. **Reduced Complexity**: Fewer edge cases and error conditions
|
||||||
|
4. **Clear Foundation**: Establish patterns before adding complexity
|
||||||
|
|
||||||
|
### Why Not JWT Tokens?
|
||||||
|
|
||||||
|
1. **Unnecessary Complexity**: JWT adds libraries and complexity
|
||||||
|
2. **No Distributed Validation**: Single-server system doesn't need it
|
||||||
|
3. **Simpler Revocation**: Database tokens are easily revoked
|
||||||
|
4. **Consistent with IndieAuth**: Random tokens match the pattern
|
||||||
|
|
||||||
|
### Why Reuse Existing CRUD?
|
||||||
|
|
||||||
|
1. **Proven Code**: `notes.py` already handles file/database sync
|
||||||
|
2. **Consistency**: Same validation and error handling
|
||||||
|
3. **Maintainability**: Single source of truth for note operations
|
||||||
|
4. **Atomic Operations**: Existing transaction handling
|
||||||
|
|
||||||
|
### Security Considerations
|
||||||
|
|
||||||
|
1. **Token Hashing**: Never store plaintext tokens
|
||||||
|
2. **Scope Enforcement**: Each operation checks required scopes
|
||||||
|
3. **HTTPS Required**: Enforce in production configuration
|
||||||
|
4. **Token Expiry**: 90-day lifetime limits exposure
|
||||||
|
5. **Single-Use Auth Codes**: Prevent replay attacks
|
||||||
|
|
||||||
|
## Consequences
|
||||||
|
|
||||||
|
### Positive
|
||||||
|
|
||||||
|
✅ **Enables V1 Release**: Removes the last blocker for V1
|
||||||
|
✅ **Real IndieWeb Participation**: Can post from standard clients
|
||||||
|
✅ **Clean Architecture**: Clear separation of concerns
|
||||||
|
✅ **Extensible Design**: Easy to add features later
|
||||||
|
✅ **Security First**: Proper token handling from day one
|
||||||
|
|
||||||
|
### Negative
|
||||||
|
|
||||||
|
⚠️ **Limited Initial Features**: No media uploads in V1
|
||||||
|
⚠️ **Database Migration Required**: Token schema changes needed
|
||||||
|
⚠️ **Client Testing Needed**: Must verify with real Micropub clients
|
||||||
|
⚠️ **Additional Complexity**: New endpoints and token management
|
||||||
|
|
||||||
|
### Neutral
|
||||||
|
|
||||||
|
- **8-10 Day Implementation**: Reasonable timeline for critical feature
|
||||||
|
- **New Dependencies**: None required (using existing libraries)
|
||||||
|
- **Documentation Burden**: Must document API for users
|
||||||
|
|
||||||
|
## Implementation Plan
|
||||||
|
|
||||||
|
### Phase 1: Token Infrastructure (Days 1-3)
|
||||||
|
- Token database schema and migration
|
||||||
|
- Token generation and storage functions
|
||||||
|
- Token endpoint for code exchange
|
||||||
|
- Scope validation helpers
|
||||||
|
|
||||||
|
### Phase 2: Micropub Core (Days 4-7)
|
||||||
|
- Main endpoint handler
|
||||||
|
- Property normalization for form/JSON
|
||||||
|
- Create post functionality
|
||||||
|
- Error response formatting
|
||||||
|
|
||||||
|
### Phase 3: Queries & Polish (Days 6-8)
|
||||||
|
- Config and source query endpoints
|
||||||
|
- Authorization endpoint with admin session check
|
||||||
|
- Discovery headers and links
|
||||||
|
- Client testing and documentation
|
||||||
|
|
||||||
|
**Note**: Timeline reduced from 8-10 days to 6-8 days due to V1 scope simplification (no update/delete)
|
||||||
|
|
||||||
|
## Alternatives Considered
|
||||||
|
|
||||||
|
### Alternative 1: Full Micropub Implementation
|
||||||
|
**Rejected**: Too complex for V1, would delay release by weeks
|
||||||
|
|
||||||
|
### Alternative 2: Custom API Instead of Micropub
|
||||||
|
**Rejected**: Breaks IndieWeb compatibility, requires custom clients
|
||||||
|
|
||||||
|
### Alternative 3: JWT-Based Tokens
|
||||||
|
**Rejected**: Unnecessary complexity for single-server system
|
||||||
|
|
||||||
|
### Alternative 4: Separate Media Endpoint First
|
||||||
|
**Rejected**: Not required for text posts, can add later
|
||||||
|
|
||||||
|
## Compliance
|
||||||
|
|
||||||
|
### Standards Compliance
|
||||||
|
- ✅ W3C Micropub specification
|
||||||
|
- ✅ IndieAuth specification for tokens
|
||||||
|
- ✅ OAuth 2.0 Bearer Token usage
|
||||||
|
|
||||||
|
### Project Principles
|
||||||
|
- ✅ Minimal code (reuses existing CRUD)
|
||||||
|
- ✅ Standards-first (follows W3C spec)
|
||||||
|
- ✅ No lock-in (standard protocols)
|
||||||
|
- ✅ Progressive enhancement (can add features)
|
||||||
|
|
||||||
|
## Risks and Mitigations
|
||||||
|
|
||||||
|
| Risk | Impact | Probability | Mitigation |
|
||||||
|
|------|--------|-------------|------------|
|
||||||
|
| Token security breach | High | Low | SHA256 hashing, HTTPS required |
|
||||||
|
| Client incompatibility | Medium | Medium | Test with 3+ clients before release |
|
||||||
|
| Scope creep | Medium | High | Strict V1 feature list |
|
||||||
|
| Performance issues | Low | Low | Simple operations, indexed database |
|
||||||
|
|
||||||
|
## Success Metrics
|
||||||
|
|
||||||
|
1. **Functional Success**
|
||||||
|
- Posts can be created from Indigenous app
|
||||||
|
- Posts can be created from Quill
|
||||||
|
- Token endpoint works with IndieAuth flow
|
||||||
|
|
||||||
|
2. **Performance Targets**
|
||||||
|
- Post creation < 500ms
|
||||||
|
- Token validation < 50ms
|
||||||
|
- Query responses < 200ms
|
||||||
|
|
||||||
|
3. **Security Requirements**
|
||||||
|
- All tokens hashed in database
|
||||||
|
- Expired tokens rejected
|
||||||
|
- Invalid scopes return 403
|
||||||
|
|
||||||
|
## References
|
||||||
|
|
||||||
|
- [W3C Micropub Specification](https://www.w3.org/TR/micropub/)
|
||||||
|
- [IndieAuth Specification](https://indieauth.spec.indieweb.org/)
|
||||||
|
- [OAuth 2.0 Bearer Token Usage](https://tools.ietf.org/html/rfc6750)
|
||||||
|
- [Micropub Rocks Validator](https://micropub.rocks/)
|
||||||
|
|
||||||
|
## Related ADRs
|
||||||
|
|
||||||
|
- ADR-004: File-based Note Storage (storage layer)
|
||||||
|
- ADR-019: IndieAuth Implementation (authentication foundation)
|
||||||
|
- ADR-025: PKCE Authentication (security pattern)
|
||||||
|
|
||||||
|
## Version Impact
|
||||||
|
|
||||||
|
**Version Change**: 0.9.5 → 1.0.0 (V1 Release!)
|
||||||
|
|
||||||
|
This change represents the final feature for V1 release, warranting the major version increment to 1.0.0.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Date**: 2024-11-24
|
||||||
|
**Author**: StarPunk Architecture Team
|
||||||
|
**Status**: Proposed
|
||||||
537
docs/decisions/ADR-029-micropub-indieauth-integration.md
Normal file
537
docs/decisions/ADR-029-micropub-indieauth-integration.md
Normal file
@@ -0,0 +1,537 @@
|
|||||||
|
# ADR-029: Micropub IndieAuth Integration Strategy
|
||||||
|
|
||||||
|
## Status
|
||||||
|
Accepted
|
||||||
|
|
||||||
|
## Context
|
||||||
|
|
||||||
|
The developer review of our Micropub design (ADR-028) revealed critical issues and questions about how IndieAuth and Micropub integrate. This ADR addresses all architectural decisions needed to proceed with implementation.
|
||||||
|
|
||||||
|
### Critical Issues Identified
|
||||||
|
|
||||||
|
1. **Token endpoint missing required `me` parameter** in the IndieAuth spec
|
||||||
|
2. **PKCE confusion** - it's not part of IndieAuth spec, but StarPunk uses it with IndieLogin.com
|
||||||
|
3. **Database security issue** - tokens stored in plain text
|
||||||
|
4. **Missing `authorization_codes` table** for token exchange
|
||||||
|
5. **Property mapping rules** undefined for Micropub to StarPunk conversion
|
||||||
|
6. **Authorization endpoint location** unclear
|
||||||
|
7. **Two authentication flows** need clarification
|
||||||
|
|
||||||
|
### V1 Scope Decision
|
||||||
|
|
||||||
|
The user has agreed to **simplify V1** by:
|
||||||
|
- ✅ Omitting update operations from V1
|
||||||
|
- ✅ Omitting delete operations from V1
|
||||||
|
- ✅ Focusing on create-only for V1 release
|
||||||
|
- Post-V1 features will be tracked separately
|
||||||
|
|
||||||
|
## Decision
|
||||||
|
|
||||||
|
We will implement a **hybrid IndieAuth architecture** that clearly separates admin authentication from Micropub authorization.
|
||||||
|
|
||||||
|
### Architectural Decisions
|
||||||
|
|
||||||
|
#### 1. Token Endpoint `me` Parameter (RESOLVED)
|
||||||
|
|
||||||
|
**Issue**: IndieAuth spec requires `me` parameter in token exchange, but our design missed it.
|
||||||
|
|
||||||
|
**Decision**: Add `me` parameter validation to token endpoint.
|
||||||
|
|
||||||
|
**Implementation**:
|
||||||
|
```python
|
||||||
|
# Token exchange request MUST include:
|
||||||
|
POST /auth/token
|
||||||
|
grant_type=authorization_code
|
||||||
|
code={code}
|
||||||
|
client_id={client_url}
|
||||||
|
redirect_uri={redirect_url}
|
||||||
|
me={user_profile_url} # REQUIRED by IndieAuth spec
|
||||||
|
```
|
||||||
|
|
||||||
|
**Validation**:
|
||||||
|
- Verify `me` matches the value stored with the authorization code
|
||||||
|
- Return error if mismatch (prevents code hijacking)
|
||||||
|
|
||||||
|
#### 2. PKCE Strategy (RESOLVED)
|
||||||
|
|
||||||
|
**Issue**: PKCE is not part of IndieAuth spec, but StarPunk uses it with IndieLogin.com.
|
||||||
|
|
||||||
|
**Decision**: Make PKCE **optional but recommended**.
|
||||||
|
|
||||||
|
**Implementation**:
|
||||||
|
- Check for `code_challenge` in authorization request
|
||||||
|
- If present, require `code_verifier` in token exchange
|
||||||
|
- If absent, proceed without PKCE (spec-compliant)
|
||||||
|
- Document as security enhancement beyond spec
|
||||||
|
|
||||||
|
**Rationale**:
|
||||||
|
- IndieLogin.com supports PKCE as an extension
|
||||||
|
- Other IndieAuth providers may not support it
|
||||||
|
- Making it optional ensures broader compatibility
|
||||||
|
|
||||||
|
#### 3. Token Storage Security (RESOLVED)
|
||||||
|
|
||||||
|
**Issue**: Current `tokens` table stores tokens in plain text (major security vulnerability).
|
||||||
|
|
||||||
|
**Decision**: Implement **immediate migration** to hashed token storage.
|
||||||
|
|
||||||
|
**Migration Strategy**:
|
||||||
|
```sql
|
||||||
|
-- Step 1: Create new secure tokens table
|
||||||
|
CREATE TABLE tokens_secure (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
token_hash TEXT UNIQUE NOT NULL, -- SHA256 hash
|
||||||
|
me TEXT NOT NULL,
|
||||||
|
client_id TEXT,
|
||||||
|
scope TEXT DEFAULT 'create',
|
||||||
|
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
expires_at TIMESTAMP NOT NULL,
|
||||||
|
last_used_at TIMESTAMP,
|
||||||
|
revoked_at TIMESTAMP
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Step 2: Invalidate all existing tokens (security breach recovery)
|
||||||
|
-- Since we can't hash plain text tokens retroactively, all must be revoked
|
||||||
|
DROP TABLE IF EXISTS tokens;
|
||||||
|
|
||||||
|
-- Step 3: Rename secure table
|
||||||
|
ALTER TABLE tokens_secure RENAME TO tokens;
|
||||||
|
|
||||||
|
-- Step 4: Create indexes
|
||||||
|
CREATE INDEX idx_tokens_hash ON tokens(token_hash);
|
||||||
|
CREATE INDEX idx_tokens_me ON tokens(me);
|
||||||
|
CREATE INDEX idx_tokens_expires ON tokens(expires_at);
|
||||||
|
```
|
||||||
|
|
||||||
|
**Security Notice**: All existing tokens will be invalidated. Users must re-authenticate.
|
||||||
|
|
||||||
|
#### 4. Authorization Codes Table (RESOLVED)
|
||||||
|
|
||||||
|
**Issue**: Design references `authorization_codes` table that doesn't exist.
|
||||||
|
|
||||||
|
**Decision**: Create the table as part of Micropub implementation.
|
||||||
|
|
||||||
|
**Schema**:
|
||||||
|
```sql
|
||||||
|
CREATE TABLE authorization_codes (
|
||||||
|
code TEXT PRIMARY KEY,
|
||||||
|
code_hash TEXT UNIQUE NOT NULL, -- SHA256 hash for security
|
||||||
|
me TEXT NOT NULL,
|
||||||
|
client_id TEXT NOT NULL,
|
||||||
|
redirect_uri TEXT NOT NULL,
|
||||||
|
scope TEXT DEFAULT 'create',
|
||||||
|
code_challenge TEXT, -- Optional PKCE
|
||||||
|
code_challenge_method TEXT, -- S256 if PKCE used
|
||||||
|
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
expires_at TIMESTAMP NOT NULL,
|
||||||
|
used_at TIMESTAMP -- Prevent replay attacks
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX idx_auth_codes_hash ON authorization_codes(code_hash);
|
||||||
|
CREATE INDEX idx_auth_codes_expires ON authorization_codes(expires_at);
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 5. Property Mapping Rules (RESOLVED)
|
||||||
|
|
||||||
|
**Issue**: Functions like `extract_title()` and `extract_content()` are undefined.
|
||||||
|
|
||||||
|
**Decision**: Define explicit mapping rules for V1.
|
||||||
|
|
||||||
|
**Micropub → StarPunk Mapping**:
|
||||||
|
```python
|
||||||
|
# Content mapping (required)
|
||||||
|
content = properties.get('content', [''])[0] # First content value
|
||||||
|
if not content:
|
||||||
|
return error_response("invalid_request", "Content is required")
|
||||||
|
|
||||||
|
# Title mapping (optional)
|
||||||
|
# Option 1: Use 'name' property if provided
|
||||||
|
title = properties.get('name', [''])[0]
|
||||||
|
# Option 2: If no name, extract from content (first line up to 50 chars)
|
||||||
|
if not title and content:
|
||||||
|
first_line = content.split('\n')[0]
|
||||||
|
title = first_line[:50] + ('...' if len(first_line) > 50 else '')
|
||||||
|
|
||||||
|
# Tags mapping
|
||||||
|
tags = properties.get('category', []) # All category values become tags
|
||||||
|
|
||||||
|
# Published date (respect if provided, otherwise use current time)
|
||||||
|
published = properties.get('published', [''])[0]
|
||||||
|
if published:
|
||||||
|
# Parse ISO 8601 date
|
||||||
|
created_at = parse_iso8601(published)
|
||||||
|
else:
|
||||||
|
created_at = datetime.now()
|
||||||
|
|
||||||
|
# Slug generation
|
||||||
|
mp_slug = properties.get('mp-slug', [''])[0]
|
||||||
|
if mp_slug:
|
||||||
|
slug = slugify(mp_slug)
|
||||||
|
else:
|
||||||
|
slug = generate_slug(title or content[:30])
|
||||||
|
```
|
||||||
|
|
||||||
|
### Q1: Authorization Endpoint Location (RESOLVED)
|
||||||
|
|
||||||
|
**Issue**: Design mentions `/auth/authorization` but it doesn't exist.
|
||||||
|
|
||||||
|
**Decision**: Create **NEW** `/auth/authorization` endpoint for Micropub clients.
|
||||||
|
|
||||||
|
**Rationale**:
|
||||||
|
- Keep admin login (`/auth/login`) separate from Micropub authorization
|
||||||
|
- Clear separation of concerns
|
||||||
|
- Follows IndieAuth spec naming conventions
|
||||||
|
|
||||||
|
**Implementation**:
|
||||||
|
```python
|
||||||
|
@bp.route("/auth/authorization", methods=["GET", "POST"])
|
||||||
|
def authorization_endpoint():
|
||||||
|
"""
|
||||||
|
IndieAuth authorization endpoint for Micropub clients
|
||||||
|
|
||||||
|
GET: Display authorization form
|
||||||
|
POST: Process authorization and redirect with code
|
||||||
|
"""
|
||||||
|
if request.method == "GET":
|
||||||
|
# Parse IndieAuth parameters
|
||||||
|
response_type = request.args.get('response_type')
|
||||||
|
client_id = request.args.get('client_id')
|
||||||
|
redirect_uri = request.args.get('redirect_uri')
|
||||||
|
state = request.args.get('state')
|
||||||
|
scope = request.args.get('scope', 'create')
|
||||||
|
me = request.args.get('me')
|
||||||
|
code_challenge = request.args.get('code_challenge')
|
||||||
|
|
||||||
|
# Validate parameters
|
||||||
|
if response_type != 'code':
|
||||||
|
return error_response("unsupported_response_type")
|
||||||
|
|
||||||
|
# Check if user is logged in (via admin session)
|
||||||
|
if not verify_admin_session():
|
||||||
|
# Redirect to login, then back here
|
||||||
|
session['pending_auth'] = request.url
|
||||||
|
return redirect(url_for('auth.login_form'))
|
||||||
|
|
||||||
|
# Display authorization form
|
||||||
|
return render_template('auth/authorize.html',
|
||||||
|
client_id=client_id,
|
||||||
|
scope=scope,
|
||||||
|
redirect_uri=redirect_uri)
|
||||||
|
|
||||||
|
else: # POST
|
||||||
|
# User approved/denied authorization
|
||||||
|
# Generate authorization code
|
||||||
|
# Store in authorization_codes table
|
||||||
|
# Redirect to client with code
|
||||||
|
```
|
||||||
|
|
||||||
|
### Q2: Two Authentication Flows Integration (RESOLVED)
|
||||||
|
|
||||||
|
**Decision**: Maintain **two separate flows** with clear boundaries.
|
||||||
|
|
||||||
|
**Flow 1: Admin Login** (Existing)
|
||||||
|
- Purpose: Admin access to StarPunk interface
|
||||||
|
- Path: `/auth/login` → IndieLogin.com → `/auth/callback`
|
||||||
|
- Result: Session cookie for admin panel
|
||||||
|
- No changes needed
|
||||||
|
|
||||||
|
**Flow 2: Micropub Authorization** (New)
|
||||||
|
- Purpose: Micropub client authorization
|
||||||
|
- Path: `/auth/authorization` → `/auth/token`
|
||||||
|
- Result: Bearer token for API access
|
||||||
|
|
||||||
|
**Integration Point**: The authorization endpoint checks for admin session:
|
||||||
|
```python
|
||||||
|
def authorization_endpoint():
|
||||||
|
# Check if admin is logged in
|
||||||
|
if not has_admin_session():
|
||||||
|
# Store authorization request
|
||||||
|
# Redirect to admin login
|
||||||
|
# After login, return to authorization
|
||||||
|
return redirect_to_login_with_return()
|
||||||
|
|
||||||
|
# Admin is logged in, show authorization form
|
||||||
|
return show_authorization_form()
|
||||||
|
```
|
||||||
|
|
||||||
|
**Key Design Choice**: We act as our **own authorization server** for Micropub, not delegating to IndieLogin.com for this flow. This is because:
|
||||||
|
1. IndieLogin.com doesn't issue access tokens
|
||||||
|
2. We need to control scopes and token lifetime
|
||||||
|
3. We already have admin authentication to verify the user
|
||||||
|
|
||||||
|
### Q3: Scope Validation Rules (RESOLVED)
|
||||||
|
|
||||||
|
**Issue**: What happens when client requests no scopes?
|
||||||
|
|
||||||
|
**Decision**: Implement **Option C** - Allow empty scope during authorization, reject at token endpoint.
|
||||||
|
|
||||||
|
**Rationale**: This matches the IndieAuth spec requirement exactly.
|
||||||
|
|
||||||
|
**Implementation**:
|
||||||
|
```python
|
||||||
|
def handle_authorization():
|
||||||
|
scope = request.args.get('scope', '')
|
||||||
|
|
||||||
|
# Store whatever scope was requested (even empty)
|
||||||
|
authorization_code = create_authorization_code(
|
||||||
|
scope=scope, # Can be empty string
|
||||||
|
# ... other parameters
|
||||||
|
)
|
||||||
|
|
||||||
|
def handle_token_exchange():
|
||||||
|
auth_code = get_authorization_code(code)
|
||||||
|
|
||||||
|
# IndieAuth spec: MUST NOT issue token if no scope
|
||||||
|
if not auth_code.scope:
|
||||||
|
return error_response("invalid_scope",
|
||||||
|
"Authorization code was issued without scope")
|
||||||
|
|
||||||
|
# Issue token with the authorized scope
|
||||||
|
token = create_access_token(scope=auth_code.scope)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Q4: V1 Scope - Update/Delete Operations (RESOLVED)
|
||||||
|
|
||||||
|
**Decision**: Remove update/delete from V1 completely.
|
||||||
|
|
||||||
|
**Changes Required**:
|
||||||
|
1. Remove `handle_update()` and `handle_delete()` from design doc
|
||||||
|
2. Remove update/delete from supported scopes in V1
|
||||||
|
3. Return "invalid_request" if action=update or action=delete
|
||||||
|
4. Document in project plan for post-V1
|
||||||
|
|
||||||
|
**V1 Supported Actions**:
|
||||||
|
- ✅ action=create (or no action - default)
|
||||||
|
- ❌ action=update → error response
|
||||||
|
- ❌ action=delete → error response
|
||||||
|
|
||||||
|
### Q5: Token Storage Security Fix (RESOLVED)
|
||||||
|
|
||||||
|
**Decision**: Fix the security issue as part of Micropub implementation.
|
||||||
|
|
||||||
|
**Implementation Plan**:
|
||||||
|
1. Create migration to new secure schema
|
||||||
|
2. Hash all new tokens before storage
|
||||||
|
3. Document that existing tokens will be invalidated
|
||||||
|
4. Add security notice to changelog
|
||||||
|
|
||||||
|
## Implementation Architecture
|
||||||
|
|
||||||
|
### Complete Authorization Flow
|
||||||
|
|
||||||
|
```
|
||||||
|
┌─────────────────────────────────────────────────────────┐
|
||||||
|
│ Micropub Client │
|
||||||
|
└────────────────────┬────────────────────────────────────┘
|
||||||
|
│
|
||||||
|
│ 1. GET /auth/authorization?
|
||||||
|
│ response_type=code&
|
||||||
|
│ client_id=https://app.example&
|
||||||
|
│ redirect_uri=...&
|
||||||
|
│ state=...&
|
||||||
|
│ scope=create&
|
||||||
|
│ me=https://user.example
|
||||||
|
▼
|
||||||
|
┌─────────────────────────────────────────────────────────┐
|
||||||
|
│ StarPunk Authorization Endpoint │
|
||||||
|
│ /auth/authorization │
|
||||||
|
├─────────────────────────────────────────────────────────┤
|
||||||
|
│ if not admin_logged_in: │
|
||||||
|
│ redirect_to_login() │
|
||||||
|
│ else: │
|
||||||
|
│ show_authorization_form() │
|
||||||
|
└────────────────────┬────────────────────────────────────┘
|
||||||
|
│
|
||||||
|
│ 2. User approves
|
||||||
|
│ POST /auth/authorization
|
||||||
|
│
|
||||||
|
│ 3. Redirect with code
|
||||||
|
│ https://app.example/callback?
|
||||||
|
│ code=xxx&state=yyy
|
||||||
|
▼
|
||||||
|
┌─────────────────────────────────────────────────────────┐
|
||||||
|
│ Micropub Client │
|
||||||
|
└────────────────────┬────────────────────────────────────┘
|
||||||
|
│
|
||||||
|
│ 4. POST /auth/token
|
||||||
|
│ grant_type=authorization_code&
|
||||||
|
│ code=xxx&
|
||||||
|
│ client_id=https://app.example&
|
||||||
|
│ redirect_uri=...&
|
||||||
|
│ me=https://user.example&
|
||||||
|
│ code_verifier=... (if PKCE)
|
||||||
|
▼
|
||||||
|
┌─────────────────────────────────────────────────────────┐
|
||||||
|
│ StarPunk Token Endpoint │
|
||||||
|
│ /auth/token │
|
||||||
|
├─────────────────────────────────────────────────────────┤
|
||||||
|
│ 1. Verify authorization code │
|
||||||
|
│ 2. Check code not used │
|
||||||
|
│ 3. Verify client_id matches │
|
||||||
|
│ 4. Verify redirect_uri matches │
|
||||||
|
│ 5. Verify me matches │
|
||||||
|
│ 6. Verify PKCE if present │
|
||||||
|
│ 7. Check scope not empty │
|
||||||
|
│ 8. Generate access token │
|
||||||
|
│ 9. Store hashed token │
|
||||||
|
│ 10. Return token response │
|
||||||
|
└────────────────────┬────────────────────────────────────┘
|
||||||
|
│
|
||||||
|
│ 5. Response:
|
||||||
|
│ {
|
||||||
|
│ "access_token": "xxx",
|
||||||
|
│ "token_type": "Bearer",
|
||||||
|
│ "scope": "create",
|
||||||
|
│ "me": "https://user.example"
|
||||||
|
│ }
|
||||||
|
▼
|
||||||
|
┌─────────────────────────────────────────────────────────┐
|
||||||
|
│ Micropub Client │
|
||||||
|
└────────────────────┬────────────────────────────────────┘
|
||||||
|
│
|
||||||
|
│ 6. POST /micropub
|
||||||
|
│ Authorization: Bearer xxx
|
||||||
|
│ h=entry&content=Hello
|
||||||
|
▼
|
||||||
|
┌─────────────────────────────────────────────────────────┐
|
||||||
|
│ StarPunk Micropub Endpoint │
|
||||||
|
│ /micropub │
|
||||||
|
├─────────────────────────────────────────────────────────┤
|
||||||
|
│ 1. Extract bearer token │
|
||||||
|
│ 2. Hash token and lookup │
|
||||||
|
│ 3. Verify not expired │
|
||||||
|
│ 4. Check scope includes "create" │
|
||||||
|
│ 5. Parse Micropub properties │
|
||||||
|
│ 6. Create note via notes.py │
|
||||||
|
│ 7. Return 201 with Location header │
|
||||||
|
└─────────────────────────────────────────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
## Consequences
|
||||||
|
|
||||||
|
### Positive
|
||||||
|
- ✅ All spec compliance issues resolved
|
||||||
|
- ✅ Clear separation between admin auth and Micropub auth
|
||||||
|
- ✅ Security vulnerability in token storage fixed
|
||||||
|
- ✅ Simplified V1 scope (create-only)
|
||||||
|
- ✅ PKCE optional for compatibility
|
||||||
|
- ✅ Clear property mapping rules
|
||||||
|
|
||||||
|
### Negative
|
||||||
|
- ⚠️ Existing tokens will be invalidated (security fix)
|
||||||
|
- ⚠️ More complex than initially designed
|
||||||
|
- ⚠️ Two authorization flows to maintain
|
||||||
|
|
||||||
|
### Neutral
|
||||||
|
- We become our own authorization server (for Micropub only)
|
||||||
|
- Admin must be logged in to authorize Micropub clients
|
||||||
|
- Update/delete deferred to post-V1
|
||||||
|
|
||||||
|
## Migration Requirements
|
||||||
|
|
||||||
|
### Database Migration Script
|
||||||
|
```sql
|
||||||
|
-- Migration: Fix token security and add authorization codes
|
||||||
|
-- Version: 0.10.0
|
||||||
|
|
||||||
|
-- 1. Create secure tokens table
|
||||||
|
CREATE TABLE tokens_new (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
token_hash TEXT UNIQUE NOT NULL,
|
||||||
|
me TEXT NOT NULL,
|
||||||
|
client_id TEXT,
|
||||||
|
scope TEXT DEFAULT 'create',
|
||||||
|
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
expires_at TIMESTAMP NOT NULL,
|
||||||
|
last_used_at TIMESTAMP,
|
||||||
|
revoked_at TIMESTAMP
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 2. Drop insecure table (invalidates all tokens)
|
||||||
|
DROP TABLE IF EXISTS tokens;
|
||||||
|
|
||||||
|
-- 3. Rename to final name
|
||||||
|
ALTER TABLE tokens_new RENAME TO tokens;
|
||||||
|
|
||||||
|
-- 4. Create authorization codes table
|
||||||
|
CREATE TABLE authorization_codes (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
code_hash TEXT UNIQUE NOT NULL,
|
||||||
|
me TEXT NOT NULL,
|
||||||
|
client_id TEXT NOT NULL,
|
||||||
|
redirect_uri TEXT NOT NULL,
|
||||||
|
scope TEXT,
|
||||||
|
state TEXT,
|
||||||
|
code_challenge TEXT,
|
||||||
|
code_challenge_method TEXT,
|
||||||
|
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
expires_at TIMESTAMP NOT NULL,
|
||||||
|
used_at TIMESTAMP
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 5. Create indexes
|
||||||
|
CREATE INDEX idx_tokens_hash ON tokens(token_hash);
|
||||||
|
CREATE INDEX idx_tokens_expires ON tokens(expires_at);
|
||||||
|
CREATE INDEX idx_auth_codes_hash ON authorization_codes(code_hash);
|
||||||
|
CREATE INDEX idx_auth_codes_expires ON authorization_codes(expires_at);
|
||||||
|
|
||||||
|
-- 6. Clean up expired auth state
|
||||||
|
DELETE FROM auth_state WHERE expires_at < datetime('now');
|
||||||
|
```
|
||||||
|
|
||||||
|
## Implementation Checklist
|
||||||
|
|
||||||
|
### Phase 1: Security & Database
|
||||||
|
- [ ] Create database migration script
|
||||||
|
- [ ] Implement token hashing functions
|
||||||
|
- [ ] Add authorization_codes table
|
||||||
|
- [ ] Update database.py schema
|
||||||
|
|
||||||
|
### Phase 2: Authorization Endpoint
|
||||||
|
- [ ] Create `/auth/authorization` route
|
||||||
|
- [ ] Implement authorization form template
|
||||||
|
- [ ] Add scope approval UI
|
||||||
|
- [ ] Generate and store authorization codes
|
||||||
|
|
||||||
|
### Phase 3: Token Endpoint
|
||||||
|
- [ ] Create `/auth/token` route
|
||||||
|
- [ ] Implement code exchange logic
|
||||||
|
- [ ] Add `me` parameter validation
|
||||||
|
- [ ] Optional PKCE verification
|
||||||
|
- [ ] Generate and store hashed tokens
|
||||||
|
|
||||||
|
### Phase 4: Micropub Endpoint (Create Only)
|
||||||
|
- [ ] Create `/micropub` route
|
||||||
|
- [ ] Bearer token extraction
|
||||||
|
- [ ] Token verification (hash lookup)
|
||||||
|
- [ ] Property normalization
|
||||||
|
- [ ] Content/title/tags mapping
|
||||||
|
- [ ] Note creation via notes.py
|
||||||
|
- [ ] Location header response
|
||||||
|
|
||||||
|
### Phase 5: Testing & Documentation
|
||||||
|
- [ ] Test with Indigenous app
|
||||||
|
- [ ] Test with Quill
|
||||||
|
- [ ] Update API documentation
|
||||||
|
- [ ] Security audit
|
||||||
|
- [ ] Performance testing
|
||||||
|
|
||||||
|
## References
|
||||||
|
|
||||||
|
- [IndieAuth Spec - Token Endpoint](https://indieauth.spec.indieweb.org/#token-endpoint)
|
||||||
|
- [IndieAuth Spec - Authorization Code](https://indieauth.spec.indieweb.org/#authorization-code)
|
||||||
|
- [Micropub Spec - Authentication](https://www.w3.org/TR/micropub/#authentication)
|
||||||
|
- [OAuth 2.0 Security Best Practices](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics)
|
||||||
|
|
||||||
|
## Related ADRs
|
||||||
|
|
||||||
|
- ADR-021: IndieAuth Provider Strategy (understanding flows)
|
||||||
|
- ADR-028: Micropub Implementation Strategy (original design)
|
||||||
|
- ADR-005: IndieLogin Authentication (admin auth flow)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Date**: 2024-11-24
|
||||||
|
**Author**: StarPunk Architecture Team
|
||||||
|
**Status**: Accepted
|
||||||
|
**Version Impact**: Requires 0.10.0 (breaking change - token invalidation)
|
||||||
1087
docs/design/micropub-endpoint-design.md
Normal file
1087
docs/design/micropub-endpoint-design.md
Normal file
File diff suppressed because it is too large
Load Diff
307
docs/design/token-security-migration.md
Normal file
307
docs/design/token-security-migration.md
Normal file
@@ -0,0 +1,307 @@
|
|||||||
|
# Token Security Migration Strategy
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
This document outlines the migration strategy for fixing the critical security issue where access tokens are stored in plain text in the database. This migration will invalidate all existing tokens as a necessary security measure.
|
||||||
|
|
||||||
|
## Security Issue
|
||||||
|
|
||||||
|
**Current State**: The `tokens` table stores tokens in plain text, which is a major security vulnerability. If the database is compromised, all tokens are immediately usable by an attacker.
|
||||||
|
|
||||||
|
**Target State**: Store only SHA256 hashes of tokens, making stolen database contents useless without the original tokens.
|
||||||
|
|
||||||
|
## Migration Plan
|
||||||
|
|
||||||
|
### Phase 1: Database Schema Migration
|
||||||
|
|
||||||
|
#### Migration Script (`migrations/005_token_security.sql`)
|
||||||
|
|
||||||
|
```sql
|
||||||
|
-- Migration: Fix token security and add Micropub support
|
||||||
|
-- Version: 0.10.0
|
||||||
|
-- Breaking Change: This will invalidate all existing tokens
|
||||||
|
|
||||||
|
-- Step 1: Create new secure tokens table
|
||||||
|
CREATE TABLE tokens_secure (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
token_hash TEXT UNIQUE NOT NULL, -- SHA256 hash of token
|
||||||
|
me TEXT NOT NULL, -- User identity URL
|
||||||
|
client_id TEXT, -- Client application URL
|
||||||
|
scope TEXT DEFAULT 'create', -- Granted scopes
|
||||||
|
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
expires_at TIMESTAMP NOT NULL, -- Token expiration
|
||||||
|
last_used_at TIMESTAMP, -- Track usage
|
||||||
|
revoked_at TIMESTAMP -- Soft revocation
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Step 2: Create indexes for performance
|
||||||
|
CREATE INDEX idx_tokens_secure_hash ON tokens_secure(token_hash);
|
||||||
|
CREATE INDEX idx_tokens_secure_me ON tokens_secure(me);
|
||||||
|
CREATE INDEX idx_tokens_secure_expires ON tokens_secure(expires_at);
|
||||||
|
|
||||||
|
-- Step 3: Create authorization_codes table for Micropub
|
||||||
|
CREATE TABLE authorization_codes (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
code_hash TEXT UNIQUE NOT NULL, -- SHA256 hash of code
|
||||||
|
me TEXT NOT NULL, -- User identity
|
||||||
|
client_id TEXT NOT NULL, -- Client application
|
||||||
|
redirect_uri TEXT NOT NULL, -- Callback URL
|
||||||
|
scope TEXT, -- Requested scopes
|
||||||
|
state TEXT, -- CSRF state
|
||||||
|
code_challenge TEXT, -- PKCE challenge
|
||||||
|
code_challenge_method TEXT, -- PKCE method
|
||||||
|
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
expires_at TIMESTAMP NOT NULL, -- 10 minute expiry
|
||||||
|
used_at TIMESTAMP -- Prevent replay
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Step 4: Create indexes for authorization codes
|
||||||
|
CREATE INDEX idx_auth_codes_hash ON authorization_codes(code_hash);
|
||||||
|
CREATE INDEX idx_auth_codes_expires ON authorization_codes(expires_at);
|
||||||
|
|
||||||
|
-- Step 5: Drop old insecure tokens table
|
||||||
|
-- WARNING: This will invalidate all existing tokens
|
||||||
|
DROP TABLE IF EXISTS tokens;
|
||||||
|
|
||||||
|
-- Step 6: Rename secure table to final name
|
||||||
|
ALTER TABLE tokens_secure RENAME TO tokens;
|
||||||
|
|
||||||
|
-- Step 7: Clean up expired auth state
|
||||||
|
DELETE FROM auth_state WHERE expires_at < datetime('now');
|
||||||
|
```
|
||||||
|
|
||||||
|
### Phase 2: Code Implementation
|
||||||
|
|
||||||
|
#### Token Generation and Storage
|
||||||
|
|
||||||
|
```python
|
||||||
|
# starpunk/tokens.py
|
||||||
|
import hashlib
|
||||||
|
import secrets
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
def generate_token() -> str:
|
||||||
|
"""Generate cryptographically secure random token"""
|
||||||
|
return secrets.token_urlsafe(32)
|
||||||
|
|
||||||
|
def hash_token(token: str) -> str:
|
||||||
|
"""Create SHA256 hash of token"""
|
||||||
|
return hashlib.sha256(token.encode()).hexdigest()
|
||||||
|
|
||||||
|
def create_access_token(me: str, client_id: str, scope: str, db) -> str:
|
||||||
|
"""
|
||||||
|
Create new access token and store hash in database
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Plain text token (only returned once, never stored)
|
||||||
|
"""
|
||||||
|
token = generate_token()
|
||||||
|
token_hash = hash_token(token)
|
||||||
|
|
||||||
|
expires_at = datetime.now() + timedelta(days=90)
|
||||||
|
|
||||||
|
db.execute("""
|
||||||
|
INSERT INTO tokens (token_hash, me, client_id, scope, expires_at)
|
||||||
|
VALUES (?, ?, ?, ?, ?)
|
||||||
|
""", (token_hash, me, client_id, scope, expires_at))
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
return token # Return plain text to user ONCE
|
||||||
|
|
||||||
|
def verify_token(token: str, db) -> dict:
|
||||||
|
"""
|
||||||
|
Verify token by comparing hash
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Token info if valid, None if invalid/expired
|
||||||
|
"""
|
||||||
|
token_hash = hash_token(token)
|
||||||
|
|
||||||
|
row = db.execute("""
|
||||||
|
SELECT me, client_id, scope
|
||||||
|
FROM tokens
|
||||||
|
WHERE token_hash = ?
|
||||||
|
AND expires_at > datetime('now')
|
||||||
|
AND revoked_at IS NULL
|
||||||
|
""", (token_hash,)).fetchone()
|
||||||
|
|
||||||
|
if row:
|
||||||
|
# Update last used timestamp
|
||||||
|
db.execute("""
|
||||||
|
UPDATE tokens
|
||||||
|
SET last_used_at = datetime('now')
|
||||||
|
WHERE token_hash = ?
|
||||||
|
""", (token_hash,))
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
return dict(row)
|
||||||
|
|
||||||
|
return None
|
||||||
|
```
|
||||||
|
|
||||||
|
### Phase 3: Migration Execution
|
||||||
|
|
||||||
|
#### Step-by-Step Process
|
||||||
|
|
||||||
|
1. **Backup Database**
|
||||||
|
```bash
|
||||||
|
cp data/starpunk.db data/starpunk.db.backup-$(date +%Y%m%d)
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Notify Users** (if applicable)
|
||||||
|
- Email or announcement about token invalidation
|
||||||
|
- Explain security improvement
|
||||||
|
- Provide re-authentication instructions
|
||||||
|
|
||||||
|
3. **Apply Migration**
|
||||||
|
```python
|
||||||
|
# In starpunk/migrations.py
|
||||||
|
def run_migration_005(conn):
|
||||||
|
"""Apply token security migration"""
|
||||||
|
with open('migrations/005_token_security.sql', 'r') as f:
|
||||||
|
conn.executescript(f.read())
|
||||||
|
conn.commit()
|
||||||
|
```
|
||||||
|
|
||||||
|
4. **Update Code**
|
||||||
|
- Deploy new token handling code
|
||||||
|
- Update all token verification points
|
||||||
|
- Add proper error messages
|
||||||
|
|
||||||
|
5. **Test Migration**
|
||||||
|
```python
|
||||||
|
# Verify new schema
|
||||||
|
cursor = conn.execute("PRAGMA table_info(tokens)")
|
||||||
|
columns = {col[1] for col in cursor.fetchall()}
|
||||||
|
assert 'token_hash' in columns
|
||||||
|
assert 'token' not in columns # Old column gone
|
||||||
|
|
||||||
|
# Test token operations
|
||||||
|
token = create_access_token("https://user.example", "app", "create", conn)
|
||||||
|
assert verify_token(token, conn) is not None
|
||||||
|
assert verify_token("invalid", conn) is None
|
||||||
|
```
|
||||||
|
|
||||||
|
### Phase 4: Post-Migration Validation
|
||||||
|
|
||||||
|
#### Security Checklist
|
||||||
|
|
||||||
|
- [ ] Verify no plain text tokens in database
|
||||||
|
- [ ] Confirm all tokens are hashed with SHA256
|
||||||
|
- [ ] Test token creation returns plain text once
|
||||||
|
- [ ] Test token verification works with hash
|
||||||
|
- [ ] Verify expired tokens are rejected
|
||||||
|
- [ ] Check revoked tokens are rejected
|
||||||
|
- [ ] Audit logs show migration completed
|
||||||
|
|
||||||
|
#### Functional Testing
|
||||||
|
|
||||||
|
- [ ] Micropub client can obtain new token
|
||||||
|
- [ ] New tokens work for API requests
|
||||||
|
- [ ] Invalid tokens return 401 Unauthorized
|
||||||
|
- [ ] Token expiry is enforced
|
||||||
|
- [ ] Last used timestamp updates
|
||||||
|
|
||||||
|
## Rollback Plan
|
||||||
|
|
||||||
|
If critical issues arise:
|
||||||
|
|
||||||
|
1. **Restore Database**
|
||||||
|
```bash
|
||||||
|
cp data/starpunk.db.backup-YYYYMMDD data/starpunk.db
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Revert Code**
|
||||||
|
```bash
|
||||||
|
git revert <migration-commit>
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Investigate Issues**
|
||||||
|
- Review migration logs
|
||||||
|
- Test in development environment
|
||||||
|
- Fix issues before retry
|
||||||
|
|
||||||
|
## User Communication
|
||||||
|
|
||||||
|
### Pre-Migration Notice
|
||||||
|
|
||||||
|
```
|
||||||
|
Subject: Important Security Update - Token Re-authentication Required
|
||||||
|
|
||||||
|
Dear StarPunk User,
|
||||||
|
|
||||||
|
We're implementing an important security update that will require you to
|
||||||
|
re-authenticate any Micropub clients you use with StarPunk.
|
||||||
|
|
||||||
|
What's Changing:
|
||||||
|
- Enhanced token security (SHA256 hashing)
|
||||||
|
- All existing access tokens will be invalidated
|
||||||
|
- You'll need to re-authorize Micropub clients
|
||||||
|
|
||||||
|
When:
|
||||||
|
- [Date and time of migration]
|
||||||
|
|
||||||
|
What You Need to Do:
|
||||||
|
1. After the update, go to your Micropub client
|
||||||
|
2. Remove and re-add your StarPunk site
|
||||||
|
3. Complete the authorization flow again
|
||||||
|
|
||||||
|
This change significantly improves the security of your StarPunk installation.
|
||||||
|
|
||||||
|
Thank you for your understanding.
|
||||||
|
```
|
||||||
|
|
||||||
|
### Post-Migration Notice
|
||||||
|
|
||||||
|
```
|
||||||
|
Subject: Security Update Complete - Please Re-authenticate
|
||||||
|
|
||||||
|
The security update has been completed successfully. All previous access
|
||||||
|
tokens have been invalidated for security reasons.
|
||||||
|
|
||||||
|
To continue using Micropub clients:
|
||||||
|
1. Open your Micropub client (Quill, Indigenous, etc.)
|
||||||
|
2. Remove your StarPunk site if listed
|
||||||
|
3. Add it again and complete authorization
|
||||||
|
4. You're ready to post!
|
||||||
|
|
||||||
|
If you experience any issues, please contact support.
|
||||||
|
```
|
||||||
|
|
||||||
|
## Timeline
|
||||||
|
|
||||||
|
| Phase | Duration | Description |
|
||||||
|
|-------|----------|-------------|
|
||||||
|
| Preparation | 1 day | Create migration scripts, test in dev |
|
||||||
|
| Communication | 1 day | Notify users of upcoming change |
|
||||||
|
| Migration | 2 hours | Apply migration, deploy code |
|
||||||
|
| Validation | 2 hours | Test and verify success |
|
||||||
|
| Support | 1 week | Help users re-authenticate |
|
||||||
|
|
||||||
|
## Risk Assessment
|
||||||
|
|
||||||
|
| Risk | Impact | Mitigation |
|
||||||
|
|------|--------|------------|
|
||||||
|
| Data loss | High | Full backup before migration |
|
||||||
|
| User disruption | Medium | Clear communication, documentation |
|
||||||
|
| Migration failure | Low | Test in dev, have rollback plan |
|
||||||
|
| Performance impact | Low | Indexes on hash columns |
|
||||||
|
|
||||||
|
## Long-term Benefits
|
||||||
|
|
||||||
|
1. **Security**: Compromised database doesn't expose usable tokens
|
||||||
|
2. **Compliance**: Follows security best practices
|
||||||
|
3. **Auditability**: Can track token usage via last_used_at
|
||||||
|
4. **Revocability**: Can revoke tokens without deletion
|
||||||
|
5. **Foundation**: Proper structure for OAuth/IndieAuth
|
||||||
|
|
||||||
|
## Conclusion
|
||||||
|
|
||||||
|
While this migration will cause temporary disruption by invalidating existing tokens, it's a necessary security improvement that brings StarPunk in line with security best practices. The migration is straightforward, well-tested, and includes comprehensive rollback procedures if needed.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Document Version**: 1.0
|
||||||
|
**Created**: 2024-11-24
|
||||||
|
**Author**: StarPunk Architecture Team
|
||||||
|
**Related**: ADR-029 (IndieAuth Integration)
|
||||||
@@ -4,16 +4,16 @@
|
|||||||
|
|
||||||
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.
|
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**: Phase 3 Complete - Authentication module implemented (v0.4.0)
|
**Current State**: Phase 5 Complete - RSS feed and container deployment (v0.9.5)
|
||||||
**Current Version**: 0.4.0
|
**Current Version**: 0.9.5
|
||||||
**Target State**: Working V1 with all features implemented, tested, and documented
|
**Target State**: Working V1 with all features implemented, tested, and documented
|
||||||
**Estimated Total Effort**: ~40-60 hours of focused development
|
**Estimated Total Effort**: ~40-60 hours of focused development
|
||||||
**Completed Effort**: ~20 hours (Phases 1-3)
|
**Completed Effort**: ~35 hours (Phases 1-5 mostly complete)
|
||||||
**Remaining Effort**: ~20-40 hours (Phases 4-10)
|
**Remaining Effort**: ~15-25 hours (Micropub, REST API optional, QA)
|
||||||
|
|
||||||
## Progress Summary
|
## Progress Summary
|
||||||
|
|
||||||
**Last Updated**: 2025-11-18
|
**Last Updated**: 2025-11-24
|
||||||
|
|
||||||
### Completed Phases ✅
|
### Completed Phases ✅
|
||||||
|
|
||||||
@@ -22,29 +22,71 @@ This document provides a comprehensive, dependency-ordered implementation plan f
|
|||||||
| 1.1 - Core Utilities | ✅ Complete | 0.1.0 | >90% | N/A |
|
| 1.1 - Core Utilities | ✅ Complete | 0.1.0 | >90% | N/A |
|
||||||
| 1.2 - Data Models | ✅ 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) |
|
| 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) |
|
| 3.1 - Authentication | ✅ Complete | 0.8.0 | 96% (51 tests) | [Phase 3 Report](/home/phil/Projects/starpunk/docs/reports/phase-3-authentication-20251118.md) |
|
||||||
|
| 4.1-4.4 - Web Interface | ✅ Complete | 0.5.2 | 87% (405 tests) | Phase 4 implementation |
|
||||||
|
| 5.1-5.2 - RSS Feed | ✅ Complete | 0.6.0 | 96% | ADR-014, ADR-015 |
|
||||||
|
|
||||||
### Current Phase 🔵
|
### Current Status 🔵
|
||||||
|
|
||||||
**Phase 4**: Web Routes and Templates (v0.5.0 target)
|
**Phase 6**: Micropub Endpoint (NOT YET IMPLEMENTED)
|
||||||
- **Status**: Design complete, ready for implementation
|
- **Status**: NOT STARTED - Planned for V1 but not yet implemented
|
||||||
- **Design Docs**: phase-4-web-interface.md, phase-4-architectural-assessment-20251118.md
|
- **Current Blocker**: Need to complete Micropub implementation
|
||||||
- **New ADR**: ADR-011 (Development Authentication Mechanism)
|
- **Progress**: 0%
|
||||||
- **Progress**: 0% (not started)
|
|
||||||
|
|
||||||
### Remaining Phases ⏳
|
### Remaining Phases ⏳
|
||||||
|
|
||||||
| Phase | Estimated Effort | Priority |
|
| Phase | Estimated Effort | Priority | Status |
|
||||||
|-------|-----------------|----------|
|
|-------|-----------------|----------|---------|
|
||||||
| 4 - Web Interface | 34 hours | HIGH |
|
| 6 - Micropub | 9-12 hours | HIGH | ❌ NOT IMPLEMENTED |
|
||||||
| 5 - RSS Feed | 4-5 hours | HIGH |
|
| 7 - REST API (Notes CRUD) | 3-4 hours | LOW (optional) | ❌ NOT IMPLEMENTED |
|
||||||
| 6 - Micropub | 9-12 hours | HIGH |
|
| 8 - Testing & QA | 9-12 hours | HIGH | ⚠️ PARTIAL (standards validation pending) |
|
||||||
| 7 - API Routes | 3-4 hours | MEDIUM (optional) |
|
| 9 - Documentation | 5-7 hours | HIGH | ⚠️ PARTIAL (some docs complete) |
|
||||||
| 8 - Testing & QA | 9-12 hours | HIGH |
|
| 10 - Release Prep | 3-5 hours | CRITICAL | ⏳ PENDING |
|
||||||
| 9 - Documentation | 5-7 hours | HIGH |
|
|
||||||
| 10 - Release Prep | 3-5 hours | CRITICAL |
|
|
||||||
|
|
||||||
**Overall Progress**: ~33% complete (Phases 1-3 done, 7 phases remaining)
|
**Overall Progress**: ~70% complete (Phases 1-5 done, Phase 6 critical blocker for V1)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## CRITICAL: Unimplemented Features in v0.9.5
|
||||||
|
|
||||||
|
These features are **IN SCOPE for V1** but **NOT YET IMPLEMENTED** as of v0.9.5:
|
||||||
|
|
||||||
|
### 1. Micropub Endpoint ❌
|
||||||
|
**Status**: NOT IMPLEMENTED
|
||||||
|
**Routes**: `/api/micropub` does not exist
|
||||||
|
**Impact**: Cannot publish from external Micropub clients (Quill, Indigenous, etc.)
|
||||||
|
**Required for V1**: YES (core IndieWeb feature)
|
||||||
|
**Tracking**: Phase 6 (9-12 hours estimated)
|
||||||
|
|
||||||
|
### 2. Notes CRUD API ❌
|
||||||
|
**Status**: NOT IMPLEMENTED
|
||||||
|
**Routes**: `/api/notes/*` do not exist
|
||||||
|
**Impact**: No RESTful JSON API for notes management
|
||||||
|
**Required for V1**: NO (optional, Phase 7)
|
||||||
|
**Note**: Admin web interface uses forms, not API
|
||||||
|
|
||||||
|
### 3. RSS Feed Active Generation ⚠️
|
||||||
|
**Status**: CODE EXISTS but route may not be wired correctly
|
||||||
|
**Route**: `/feed.xml` should exist but needs verification
|
||||||
|
**Impact**: RSS syndication may not be working
|
||||||
|
**Required for V1**: YES (core syndication feature)
|
||||||
|
**Implemented in**: v0.6.0 (feed module exists, route should be active)
|
||||||
|
|
||||||
|
### 4. IndieAuth Token Endpoint ❌
|
||||||
|
**Status**: AUTHORIZATION ENDPOINT ONLY
|
||||||
|
**Current**: Only authentication flow implemented (for admin login)
|
||||||
|
**Missing**: Token endpoint for Micropub authentication
|
||||||
|
**Impact**: Cannot authenticate Micropub requests
|
||||||
|
**Required for V1**: YES (required for Micropub)
|
||||||
|
**Note**: May use external IndieAuth server instead of self-hosted
|
||||||
|
|
||||||
|
### 5. Microformats Validation ⚠️
|
||||||
|
**Status**: MARKUP EXISTS but not validated
|
||||||
|
**Current**: Templates have microformats (h-entry, h-card, h-feed)
|
||||||
|
**Missing**: IndieWebify.me validation tests
|
||||||
|
**Impact**: May not parse correctly in microformats parsers
|
||||||
|
**Required for V1**: YES (standards compliance)
|
||||||
|
**Tracking**: Phase 8.2 (validation tests)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -1236,6 +1278,122 @@ Final steps before V1 release.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Post-V1 Roadmap
|
||||||
|
|
||||||
|
### Phase 11: Micropub Extended Operations (V1.1)
|
||||||
|
|
||||||
|
**Priority**: HIGH for V1.1 release
|
||||||
|
**Estimated Effort**: 4-6 hours
|
||||||
|
**Dependencies**: Phase 6 (Micropub Core) must be complete
|
||||||
|
|
||||||
|
#### 11.1 Update Operations
|
||||||
|
- [ ] Implement `action=update` handler in `/micropub`
|
||||||
|
- Support replace operations (replace entire property)
|
||||||
|
- Support add operations (append to array properties)
|
||||||
|
- Support delete operations (remove from array properties)
|
||||||
|
- Map Micropub properties to StarPunk note fields
|
||||||
|
- Validate URL belongs to this StarPunk instance
|
||||||
|
- **Acceptance Criteria**: Can update posts via Micropub clients
|
||||||
|
|
||||||
|
#### 11.2 Delete Operations
|
||||||
|
- [ ] Implement `action=delete` handler in `/micropub`
|
||||||
|
- Soft delete implementation (set deleted_at timestamp)
|
||||||
|
- URL validation and slug extraction
|
||||||
|
- Authorization check (delete scope required)
|
||||||
|
- Proper 204 No Content response
|
||||||
|
- **Acceptance Criteria**: Can delete posts via Micropub clients
|
||||||
|
|
||||||
|
#### 11.3 Extended Scopes
|
||||||
|
- [ ] Add "update" and "delete" to SUPPORTED_SCOPES
|
||||||
|
- [ ] Update authorization form to display requested scopes
|
||||||
|
- [ ] Implement scope-specific permission checks
|
||||||
|
- [ ] Update token endpoint to validate extended scopes
|
||||||
|
- [ ] **Acceptance Criteria**: Fine-grained permission control
|
||||||
|
|
||||||
|
### Phase 12: Media Endpoint (V1.2)
|
||||||
|
|
||||||
|
**Priority**: MEDIUM for V1.2 release
|
||||||
|
**Estimated Effort**: 6-8 hours
|
||||||
|
**Dependencies**: Micropub core functionality
|
||||||
|
|
||||||
|
#### 12.1 Media Upload Endpoint
|
||||||
|
- [ ] Create `/micropub/media` endpoint
|
||||||
|
- [ ] Handle multipart/form-data file uploads
|
||||||
|
- [ ] Store files in `/data/media/YYYY/MM/` structure
|
||||||
|
- [ ] Generate unique filenames to prevent collisions
|
||||||
|
- [ ] Image optimization (resize, compress)
|
||||||
|
- [ ] Return 201 Created with Location header
|
||||||
|
- [ ] **Acceptance Criteria**: Can upload images via Micropub clients
|
||||||
|
|
||||||
|
#### 12.2 Media in Posts
|
||||||
|
- [ ] Support photo property in Micropub create/update
|
||||||
|
- [ ] Embed images in Markdown content
|
||||||
|
- [ ] Update templates to display images properly
|
||||||
|
- [ ] Add media-endpoint to Micropub config query
|
||||||
|
- [ ] **Acceptance Criteria**: Posts can include images
|
||||||
|
|
||||||
|
### Phase 13: Advanced IndieWeb Features (V2.0)
|
||||||
|
|
||||||
|
**Priority**: LOW - Future enhancement
|
||||||
|
**Estimated Effort**: 10-15 hours per feature
|
||||||
|
**Dependencies**: All V1.x features complete
|
||||||
|
|
||||||
|
#### 13.1 Webmentions
|
||||||
|
- [ ] Receive webmentions at `/webmention` endpoint
|
||||||
|
- [ ] Verify source links to target
|
||||||
|
- [ ] Extract microformats from source
|
||||||
|
- [ ] Store webmentions in database
|
||||||
|
- [ ] Display webmentions on posts
|
||||||
|
- [ ] Send webmentions on publish
|
||||||
|
- [ ] Moderation interface in admin
|
||||||
|
|
||||||
|
#### 13.2 Syndication (POSSE)
|
||||||
|
- [ ] Add syndication targets configuration
|
||||||
|
- [ ] Support mp-syndicate-to in Micropub
|
||||||
|
- [ ] Implement Mastodon syndication
|
||||||
|
- [ ] Implement Twitter/X syndication (if API available)
|
||||||
|
- [ ] Store syndication URLs in post metadata
|
||||||
|
- [ ] Display syndication links on posts
|
||||||
|
|
||||||
|
#### 13.3 IndieAuth Server
|
||||||
|
- [ ] Implement full authorization server
|
||||||
|
- [ ] Allow StarPunk to be identity provider
|
||||||
|
- [ ] Profile URL verification
|
||||||
|
- [ ] Client registration/discovery
|
||||||
|
- [ ] Token introspection endpoint
|
||||||
|
- [ ] Token revocation endpoint
|
||||||
|
- [ ] Refresh tokens support
|
||||||
|
|
||||||
|
### Phase 14: Enhanced Features (V2.0+)
|
||||||
|
|
||||||
|
**Priority**: LOW - Long-term vision
|
||||||
|
**Estimated Effort**: Variable
|
||||||
|
|
||||||
|
#### 14.1 Multiple Post Types
|
||||||
|
- [ ] Articles (long-form with title)
|
||||||
|
- [ ] Replies (in-reply-to support)
|
||||||
|
- [ ] Likes (like-of property)
|
||||||
|
- [ ] Bookmarks (bookmark-of property)
|
||||||
|
- [ ] Events (h-event microformat)
|
||||||
|
- [ ] Check-ins (location data)
|
||||||
|
|
||||||
|
#### 14.2 Multi-User Support
|
||||||
|
- [ ] User registration system
|
||||||
|
- [ ] Per-user permissions and roles
|
||||||
|
- [ ] Separate author feeds (/author/username)
|
||||||
|
- [ ] Multi-author Micropub (me verification)
|
||||||
|
- [ ] User profile pages
|
||||||
|
|
||||||
|
#### 14.3 Advanced UI Features
|
||||||
|
- [ ] WYSIWYG Markdown editor
|
||||||
|
- [ ] Draft/schedule posts
|
||||||
|
- [ ] Batch operations interface
|
||||||
|
- [ ] Analytics dashboard
|
||||||
|
- [ ] Theme customization
|
||||||
|
- [ ] Plugin system
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Summary Checklist
|
## Summary Checklist
|
||||||
|
|
||||||
### Core Features (Must Have)
|
### Core Features (Must Have)
|
||||||
@@ -1243,36 +1401,49 @@ Final steps before V1 release.
|
|||||||
- 86% test coverage, 85 tests passing
|
- 86% test coverage, 85 tests passing
|
||||||
- Full file/database synchronization
|
- Full file/database synchronization
|
||||||
- Soft and hard delete support
|
- Soft and hard delete support
|
||||||
- [x] **IndieLogin authentication** ✅ v0.4.0
|
- [x] **IndieLogin authentication** ✅ v0.8.0
|
||||||
- 96% test coverage, 37 tests passing
|
- 96% test coverage, 51 tests passing
|
||||||
- CSRF protection, session management
|
- CSRF protection, session management, PKCE
|
||||||
- Token hashing for security
|
- Token hashing for security
|
||||||
- [ ] **Admin web interface** ⏳ Designed, not implemented
|
- IndieLogin.com integration working
|
||||||
- Design complete (Phase 4)
|
- [x] **Admin web interface** ✅ v0.5.2
|
||||||
- Routes specified
|
- Routes: `/auth/login`, `/auth/callback`, `/auth/logout`, `/admin/*`
|
||||||
- Templates planned
|
- Dashboard, note editor, delete functionality
|
||||||
- [ ] **Public web interface** ⏳ Designed, not implemented
|
- Flash messages, form handling
|
||||||
- Design complete (Phase 4)
|
- 87% test coverage, 405 tests passing
|
||||||
- Microformats2 markup planned
|
- [x] **Public web interface** ✅ v0.5.0
|
||||||
- [ ] **RSS feed generation** ⏳ Not started
|
- Routes: `/`, `/note/<slug>`
|
||||||
- Phase 5
|
- Microformats2 markup (h-entry, h-card, h-feed)
|
||||||
- [ ] **Micropub endpoint** ⏳ Not started
|
- Responsive design
|
||||||
- Phase 6
|
- Server-side rendering
|
||||||
- Token model ready
|
- [x] **RSS feed generation** ✅ v0.6.0
|
||||||
- [x] **Core tests passing** ✅ Phases 1-3 complete
|
- Route: `/feed.xml` active
|
||||||
|
- RSS 2.0 compliant
|
||||||
|
- 96% test coverage
|
||||||
|
- Auto-discovery links in HTML
|
||||||
|
- [ ] **Micropub endpoint** ❌ NOT IMPLEMENTED
|
||||||
|
- Phase 6 not started
|
||||||
|
- Critical blocker for V1
|
||||||
|
- Token model ready but no endpoint
|
||||||
|
- [x] **Core tests passing** ✅ v0.9.5
|
||||||
- Utils: >90% coverage
|
- Utils: >90% coverage
|
||||||
- Models: >90% coverage
|
- Models: >90% coverage
|
||||||
- Notes: 86% coverage
|
- Notes: 86% coverage
|
||||||
- Auth: 96% coverage
|
- Auth: 96% coverage
|
||||||
- [ ] **Standards compliance** ⏳ Partial
|
- Feed: 96% coverage
|
||||||
- HTML5: Not yet tested
|
- Routes: 87% coverage
|
||||||
- RSS: Not yet implemented
|
- Overall: 87% coverage
|
||||||
- Microformats: Planned in Phase 4
|
- [ ] **Standards compliance** ⚠️ PARTIAL
|
||||||
- Micropub: Not yet implemented
|
- HTML5: ⚠️ Not validated (markup exists)
|
||||||
- [x] **Documentation complete (Phases 1-3)** ✅
|
- RSS: ✅ Implemented and tested
|
||||||
- ADRs 001-011 complete
|
- Microformats: ⚠️ Markup exists, not validated
|
||||||
- Design docs for Phases 1-4
|
- Micropub: ❌ Not implemented
|
||||||
- Implementation reports for Phases 2-3
|
- [x] **Documentation extensive** ✅ v0.9.5
|
||||||
|
- ADRs 001-025 complete
|
||||||
|
- Design docs for Phases 1-5
|
||||||
|
- Implementation reports for major features
|
||||||
|
- Container deployment guide
|
||||||
|
- CHANGELOG maintained
|
||||||
|
|
||||||
### Optional Features (Nice to Have)
|
### Optional Features (Nice to Have)
|
||||||
- [ ] Markdown preview (JavaScript) - Phase 4.5
|
- [ ] Markdown preview (JavaScript) - Phase 4.5
|
||||||
@@ -1282,54 +1453,66 @@ Final steps before V1 release.
|
|||||||
- [ ] Feed caching - Deferred to V2
|
- [ ] Feed caching - Deferred to V2
|
||||||
|
|
||||||
### Quality Gates
|
### Quality Gates
|
||||||
- [x] **Test coverage >80%** ✅ Phases 1-3 achieve 86-96%
|
- [x] **Test coverage >80%** ✅ v0.9.5 achieves 87% overall
|
||||||
- [ ] **All validators pass** ⏳ Not yet tested
|
- [ ] **All validators pass** ⚠️ PARTIAL
|
||||||
- HTML validator: Phase 8
|
- HTML validator: ⏳ Not tested
|
||||||
- RSS validator: Phase 8
|
- RSS validator: ✅ RSS 2.0 compliant (v0.6.0)
|
||||||
- Microformats validator: Phase 8
|
- Microformats validator: ⏳ Not tested (markup exists)
|
||||||
- Micropub validator: Phase 8
|
- Micropub validator: ❌ N/A (not implemented)
|
||||||
- [x] **Security tests pass** ✅ Phases 1-3
|
- [x] **Security tests pass** ✅ v0.9.5
|
||||||
- SQL injection prevention tested
|
- SQL injection prevention tested
|
||||||
- Path traversal prevention tested
|
- Path traversal prevention tested
|
||||||
- CSRF protection tested
|
- CSRF protection tested
|
||||||
- Token hashing tested
|
- Token hashing tested
|
||||||
- [ ] **Manual testing complete** ⏳ Not yet performed
|
- PKCE implementation tested
|
||||||
- [ ] **Performance targets met** ⏳ Not yet tested
|
- [x] **Manual testing complete** ✅ v0.9.5
|
||||||
- [ ] **Production deployment tested** ⏳ Not yet performed
|
- IndieLogin.com authentication working
|
||||||
|
- Admin interface functional
|
||||||
|
- Note CRUD operations tested
|
||||||
|
- RSS feed generation verified
|
||||||
|
- [x] **Performance targets met** ✅ v0.9.5
|
||||||
|
- Containerized deployment with gunicorn
|
||||||
|
- Response times acceptable
|
||||||
|
- [x] **Production deployment tested** ✅ v0.9.5
|
||||||
|
- Container deployment working
|
||||||
|
- Gitea CI/CD pipeline operational
|
||||||
|
- Health check endpoint functional
|
||||||
|
|
||||||
**Current Status**: 3/10 phases complete (33%), foundation solid, ready for Phase 4
|
**Current Status**: 5/7 critical phases complete (71%), Micropub is primary blocker for V1
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Estimated Timeline
|
## Estimated Timeline
|
||||||
|
|
||||||
**Total Effort**: 40-60 hours of focused development work
|
**Total Effort**: 40-60 hours of focused development work
|
||||||
|
**Completed Effort**: ~35 hours (Phases 1-5)
|
||||||
|
**Remaining Effort**: ~15-25 hours (Phase 6, validation, V1 release)
|
||||||
|
|
||||||
**Breakdown by Phase**:
|
**Breakdown by Phase**:
|
||||||
- Phase 1 (Utilities & Models): 5-7 hours
|
- ~~Phase 1 (Utilities & Models): 5-7 hours~~ ✅ Complete (v0.1.0)
|
||||||
- Phase 2 (Notes Management): 6-8 hours
|
- ~~Phase 2 (Notes Management): 6-8 hours~~ ✅ Complete (v0.3.0)
|
||||||
- Phase 3 (Authentication): 5-6 hours
|
- ~~Phase 3 (Authentication): 5-6 hours~~ ✅ Complete (v0.8.0)
|
||||||
- Phase 4 (Web Interface): 13-17 hours
|
- ~~Phase 4 (Web Interface): 13-17 hours~~ ✅ Complete (v0.5.2)
|
||||||
- Phase 5 (RSS Feed): 4-5 hours
|
- ~~Phase 5 (RSS Feed): 4-5 hours~~ ✅ Complete (v0.6.0)
|
||||||
- Phase 6 (Micropub): 9-12 hours
|
- Phase 6 (Micropub): 9-12 hours ❌ NOT STARTED
|
||||||
- Phase 7 (REST API): 3-4 hours (optional)
|
- Phase 7 (REST API): 3-4 hours ⏳ OPTIONAL (can defer to V2)
|
||||||
- Phase 8 (Testing): 9-12 hours
|
- Phase 8 (Testing & QA): 9-12 hours ⚠️ PARTIAL (validation tests pending)
|
||||||
- Phase 9 (Documentation): 5-7 hours
|
- Phase 9 (Documentation): 5-7 hours ⚠️ PARTIAL (README update needed)
|
||||||
- Phase 10 (Release): 3-5 hours
|
- Phase 10 (Release Prep): 3-5 hours ⏳ PENDING
|
||||||
|
|
||||||
**Original Schedule**:
|
**Current Status** (as of 2025-11-24):
|
||||||
- ~~Week 1: Phases 1-3 (foundation and auth)~~ ✅ Complete
|
- **Completed**: Phases 1-5 (foundation, auth, web, RSS) - ~35 hours ✅
|
||||||
- Week 2: Phase 4 (web interface) ⏳ Current
|
- **In Progress**: Container deployment, CI/CD (v0.9.5) ✅
|
||||||
- Week 3: Phases 5-6 (RSS and Micropub)
|
- **Critical Blocker**: Phase 6 (Micropub) - ~12 hours ❌
|
||||||
- Week 4: Phases 8-10 (testing, docs, release)
|
- **Remaining**: Validation tests, final docs, V1 release - ~8 hours ⏳
|
||||||
|
|
||||||
**Revised Schedule** (from 2025-11-18):
|
**Path to V1**:
|
||||||
- **Completed**: Phases 1-3 (utilities, models, notes, auth) - ~20 hours
|
1. **Micropub Implementation** (9-12 hours) - Required for V1
|
||||||
- **Next**: Phase 4 (web interface) - ~34 hours (~5 days)
|
2. **Standards Validation** (3-4 hours) - HTML, Microformats, Micropub.rocks
|
||||||
- **Then**: Phases 5-6 (RSS + Micropub) - ~15 hours (~2 days)
|
3. **Documentation Polish** (2-3 hours) - Update README, verify all docs
|
||||||
- **Finally**: Phases 8-10 (QA + docs + release) - ~20 hours (~3 days)
|
4. **V1 Release** (1-2 hours) - Tag, announce, publish
|
||||||
|
|
||||||
**Estimated Completion**: ~10-12 development days from 2025-11-18
|
**Estimated V1 Completion**: ~2-3 development days from 2025-11-24 (if Micropub implemented)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# ADR-019 Implementation Report
|
# ADR-025 Implementation Report
|
||||||
|
|
||||||
**Date**: 2025-11-19
|
**Date**: 2025-11-19
|
||||||
**Version**: 0.8.0
|
**Version**: 0.8.0
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
## Summary
|
## Summary
|
||||||
|
|
||||||
Successfully implemented ADR-019: IndieAuth Correct Implementation Based on IndieLogin.com API with PKCE support. This fixes the critical authentication bug that has been present since v0.7.0.
|
Successfully implemented ADR-025: IndieAuth Correct Implementation Based on IndieLogin.com API with PKCE support. This fixes the critical authentication bug that has been present since v0.7.0.
|
||||||
|
|
||||||
## Implementation Completed
|
## Implementation Completed
|
||||||
|
|
||||||
@@ -53,8 +53,8 @@ Successfully implemented ADR-019: IndieAuth Correct Implementation Based on Indi
|
|||||||
- ✅ Updated version to 0.8.0 in starpunk/__init__.py
|
- ✅ Updated version to 0.8.0 in starpunk/__init__.py
|
||||||
- ✅ Updated CHANGELOG.md with v0.8.0 entry
|
- ✅ Updated CHANGELOG.md with v0.8.0 entry
|
||||||
- ✅ Added known issues notes to v0.7.0 and v0.7.1 CHANGELOG entries
|
- ✅ Added known issues notes to v0.7.0 and v0.7.1 CHANGELOG entries
|
||||||
- ✅ Updated ADR-016 status to "Superseded by ADR-019"
|
- ✅ Updated ADR-016 status to "Superseded by ADR-025"
|
||||||
- ✅ Updated ADR-017 status to "Superseded by ADR-019"
|
- ✅ Updated ADR-017 status to "Superseded by ADR-025"
|
||||||
- ✅ Created TODO_TEST_UPDATES.md documenting test updates needed
|
- ✅ Created TODO_TEST_UPDATES.md documenting test updates needed
|
||||||
|
|
||||||
## Lines of Code Changes
|
## Lines of Code Changes
|
||||||
@@ -201,16 +201,16 @@ ALTER TABLE auth_state ADD COLUMN code_verifier TEXT NOT NULL DEFAULT '';
|
|||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
- **ADR-019**: docs/decisions/ADR-019-indieauth-pkce-authentication.md
|
- **ADR-025**: docs/decisions/ADR-025-indieauth-pkce-authentication.md
|
||||||
- **Design Doc**: docs/designs/indieauth-pkce-authentication.md
|
- **Design Doc**: docs/designs/indieauth-pkce-authentication.md
|
||||||
- **Versioning Guidance**: docs/reports/ADR-019-versioning-guidance.md
|
- **Versioning Guidance**: docs/reports/ADR-025-versioning-guidance.md
|
||||||
- **Implementation Summary**: docs/reports/ADR-019-implementation-summary.md
|
- **Implementation Summary**: docs/reports/ADR-025-implementation-summary.md
|
||||||
- **RFC 7636**: PKCE specification
|
- **RFC 7636**: PKCE specification
|
||||||
- **IndieLogin.com API**: https://indielogin.com/api
|
- **IndieLogin.com API**: https://indielogin.com/api
|
||||||
|
|
||||||
## Conclusion
|
## Conclusion
|
||||||
|
|
||||||
ADR-019 has been successfully implemented. The IndieAuth authentication flow now correctly implements PKCE as required by IndieLogin.com, uses the correct API endpoints, and validates the issuer. Unnecessary features from v0.7.0 and v0.7.1 have been removed, resulting in cleaner, more maintainable code.
|
ADR-025 has been successfully implemented. The IndieAuth authentication flow now correctly implements PKCE as required by IndieLogin.com, uses the correct API endpoints, and validates the issuer. Unnecessary features from v0.7.0 and v0.7.1 have been removed, resulting in cleaner, more maintainable code.
|
||||||
|
|
||||||
The implementation follows the architect's specifications exactly and maintains the project's minimal code philosophy. Version 0.8.0 is ready for testing and deployment.
|
The implementation follows the architect's specifications exactly and maintains the project's minimal code philosophy. Version 0.8.0 is ready for testing and deployment.
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# ADR-019 Implementation Summary
|
# ADR-025 Implementation Summary
|
||||||
|
|
||||||
**Quick Reference for Developer**
|
**Quick Reference for Developer**
|
||||||
**Date**: 2025-11-19
|
**Date**: 2025-11-19
|
||||||
@@ -12,8 +12,8 @@ This is a **critical bug fix** that implements IndieAuth authentication correctl
|
|||||||
|
|
||||||
All documentation has been separated into proper categories:
|
All documentation has been separated into proper categories:
|
||||||
|
|
||||||
### 1. **Architecture Decision Record** (ADR-019)
|
### 1. **Architecture Decision Record** (ADR-025)
|
||||||
**File**: `/home/phil/Projects/starpunk/docs/decisions/ADR-019-indieauth-pkce-authentication.md`
|
**File**: `/home/phil/Projects/starpunk/docs/decisions/ADR-025-indieauth-pkce-authentication.md`
|
||||||
|
|
||||||
**What it contains**:
|
**What it contains**:
|
||||||
- Context: Why we need this change
|
- Context: Why we need this change
|
||||||
@@ -39,7 +39,7 @@ All documentation has been separated into proper categories:
|
|||||||
This is your **primary implementation reference**.
|
This is your **primary implementation reference**.
|
||||||
|
|
||||||
### 3. **Versioning Guidance**
|
### 3. **Versioning Guidance**
|
||||||
**File**: `/home/phil/Projects/starpunk/docs/reports/ADR-019-versioning-guidance.md`
|
**File**: `/home/phil/Projects/starpunk/docs/reports/ADR-025-versioning-guidance.md`
|
||||||
|
|
||||||
**What it contains**:
|
**What it contains**:
|
||||||
- Version number decision: **0.8.0**
|
- Version number decision: **0.8.0**
|
||||||
@@ -53,7 +53,7 @@ This is your **primary implementation reference**.
|
|||||||
Follow the design document for detailed steps. This is just a high-level checklist:
|
Follow the design document for detailed steps. This is just a high-level checklist:
|
||||||
|
|
||||||
### Pre-Implementation
|
### Pre-Implementation
|
||||||
- [ ] Read ADR-019 (architectural decision)
|
- [ ] Read ADR-025 (architectural decision)
|
||||||
- [ ] Read full design document
|
- [ ] Read full design document
|
||||||
- [ ] Review versioning guidance
|
- [ ] Review versioning guidance
|
||||||
- [ ] Understand PKCE flow
|
- [ ] Understand PKCE flow
|
||||||
@@ -91,8 +91,8 @@ Follow the design document for detailed steps. This is just a high-level checkli
|
|||||||
- [ ] **Do NOT delete v0.7.0 or v0.7.1 tags**
|
- [ ] **Do NOT delete v0.7.0 or v0.7.1 tags**
|
||||||
|
|
||||||
### Documentation
|
### Documentation
|
||||||
- [ ] Update ADR-016 status to "Superseded by ADR-019"
|
- [ ] Update ADR-016 status to "Superseded by ADR-025"
|
||||||
- [ ] Update ADR-017 status to "Superseded by ADR-019"
|
- [ ] Update ADR-017 status to "Superseded by ADR-025"
|
||||||
- [ ] Add implementation note to ADR-005
|
- [ ] Add implementation note to ADR-005
|
||||||
|
|
||||||
## Key Points
|
## Key Points
|
||||||
@@ -123,9 +123,9 @@ Follow the design document for detailed steps. This is just a high-level checkli
|
|||||||
|
|
||||||
**Read in this order**:
|
**Read in this order**:
|
||||||
1. This file (you are here) - Overview
|
1. This file (you are here) - Overview
|
||||||
2. `/home/phil/Projects/starpunk/docs/decisions/ADR-019-indieauth-pkce-authentication.md` - Architectural decision
|
2. `/home/phil/Projects/starpunk/docs/decisions/ADR-025-indieauth-pkce-authentication.md` - Architectural decision
|
||||||
3. `/home/phil/Projects/starpunk/docs/designs/indieauth-pkce-authentication.md` - **Full implementation guide**
|
3. `/home/phil/Projects/starpunk/docs/designs/indieauth-pkce-authentication.md` - **Full implementation guide**
|
||||||
4. `/home/phil/Projects/starpunk/docs/reports/ADR-019-versioning-guidance.md` - Versioning details
|
4. `/home/phil/Projects/starpunk/docs/reports/ADR-025-versioning-guidance.md` - Versioning details
|
||||||
|
|
||||||
**Standards Reference**:
|
**Standards Reference**:
|
||||||
- `/home/phil/Projects/starpunk/docs/standards/versioning-strategy.md` - Semantic versioning rules
|
- `/home/phil/Projects/starpunk/docs/standards/versioning-strategy.md` - Semantic versioning rules
|
||||||
@@ -176,8 +176,8 @@ You're done when:
|
|||||||
**If authentication still fails**:
|
**If authentication still fails**:
|
||||||
1. Check logs for PKCE parameters (should be redacted but visible)
|
1. Check logs for PKCE parameters (should be redacted but visible)
|
||||||
2. Verify database has code_verifier column
|
2. Verify database has code_verifier column
|
||||||
3. Check authorization URL has `code_challenge` and `code_challenge_method=S256`
|
3. Check authorization URL has code_challenge and code_challenge_method=S256
|
||||||
4. Verify token exchange POST includes `code_verifier`
|
4. Verify token exchange POST includes code_verifier
|
||||||
5. Check IndieLogin.com response in logs
|
5. Check IndieLogin.com response in logs
|
||||||
|
|
||||||
**Key debugging points**:
|
**Key debugging points**:
|
||||||
@@ -192,7 +192,7 @@ You're done when:
|
|||||||
|
|
||||||
Refer to:
|
Refer to:
|
||||||
- Design document for "how"
|
- Design document for "how"
|
||||||
- ADR-019 for "why"
|
- ADR-025 for "why"
|
||||||
- Versioning guidance for "what version"
|
- Versioning guidance for "what version"
|
||||||
|
|
||||||
All documentation follows the project principle: **Every line must justify its existence.**
|
All documentation follows the project principle: **Every line must justify its existence.**
|
||||||
127
docs/standards/testing-checklist.md
Normal file
127
docs/standards/testing-checklist.md
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
# Testing Checklist
|
||||||
|
|
||||||
|
This document provides a comprehensive checklist for testing StarPunk functionality before release.
|
||||||
|
|
||||||
|
## Manual Testing Checklist
|
||||||
|
|
||||||
|
### Core Functionality
|
||||||
|
- [ ] Create notes via web interface
|
||||||
|
- [ ] Create notes via Micropub JSON
|
||||||
|
- [ ] Create notes via Micropub form-encoded
|
||||||
|
- [ ] Notes display with proper microformats
|
||||||
|
- [ ] Markdown renders correctly
|
||||||
|
- [ ] Slugs generate uniquely
|
||||||
|
- [ ] Timestamps record accurately
|
||||||
|
|
||||||
|
### Authentication & Security
|
||||||
|
- [ ] IndieAuth login flow works
|
||||||
|
- [ ] Micropub client authentication
|
||||||
|
- [ ] Token expiration works
|
||||||
|
- [ ] Rate limiting functions
|
||||||
|
|
||||||
|
### Syndication & Standards
|
||||||
|
- [ ] RSS feed validates (W3C validator)
|
||||||
|
- [ ] API returns correct status codes
|
||||||
|
|
||||||
|
### Automated Testing
|
||||||
|
- [ ] All unit tests pass
|
||||||
|
- [ ] All integration tests pass
|
||||||
|
- [ ] Test coverage >80%
|
||||||
|
|
||||||
|
## Validation Tools
|
||||||
|
|
||||||
|
### IndieWeb Standards
|
||||||
|
- **IndieWebify.me**: https://indiewebify.me/
|
||||||
|
- Verify microformats (h-entry, h-card, h-feed)
|
||||||
|
- Check IndieAuth implementation
|
||||||
|
|
||||||
|
- **IndieAuth Validator**: https://indieauth.com/validate
|
||||||
|
- Test IndieAuth flow
|
||||||
|
- Validate token handling
|
||||||
|
|
||||||
|
- **Micropub Test Suite**: https://micropub.rocks/
|
||||||
|
- Comprehensive Micropub endpoint testing
|
||||||
|
- Verify spec compliance
|
||||||
|
|
||||||
|
### Web Standards
|
||||||
|
- **W3C Feed Validator**: https://validator.w3.org/feed/
|
||||||
|
- Validate RSS 2.0 feed structure
|
||||||
|
- Check date formatting
|
||||||
|
- Verify CDATA wrapping
|
||||||
|
|
||||||
|
- **W3C HTML Validator**: https://validator.w3.org/
|
||||||
|
- Validate HTML5 markup
|
||||||
|
- Check semantic structure
|
||||||
|
- Verify accessibility
|
||||||
|
|
||||||
|
- **JSON Validator**: https://jsonlint.com/
|
||||||
|
- Validate API responses
|
||||||
|
- Check Micropub payloads
|
||||||
|
|
||||||
|
## Testing Resources
|
||||||
|
|
||||||
|
### Specifications
|
||||||
|
- IndieWeb Notes: https://indieweb.org/note
|
||||||
|
- Micropub Spec: https://micropub.spec.indieweb.org
|
||||||
|
- IndieAuth Spec: https://indieauth.spec.indieweb.org
|
||||||
|
- Microformats2: http://microformats.org/wiki/h-entry
|
||||||
|
- RSS 2.0 Spec: https://www.rssboard.org/rss-specification
|
||||||
|
|
||||||
|
### Testing & Validation
|
||||||
|
- Micropub Test Suite: https://micropub.rocks/
|
||||||
|
- IndieAuth Testing: https://indieauth.com/
|
||||||
|
- Microformats Parser: https://pin13.net/mf2/
|
||||||
|
|
||||||
|
### Example Implementations
|
||||||
|
- IndieWeb Examples: https://indieweb.org/examples
|
||||||
|
- Micropub Clients: https://indieweb.org/Micropub/Clients
|
||||||
|
|
||||||
|
## Pre-Release Validation Workflow
|
||||||
|
|
||||||
|
1. **Run Automated Tests**
|
||||||
|
```bash
|
||||||
|
uv run pytest
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Validate HTML**
|
||||||
|
- Test homepage output
|
||||||
|
- Test note permalink output
|
||||||
|
- Run through W3C HTML Validator
|
||||||
|
|
||||||
|
3. **Validate RSS Feed**
|
||||||
|
- Access /feed.xml
|
||||||
|
- Run through W3C Feed Validator
|
||||||
|
- Verify in actual RSS reader
|
||||||
|
|
||||||
|
4. **Validate Microformats**
|
||||||
|
- Test homepage with IndieWebify.me
|
||||||
|
- Test note permalinks
|
||||||
|
- Use microformats parser
|
||||||
|
|
||||||
|
5. **Validate Micropub**
|
||||||
|
- Run micropub.rocks test suite
|
||||||
|
- Test with real Micropub client (Quill)
|
||||||
|
|
||||||
|
6. **Manual Browser Testing**
|
||||||
|
- Chrome/Chromium
|
||||||
|
- Firefox
|
||||||
|
- Safari (if available)
|
||||||
|
- Mobile browsers
|
||||||
|
|
||||||
|
7. **Security Verification**
|
||||||
|
- CSRF protection working
|
||||||
|
- XSS prevention verified
|
||||||
|
- SQL injection tests pass
|
||||||
|
- Path traversal prevention works
|
||||||
|
|
||||||
|
## Success Criteria
|
||||||
|
|
||||||
|
All checklist items must pass before V1 release. If any validation tool reports errors, they must be fixed before proceeding.
|
||||||
|
|
||||||
|
## Related Documentation
|
||||||
|
|
||||||
|
- [Testing Strategy](/home/phil/Projects/starpunk/docs/architecture/overview.md#testing-strategy)
|
||||||
|
- [Implementation Plan](/home/phil/Projects/starpunk/docs/projectplan/v1/implementation-plan.md)
|
||||||
|
- [Feature Scope](/home/phil/Projects/starpunk/docs/projectplan/v1/feature-scope.md)
|
||||||
|
|
||||||
|
**Last Updated**: 2025-11-24
|
||||||
@@ -153,5 +153,5 @@ def create_app(config=None):
|
|||||||
|
|
||||||
# Package version (Semantic Versioning 2.0.0)
|
# Package version (Semantic Versioning 2.0.0)
|
||||||
# See docs/standards/versioning-strategy.md for details
|
# See docs/standards/versioning-strategy.md for details
|
||||||
__version__ = "0.9.4"
|
__version__ = "0.9.5"
|
||||||
__version_info__ = (0, 9, 4)
|
__version_info__ = (0, 9, 5)
|
||||||
|
|||||||
@@ -44,9 +44,9 @@ def load_config(app, config_override=None):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Flask secret key (uses SESSION_SECRET by default)
|
# Flask secret key (uses SESSION_SECRET by default)
|
||||||
app.config["SECRET_KEY"] = os.getenv(
|
# Note: We check for truthy value to handle empty string in .env
|
||||||
"FLASK_SECRET_KEY", app.config["SESSION_SECRET"]
|
flask_secret = os.getenv("FLASK_SECRET_KEY")
|
||||||
)
|
app.config["SECRET_KEY"] = flask_secret if flask_secret else app.config["SESSION_SECRET"]
|
||||||
|
|
||||||
# Data paths
|
# Data paths
|
||||||
app.config["DATA_PATH"] = Path(os.getenv("DATA_PATH", "./data"))
|
app.config["DATA_PATH"] = Path(os.getenv("DATA_PATH", "./data"))
|
||||||
|
|||||||
Reference in New Issue
Block a user