feat!: OIDC admin login and built-in IndieAuth server (v2.0.0)
Admin login now uses OpenID Connect (PKCE, nonce, ID token verified against the provider JWKS) and only OIDC_ADMIN_SUB may log in. Micropub tokens are issued and verified by StarPunk itself, with a consent screen behind the OIDC session and a Connected Apps page to revoke them, so an external IndieAuth server (Gondulf) is no longer needed. Existing notes, media, tags, webmentions, author profile and sessions are unchanged. Migration 011 adds new tables only. BREAKING CHANGE: production requires OIDC_ISSUER, OIDC_CLIENT_ID, OIDC_CLIENT_SECRET and OIDC_ADMIN_SUB. The ADMIN_ME page must point Micropub apps at StarPunk's IndieAuth endpoints. See ADR-064. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d3fa5b7a2a
commit
b84cf23e1a
29 files changed
+1824
-2354
No files matched your search
@@ -0,0 +1,43 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Authorize App - StarPunk{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="login-container authorize">
|
||||
{% if request_error %}
|
||||
<h2>Cannot authorize this app</h2>
|
||||
<p>{{ request_error }}</p>
|
||||
<p><a href="/">Return to homepage</a></p>
|
||||
{% else %}
|
||||
<h2>Authorize app</h2>
|
||||
<p>
|
||||
<strong>{{ auth_request.client_id }}</strong> wants to sign in as
|
||||
<strong>{{ me }}</strong>.
|
||||
</p>
|
||||
<p><small>After approval you will be sent to {{ auth_request.redirect_uri }}</small></p>
|
||||
|
||||
<form action="{{ url_for('indieauth.approve') }}" method="POST" class="login-form">
|
||||
{% for name, value in fields.items() %}
|
||||
<input type="hidden" name="{{ name }}" value="{{ value }}">
|
||||
{% endfor %}
|
||||
|
||||
{% if auth_request.scopes %}
|
||||
<fieldset>
|
||||
<legend>Permissions requested</legend>
|
||||
{% for scope in auth_request.scopes %}
|
||||
<label>
|
||||
<input type="checkbox" name="scope_granted" value="{{ scope }}" checked>
|
||||
{{ scope }}
|
||||
</label><br>
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
{% else %}
|
||||
<p>This app only wants to confirm your identity. It cannot post.</p>
|
||||
{% endif %}
|
||||
|
||||
<button type="submit" name="decision" value="approve" class="button button-primary">Approve</button>
|
||||
<button type="submit" name="decision" value="deny" class="button button-secondary">Deny</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -6,6 +6,7 @@
|
||||
<a href="{{ url_for('admin.dashboard') }}">Dashboard</a>
|
||||
<a href="{{ url_for('admin.new_note_form') }}">New Note</a>
|
||||
<a href="{{ url_for('admin.metrics_dashboard') }}">Metrics</a>
|
||||
<a href="{{ url_for('admin.tokens') }}">Connected Apps</a>
|
||||
<form action="{{ url_for('auth.logout') }}" method="POST" class="logout-form">
|
||||
<button type="submit" class="button button-secondary">Logout</button>
|
||||
</form>
|
||||
|
||||
@@ -5,23 +5,10 @@
|
||||
{% block content %}
|
||||
<div class="login-container">
|
||||
<h2>Admin Login</h2>
|
||||
<p>Sign in with your personal website using IndieLogin</p>
|
||||
<p>Sign in with {{ config.OIDC_PROVIDER_NAME }} to manage this site.</p>
|
||||
|
||||
<form action="{{ url_for('auth.login_initiate') }}" method="POST" class="login-form">
|
||||
<div class="form-group">
|
||||
<label for="me">Your Website URL</label>
|
||||
<input
|
||||
type="url"
|
||||
id="me"
|
||||
name="me"
|
||||
placeholder="https://example.com"
|
||||
required
|
||||
autofocus
|
||||
>
|
||||
<small>Enter your website URL (must match admin configuration)</small>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="button button-primary">Sign in with IndieLogin</button>
|
||||
<button type="submit" class="button button-primary">Sign in with {{ config.OIDC_PROVIDER_NAME }}</button>
|
||||
</form>
|
||||
|
||||
{% if config.DEV_MODE %}
|
||||
@@ -33,16 +20,5 @@
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="login-help">
|
||||
<h3>What is IndieLogin?</h3>
|
||||
<p>
|
||||
IndieLogin allows you to sign in using your own website.
|
||||
No password required - just authenticate with your domain.
|
||||
</p>
|
||||
<a href="https://indielogin.com/api" target="_blank" rel="noopener">
|
||||
Learn more about IndieLogin
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,44 @@
|
||||
{% extends "admin/base.html" %}
|
||||
|
||||
{% block title %}Connected Apps - StarPunk Admin{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
<div class="tokens-admin">
|
||||
<h2>Connected Apps</h2>
|
||||
<p>Micropub apps you have approved. Revoke any you no longer use.</p>
|
||||
|
||||
{% if tokens %}
|
||||
<table class="note-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>App</th>
|
||||
<th>Scope</th>
|
||||
<th>Approved</th>
|
||||
<th>Last used</th>
|
||||
<th>Expires</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for t in tokens %}
|
||||
<tr>
|
||||
<td>{{ t.client_id }}</td>
|
||||
<td>{{ t.scope }}</td>
|
||||
<td>{{ t.created_at }}</td>
|
||||
<td>{{ t.last_used_at or "never" }}</td>
|
||||
<td>{{ t.expires_at }}</td>
|
||||
<td>
|
||||
<form method="POST" action="{{ url_for('admin.revoke_token', token_id=t.id) }}">
|
||||
<button type="submit" class="button button-danger"
|
||||
onclick="return confirm('Revoke this app\'s access?')">Revoke</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<p>No apps connected.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -11,6 +11,10 @@
|
||||
{# Webmention endpoint (v1.6.0) #}
|
||||
{% if config.WEBMENTION_ENABLED %}
|
||||
<link rel="webmention" href="/webmention">
|
||||
<link rel="micropub" href="{{ config.SITE_URL.rstrip('/') }}{{ url_for('micropub.micropub_endpoint') }}">
|
||||
<link rel="indieauth-metadata" href="{{ config.SITE_URL.rstrip('/') }}{{ url_for('indieauth.metadata') }}">
|
||||
<link rel="authorization_endpoint" href="{{ config.SITE_URL.rstrip('/') }}{{ url_for('indieauth.authorize') }}">
|
||||
<link rel="token_endpoint" href="{{ config.SITE_URL.rstrip('/') }}{{ url_for('indieauth.token') }}">
|
||||
{% endif %}
|
||||
|
||||
{# rel-me links from discovered author profile (v1.2.0 Phase 2) #}
|
||||
|
||||
Reference in new issue
Block a user