docs: Bring all documentation up to date for v2.10.1

- architecture/: overview, technology stack, auth (OIDC + built-in
  IndieAuth), syndication (POSSE) rewritten; new database.md,
  deployment.md and indieweb-protocols.md; legacy stack marked historical
- decisions/: reconstructed ADR-060 and ADR-063; 31 status corrections
  (superseded auth ADRs, proposed -> accepted); INDEX rebuilt
- design/: reconstructed the v1.6.0 documents the webmention code cites;
  reports for 18 v2 releases without a design folder; INDEX rebuilt
- projectplan/: BACKLOG rewritten (shipped items removed, open issues from
  the reviews added); RELEASE.md for v2.0.0-v2.10.1; INDEX
- standards/: development setup (uv, tests, DEV_MODE), testing (CI test
  stage), git and release flow, versioning, coding standards, cookies
- README, CLAUDE.md, .env.example (every setting the code reads, with
  defaults) brought up to date
- 137 broken links repaired (old absolute paths, moved files); stale ADR
  references in code comments corrected (comments only)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
PhilandClaude Opus 5.5 committed 2026-11-03 12:40:19 -07:00
1 parent fa551de197
commit 0716984958
143 files changed
+6222 -8660

No files matched your search

+295 -381
View File
@@ -1,428 +1,342 @@
# StarPunk Simplified Authentication Architecture
# Authentication and Authorization Architecture
Current as of v2.10.1. Decision record: [ADR-064](../decisions/ADR-064-oidc-admin-login-and-builtin-indieauth-server.md),
which supersedes the "no self-hosted IndieAuth" decisions
([ADR-050](../decisions/ADR-050-remove-custom-indieauth-server.md),
[ADR-056](../decisions/ADR-056-no-selfhosted-indieauth.md)) and the external
token verification of ADR-030 / ADR-036.
> The filename is historical: it described the v1.x "external provider only"
> design. Other documents link to it, so it is kept.
## Overview
After removing the custom IndieAuth authorization server, StarPunk becomes a pure Micropub server that relies on external providers for all authentication and authorization.
StarPunk is a single-user site with two kinds of client and two auth
mechanisms:
## Architecture Diagrams
| Who | Mechanism | Credential | Code |
|---|---|---|---|
| The site owner in a browser (admin UI, consent screen) | OpenID Connect login against an external provider (e.g. Pocket ID) | `starpunk_session` cookie, backed by a hashed row in `sessions` | `starpunk/auth.py`, `starpunk/routes/auth.py` |
| Micropub apps (Quill, Indigenous, ...) | StarPunk's own IndieAuth authorization server | Bearer access token, backed by a hashed row in `indieauth_tokens` | `starpunk/indieauth.py`, `starpunk/routes/indieauth.py` |
The two are chained: a Micropub app is approved on a consent screen that
requires an admin session, so every token ultimately rests on the OIDC
login. StarPunk stores no passwords.
### Before: Complex Mixed-Mode Architecture
```
┌──────────────────────────────────────────────────────────────┐
│ StarPunk Instance │
│ │
│ ┌────────────────────────────────────────────────────────┐ │
│ │ Web Interface │ │
│ │ ┌─────────────┐ ┌──────────────┐ ┌──────────────┐ │ │
│ │ │ Admin Login │ │ Authorization │ │ Token Issuer │ │ │
│ │ └─────────────┘ └──────────────┘ └──────────────┘ │ │
│ └────────────────────────────────────────────────────────┘ │
│ │
│ ┌────────────────────────────────────────────────────────┐ │
│ │ Auth Module │ │
│ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │
│ │ │ Sessions │ │ PKCE │ │ Tokens │ │ Codes │ │ │
│ │ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │ │
│ └────────────────────────────────────────────────────────┘ │
│ │
│ ┌────────────────────────────────────────────────────────┐ │
│ │ Database │ │
│ │ ┌────────┐ ┌──────────────────┐ ┌─────────────────┐ │ │
│ │ │ Users │ │ authorization_codes│ │ tokens │ │ │
│ │ └────────┘ └──────────────────┘ └─────────────────┘ │ │
│ └────────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────┘
Browser (owner) StarPunk OIDC provider
─────────────── ──────── ─────────────
POST /auth/login ─────────────▶ initiate_login() ── redirect ──▶ authorize (PKCE, nonce)
owner authenticates
GET /auth/callback?code&state ◀────────────────────── redirect ───┘
handle_callback(): code exchange, ID token checks,
sub == OIDC_ADMIN_SUB → create_session(ADMIN_ME)
◀── Set-Cookie: starpunk_session
Problems:
- 500+ lines of security-critical code
- Dual role: authorization server AND resource server
- Complex token lifecycle management
- Database bloat with token storage
- Maintenance burden for security updates
Micropub app StarPunk
──────────── ────────
discovers indieauth-metadata / authorization_endpoint / token_endpoint
GET /auth/authorize?... ────────▶ validate request → (OIDC login if no session) → consent page
owner approves ─────────────────▶ POST /auth/authorize/approve → redirect: code, state, iss
POST /auth/token (code, verifier) ▶ access token (hash stored in indieauth_tokens)
POST /micropub, /micropub/media ─▶ verify_access_token() + scope check
```
### After: Clean Separation of Concerns
```
┌──────────────────────────────────────────────────────────────┐
│ StarPunk Instance │
│ │
│ ┌────────────────────────────────────────────────────────┐ │
│ │ Web Interface │ │
│ │ ┌─────────────┐ ┌──────────────┐ │ │
│ │ │ Admin Login │ │ Micropub │ │ │
│ │ └─────────────┘ └──────────────┘ │ │
│ └────────────────────────────────────────────────────────┘ │
│ │
│ ┌────────────────────────────────────────────────────────┐ │
│ │ Auth Module │ │
│ │ ┌──────────────┐ ┌──────────────────────┐ │ │
│ │ │ Sessions │ │ Token Verification │ │ │
│ │ │ (Admin Only) │ │ (External Provider) │ │ │
│ │ └──────────────┘ └──────────────────────┘ │ │
│ └────────────────────────────────────────────────────────┘ │
│ │
│ ┌────────────────────────────────────────────────────────┐ │
│ │ Database │ │
│ │ ┌────────┐ ┌──────────┐ ┌─────────┐ │ │
│ │ │ Users │ │auth_state│ │ posts │ (No token tables)│ │
│ │ └────────┘ └──────────┘ └─────────┘ │ │
│ └────────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────┘
│
│ API Calls
▼
┌──────────────────────────────────────────────────────────────┐
│ External IndieAuth Providers │
│ ┌─────────────────────┐ ┌─────────────────────────┐ │
│ │ indieauth.com │ │ tokens.indieauth.com │ │
│ │ (Authorization) │ │ (Token Verification) │ │
│ └─────────────────────┘ └─────────────────────────┘ │
└──────────────────────────────────────────────────────────────┘
## 1. Admin login (OIDC)
Benefits:
- 500+ lines of code removed
- Clear single responsibility
- No security burden
- Minimal database footprint
- Zero maintenance for auth code
```
### Flow
## Authentication Flows
1. `GET /auth/login` shows `templates/admin/login.html`, or redirects to the
dashboard if the session cookie is already valid.
2. `POST /auth/login` calls `auth.initiate_login(next)`:
- Fetches `{OIDC_ISSUER}/.well-known/openid-configuration` (cached for an
hour per process). The document's `issuer` must equal `OIDC_ISSUER`, and
it must name `authorization_endpoint`, `token_endpoint` and `jwks_uri`.
- Generates `state`, `nonce` and a PKCE `code_verifier`, and stores them in
`oidc_login_state` with the sanitized `next` URL (same site only) and a
10-minute expiry.
- Redirects to the provider with `response_type=code`, `scope=openid` and
`code_challenge_method=S256`.
3. `GET /auth/callback`:
- A provider `error` parameter, or a missing `code`/`state`, flashes an
error and returns to the login page.
- The `state` row is fetched and deleted in one step: it is single use and
must not have expired.
- If the provider sent `iss` (RFC 9207), it must match the issuer.
- The code is exchanged at the token endpoint along with the
`code_verifier`. StarPunk authenticates as a confidential client (HTTP
Basic, `OIDC_CLIENT_ID` / `OIDC_CLIENT_SECRET`).
- The ID token is verified with PyJWT against the provider's JWKS. The
checks are: the signature (algorithms from the provider metadata, never
`none`), `iss`, `aud` equal to the client id, `exp`, required `iat` and
`sub`, a 60 s leeway, and a `nonce` equal to the stored one.
- `sub` must equal `OIDC_ADMIN_SUB` (constant-time comparison). Any other
account gets "Not authorized as admin".
- A session is created for `ADMIN_ME`, the owner's identity URL. It is also
the `me` of every issued token. The author h-card is refreshed from
`ADMIN_ME` on a best-effort basis that never blocks login (see
[ADR-061](../decisions/ADR-061-author-discovery.md)).
### Flow 1: Admin Authentication (Unchanged)
```
Admin User StarPunk IndieLogin.com
│ │ │
├──── GET /admin/login ───→ │ │
│ │ │
│ ←── Login Form ─────────── │ │
│ │ │
├──── POST /auth/login ───→ │ │
│ (me=admin.com) │ │
│ ├──── Redirect ──────────────→ │
│ │ (client_id=starpunk.com) │
│ ←──────────── Authorization Request ───────────────────── │
│ │ │
├───────────── Authenticate with IndieLogin ──────────────→ │
│ │ │
│ │ ←── Callback ────────────────│
│ │ (me=admin.com) │
│ │ │
│ ←── Session Cookie ─────── │ │
│ │ │
│ Admin Access │ │
```
### Sessions
### Flow 2: Micropub Client Authentication (Simplified)
```
Micropub Client StarPunk External Token Endpoint
│ │ │
├─── POST /micropub ───→ │ │
│ Bearer: token123 │ │
│ ├──── GET /token ─────────→ │
│ │ Bearer: token123 │
│ │ │
│ │ ←── Token Info ──────────│
│ │ {me, scope, client_id} │
│ │ │
│ │ [Validate me==ADMIN_ME] │
│ │ [Check scope includes │
│ │ "create"] │
│ │ │
│ ←── 201 Created ────────│ │
│ Location: /post/123 │ │
```
- `create_session(me)` makes a random 32-byte URL-safe token. Only its
SHA-256 hash is stored in `sessions`, with `me`, `expires_at`
(`SESSION_LIFETIME` days, default 30), the user agent and the IP. Expired
sessions and login states are cleaned up each time a session is created.
- Cookie `starpunk_session`: `HttpOnly`, `SameSite=Lax`, `Secure` when
`SITE_URL` is https, `max-age` equal to the session lifetime.
- `verify_session(token)` looks up the hash, checks expiry and updates
`last_used_at`.
- `@require_auth` protects `/admin/*`. Without a valid session it remembers
the URL and redirects to `/auth/login`. It sets `g.user` and `g.me`.
- A `before_request` hook also resolves the session on public pages that
carry the cookie, so the header can show "Admin" instead of "Log in".
- `POST /auth/logout` deletes the session row and the cookie.
## Component Responsibilities
### Configuration
### StarPunk Components
Outside `DEV_MODE`, `OIDC_ISSUER`, `OIDC_CLIENT_ID`, `OIDC_CLIENT_SECRET`,
`OIDC_ADMIN_SUB` and `ADMIN_ME` are required, and startup fails without them.
The provider must have `{SITE_URL}/auth/callback` registered as a redirect
URI.
#### 1. Admin Authentication (`/auth/*`)
**Responsibility**: Manage admin sessions via IndieLogin.com
**Does**:
- Initiate OAuth flow with IndieLogin.com
- Validate callback and create session
- Manage session lifecycle
### Development mode
**Does NOT**:
- Issue tokens
- Store passwords
- Manage user identities
With `DEV_MODE=true` (and `DEV_ADMIN_ME`), `/dev/login` creates a session
without OIDC. The blueprint is registered only in dev mode, and its
`before_request` guard returns 404 if `DEV_MODE` is off. Every page shows a
warning banner while it is on. Never enable it in production.
#### 2. Micropub Endpoint (`/micropub`)
**Responsibility**: Accept and process Micropub requests
**Does**:
- Extract Bearer tokens from requests
- Verify tokens with external endpoint
- Create/update/delete posts
- Return proper Micropub responses
## 2. Built-in IndieAuth authorization server
**Does NOT**:
- Issue tokens
- Manage authorization codes
- Store token data
StarPunk issues tokens for exactly one identity, `ADMIN_ME`. It implements
the authorization code flow of the current IndieAuth spec
(https://indieauth.spec.indieweb.org/), with PKCE required.
#### 3. Token Verification Module
**Responsibility**: Validate tokens with external providers
**Does**:
- Call external token endpoint
- Cache valid tokens (5 min TTL)
- Validate scope and identity
### Endpoints
**Does NOT**:
- Generate tokens
- Store tokens permanently
- Manage token lifecycle
| Method | Path | Purpose |
|---|---|---|
| GET | `/.well-known/oauth-authorization-server` | Server metadata (the target of `rel=indieauth-metadata`) |
| GET | `/auth/authorize` | Validate the request; show the consent screen (admin session required) |
| POST | `/auth/authorize/approve` | Consent decision from the screen |
| POST | `/auth/authorize` | Profile-only code redemption, returns `{"me": ...}` |
| POST | `/auth/token` | Exchange a code for an access token; also legacy `action=revoke` |
| GET | `/auth/token` | Legacy token verification (Bearer token → `me`, `client_id`, `scope`) |
| POST | `/auth/revoke` | RFC 7009 revocation (always 200) |
### External Provider Responsibilities
All JSON responses carry `Cache-Control: no-store`. Errors use the OAuth
form `{"error", "error_description"}`.
#### indieauth.com
- User authentication
- Authorization consent
- Authorization code generation
- Profile discovery
### Metadata
#### tokens.indieauth.com
- Token issuance
- Token verification
- Token revocation
- Scope management
## Configuration
### Required Settings
```ini
# Identity of the admin user
ADMIN_ME=https://your-domain.com
# External token endpoint for verification
TOKEN_ENDPOINT=https://tokens.indieauth.com/token
# Admin session secret (existing)
SECRET_KEY=your-secret-key
```
### HTML Discovery
```html
<!-- Added to all pages -->
<link rel="authorization_endpoint" href="https://indieauth.com/auth">
<link rel="token_endpoint" href="https://tokens.indieauth.com/token">
<link rel="micropub" href="https://starpunk.example.com/micropub">
```
## Security Model
### Trust Boundaries
```
┌─────────────────────────────────────────────────────────────┐
│ Trusted Zone │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ StarPunk Application │ │
│ │ - Session management │ │
│ │ - Post creation/management │ │
│ │ - Admin interface │ │
│ └──────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
│
Token Verification API
│
┌─────────────────────────────────────────────────────────────┐
│ Semi-Trusted Zone │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ External IndieAuth Providers │ │
│ │ - Token validation │ │
│ │ - Identity verification │ │
│ └──────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
│
User Authentication
│
┌─────────────────────────────────────────────────────────────┐
│ Untrusted Zone │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ Micropub Clients │ │
│ │ - Must provide valid Bearer tokens │ │
│ │ - Tokens verified on every request │ │
│ └──────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
```
### Security Benefits of Simplified Architecture
1. **Reduced Attack Surface**
- No token generation = no cryptographic mistakes
- No token storage = no database leaks
- No PKCE = no implementation errors
2. **Specialized Security**
- Auth providers focus solely on security
- Regular updates from specialized teams
- Community-vetted implementations
3. **Clear Boundaries**
- StarPunk only verifies, never issues
- Single source of truth (external provider)
- No confused deputy problems
## Performance Characteristics
### Token Verification Performance
```
Without Cache:
┌──────────┐ 200-500ms ┌─────────────┐
│ Micropub ├───────────────────→│Token Endpoint│
└──────────┘ └─────────────┘
With Cache (95% hit rate):
┌──────────┐ <1ms ┌─────────────┐
│ Micropub ├───────────────────→│ Memory Cache │
└──────────┘ └─────────────┘
```
### Cache Strategy
```python
Cache Key: SHA256(token)
Cache Value: {
'me': 'https://user.com',
'client_id': 'https://client.com',
'scope': 'create update delete',
'expires_at': timestamp + 300 # 5 minutes
```json
{
"issuer": "<SITE_URL>/",
"authorization_endpoint": "<SITE_URL>/auth/authorize",
"token_endpoint": "<SITE_URL>/auth/token",
"revocation_endpoint": "<SITE_URL>/auth/revoke",
"revocation_endpoint_auth_methods_supported": ["none"],
"scopes_supported": ["create", "update", "delete", "media", "profile"],
"response_types_supported": ["code"],
"grant_types_supported": ["authorization_code"],
"code_challenge_methods_supported": ["S256"],
"authorization_response_iss_parameter_supported": true
}
```
### Expected Latencies
- First request: 200-500ms (external API)
- Cached request: <1ms
- Admin login: 1-2s (OAuth flow)
- Post creation: <50ms (after auth)
StarPunk has no introspection or userinfo endpoint. Only StarPunk itself
checks its tokens.
## Migration Impact
### Authorization request validation (`validate_authorization_request`)
### Breaking Changes
1. **All existing tokens invalid**
- Users must re-authenticate
- No migration path for tokens
- `client_id` must be an http(s) URL without a fragment.
- `redirect_uri` must be present and have no fragment. It must either share
the `client_id`'s scheme, host and port, or be published by the client. To
check the second case, StarPunk fetches the `client_id` URL (5 s timeout,
with an SSRF check on the URL unless `DEV_MODE` is on). It reads
`redirect_uris` from a JSON client metadata document, or
`rel="redirect_uri"` from the `Link` header and from `<link>`/`<a>`
elements.
- Problems with `client_id` or `redirect_uri` are shown to the user on an
error page (HTTP 400). They are never redirected, because the redirect
target can't be trusted.
- Other problems are redirected to the client with `error`,
`error_description`, `state` and `iss`. These are: a `response_type` other
than `code` (`unsupported_response_type`), a missing `state`, a missing
`code_challenge`, or a `code_challenge_method` other than `S256`.
- `scope` is split on spaces. Requested scopes are not filtered against
`scopes_supported`.
2. **Endpoint removal**
- `/auth/authorization` → 404
- `/auth/token` → 404
### Consent screen
3. **Configuration required**
- Must set `ADMIN_ME`
- Must configure domain with IndieAuth links
If `GET /auth/authorize` gets a valid request but there is no admin session,
StarPunk stores the request URL and redirects to the OIDC login, which
returns to that URL afterwards. With a session, it renders
`templates/admin/authorize.html`. The page shows the client id, the identity
the client will act as, the redirect URI, and one checkbox per requested
scope (all checked). A request without scopes is described as "only wants to
confirm your identity".
### Non-Breaking Preserved Functionality
1. **Admin login unchanged**
- Same URL (`/admin/login`)
- Same provider (IndieLogin.com)
- Sessions preserved
`POST /auth/authorize/approve` checks the session again and re-validates the
request from hidden form fields. "Deny" redirects with
`error=access_denied`. "Approve" grants only the scopes that were both
requested and left checked, issues a code, and redirects with `code`,
`state` and `iss`.
2. **Micropub API unchanged**
- Same endpoint (`/micropub`)
- Same request format
- Same response format
### Codes and tokens
## Comparison with Other Systems
| | Authorization code | Access token |
|---|---|---|
| Table | `indieauth_codes` | `indieauth_tokens` |
| Value | 32 random bytes, URL-safe | 32 random bytes, URL-safe |
| Stored as | SHA-256 hash | SHA-256 hash |
| Lifetime | 10 minutes | `INDIEAUTH_TOKEN_LIFETIME_DAYS` (default 90) |
| Bound to | `client_id`, `redirect_uri`, `scope`, `code_challenge` | `client_id`, `scope` |
### WordPress + IndieAuth Plugin
- **Similarity**: External provider for auth
- **Difference**: WP has user management, we don't
`redeem_authorization_code` handles redemption for both `POST /auth/token`
and `POST /auth/authorize`:
### Known IndieWeb Sites
- **micro.blog**: Custom auth server (complex)
- **Indigenous**: Client only, uses external auth
- **StarPunk**: Micropub server only (simple)
1. `code` and `code_verifier` are required.
2. An atomic `UPDATE ... SET used_at = now WHERE code_hash = ? AND used_at IS
NULL AND expires_at > now` makes the code single-use, even across
gunicorn workers.
3. `client_id` and `redirect_uri` must match the code exactly.
4. `BASE64URL(SHA256(code_verifier))` must equal the stored challenge
(constant-time comparison).
### Architecture Philosophy
```
"Do one thing well"
│
├── StarPunk: Publish notes
├── IndieAuth.com: Authenticate users
└── Tokens.indieauth.com: Manage tokens
The token endpoint accepts only `grant_type=authorization_code`. It refuses
a code issued with no scope (`invalid_grant`), because such codes are for
the profile-only flow at the authorization endpoint. The response is
`{access_token, token_type: "Bearer", scope, me, expires_in}`. There are no
refresh tokens: a client re-authorizes when its token expires.
Expired codes are deleted whenever a new code is issued.
### Verification and revocation
- `verify_access_token(token)` hashes the token and accepts it if it is
neither revoked nor expired, then updates `last_used_at`. It returns
`{me: ADMIN_ME, client_id, scope}`.
- `check_scope(required, scope)` matches whole words in the space-separated
scope string.
- Revocation sets `revoked_at`. It can happen by token value, through
`POST /auth/revoke` or the legacy `POST /auth/token` with `action=revoke`
(unknown tokens are ignored, per RFC 7009). It can also happen by id, from
the admin page.
- `/admin/tokens` ("Connected Apps") lists active tokens with their client,
scope, dates and last use. Each has a Revoke button.
### Scopes
| Scope | Allows |
|---|---|
| `create` | Micropub create (published or draft), media upload, `q=source`, `q=category` |
| `draft` | Micropub create, always saved as a draft (v2.9.0); `q=source`, `q=category` |
| `update` | Micropub update; `q=source`, `q=category` |
| `delete` | Micropub delete and undelete; `q=source`, `q=category` |
| `media` | Media endpoint uploads |
| `profile` | Nothing beyond identity (there is no profile or userinfo endpoint) |
`q=config` and `q=syndicate-to` work with any valid token.
## 3. Token use at the Micropub and media endpoints
`routes/micropub.py` handles `GET/POST /micropub` and
`POST /micropub/media`. The old `POST /media` path is kept for existing
clients.
### Extracting the token (`micropub.extract_bearer_token`)
- The token comes from `Authorization: Bearer <token>`, with the scheme
matched case-insensitively (RFC 7235).
- Or it comes from `access_token` in the form body (POST) or the query
string (GET).
- A token in both places gets **400 `invalid_request`** (RFC 6750 §2,
v2.9.0).
- No token gets **401 `unauthorized`**, "No access token provided".
- An unknown, expired or revoked token gets **401 `unauthorized`**,
"Invalid or expired access token".
Every 401 carries `WWW-Authenticate: Bearer realm="micropub"`. When a token
was sent but isn't valid, `error="invalid_token"` is added (RFC 6750 §3,
v2.9.0).
### Scope rules
| Operation | Required scope | Notes |
|---|---|---|
| create | `create` or `draft` | With only `draft`, the post is saved unpublished whatever `post-status` says |
| update | `update` | |
| delete / undelete | `delete` | |
| `q=source`, `q=category` | any of `create`, `update`, `delete`, `draft` | These show drafts and tags (v2.9.0) |
| `q=config`, `q=syndicate-to` | any valid token | |
| media upload | `media` or `create` | `create` is accepted for older clients |
A missing scope gets **403 `insufficient_scope`** (RFC 6750). The Micropub
Recommendation's error table lists 401 for this case. StarPunk keeps 403 on
purpose (see the [v2.9.0 review](../design/v2.9.0/2026-11-03-micropub-review.md),
"Kept as is").
Micropub request handling itself is described in
[indieweb-protocols.md](indieweb-protocols.md#micropub).
## 4. Discovery
`templates/base.html` puts these links on every page, whether or not
`WEBMENTION_ENABLED` is set (v2.8.0):
```html
<link rel="micropub" href="<SITE_URL>/micropub">
<link rel="indieauth-metadata" href="<SITE_URL>/.well-known/oauth-authorization-server">
<link rel="authorization_endpoint" href="<SITE_URL>/auth/authorize">
<link rel="token_endpoint" href="<SITE_URL>/auth/token">
<link rel="me" href="<author home>">
<link rel="author" href="<author home>">
```
## Future Considerations
Micropub clients start from the URL the user types, which is normally
`ADMIN_ME`. If `ADMIN_ME` is the StarPunk site itself, the links above are
enough. If it is another page, that page must advertise StarPunk's
`indieauth-metadata` (or `authorization_endpoint` and `token_endpoint`) and
`micropub` links. Otherwise clients won't find StarPunk
([ADR-064](../decisions/ADR-064-oidc-admin-login-and-builtin-indieauth-server.md) §3).
### Potential V2 Enhancements (NOT for V1)
1. **Multi-user support**
- Would require user management
- Still use external auth
## 5. Data (migration 011)
2. **Multiple token endpoints**
- Support different providers per user
- Endpoint discovery from user domain
| Table | Purpose | Key columns |
|---|---|---|
| `sessions` | Admin browser sessions | `session_token_hash`, `me`, `expires_at`, `last_used_at`, `user_agent`, `ip_address` |
| `oidc_login_state` | One pending OIDC login | `state` (PK), `nonce`, `code_verifier`, `next_url`, `expires_at` |
| `indieauth_codes` | Authorization codes | `code_hash`, `client_id`, `redirect_uri`, `scope`, `code_challenge`, `expires_at`, `used_at` |
| `indieauth_tokens` | Access tokens | `token_hash`, `client_id`, `scope`, `expires_at`, `last_used_at`, `revoked_at` |
3. **Token caching layer**
- Redis for distributed caching
- Longer TTL with refresh
The legacy v1 tables `auth_state`, `tokens` and `authorization_codes` are
not used (see the migration's header comment).
### Explicitly NOT Implementing
1. **Custom authorization server**
- Violates simplicity principle
- Maintenance burden
## 6. Security properties and known gaps
2. **Password authentication**
- Not IndieWeb compliant
- Security burden
In place:
3. **JWT validation**
- Not part of IndieAuth spec
- Unnecessary complexity
- No secrets at rest: session tokens, codes and access tokens are stored only
as SHA-256 hashes.
- OIDC: PKCE S256, a nonce, single-use expiring state, issuer checks (in the
metadata and the RFC 9207 `iss`), full ID-token validation, and a single
allowed `sub`.
- IndieAuth: PKCE S256 required, single-use 10-minute codes bound to the
client and redirect URI, `iss` in every authorization response, and
untrusted redirect URIs never followed.
- Post-login redirects are limited to this site.
## Testing Strategy
Known gaps:
### Unit Tests
```python
# Test external verification
@patch('httpx.get')
def test_token_verification(mock_get):
# Mock successful response
mock_get.return_value.status_code = 200
mock_get.return_value.json.return_value = {
'me': 'https://example.com',
'scope': 'create'
}
result = verify_token('test-token')
assert result is not None
```
### Integration Tests
```python
# Test with real endpoint (in CI)
def test_real_token_verification():
# Use test token from tokens.indieauth.com
token = get_test_token()
result = verify_token(token)
assert result['me'] == TEST_USER
```
### Manual Testing
1. Configure domain with IndieAuth links
2. Use Quill or Indigenous
3. Create test post
4. Verify token caching
## Metrics for Success
### Quantitative Metrics
- **Code removed**: >500 lines
- **Database tables removed**: 2
- **Complexity reduction**: ~40%
- **Test coverage maintained**: >90%
- **Performance**: <500ms token verification
### Qualitative Metrics
- **Clarity**: Clear separation of concerns
- **Maintainability**: No auth code to maintain
- **Security**: Specialized providers
- **Flexibility**: User choice of providers
- **Simplicity**: Focus on core functionality
---
**Document Version**: 1.0
**Created**: 2025-11-24
**Author**: StarPunk Architecture Team
**Purpose**: Document simplified authentication architecture after IndieAuth server removal
- Admin forms and the consent form have no CSRF token. They rely on the
`SameSite=Lax` session cookie, which cross-site POSTs don't carry.
- The client metadata fetch checks the `client_id` URL against private
addresses, but then makes a plain `httpx.get` that follows redirects.
Redirect hops are not re-checked and the connection is not pinned, unlike
`webmention_ssrf.safe_get`.
- `scopes_supported` leaves out `draft`, although Micropub honours it and
the consent screen grants it when requested. Unknown scopes are also shown
and granted as requested; they just have no effect.
- No token introspection endpoint and no refresh tokens.