diff options
| author | Dennis Fink | 2026-11-17 14:44:00 +0100 |
|---|---|---|
| committer | Dennis Fink | 2026-11-17 14:44:00 +0100 |
| commit | 227092b57acc886469e16bcc4c0d3256e86d3d1e (patch) | |
| tree | c1de8d5f8f3a37562e482f84e8017213c08a05d6 /webmentions_ssg/templates | |
| parent | f98b0e446b41325c494bd97900b7bbf730a7d67e (diff) | |
| download | webmentions-ssg-227092b57acc886469e16bcc4c0d3256e86d3d1e.tar.gz webmentions-ssg-227092b57acc886469e16bcc4c0d3256e86d3d1e.zip | |
feat(receiver): add source domain access rules
Add persistent source block and allow lists with authenticated
management, single-row and bulk blocking actions, and optional
fail-closed allowlist mode.
Reject disallowed sources before enqueueing and recheck policy in
verification workers, while sharing canonical hostname normalization
across receiver, sender, and configuration paths.
Diffstat (limited to 'webmentions_ssg/templates')
| -rw-r--r-- | webmentions_ssg/templates/base.html | 2 | ||||
| -rw-r--r-- | webmentions_ssg/templates/received.html | 20 | ||||
| -rw-r--r-- | webmentions_ssg/templates/source_domains.html | 68 |
3 files changed, 90 insertions, 0 deletions
diff --git a/webmentions_ssg/templates/base.html b/webmentions_ssg/templates/base.html index 69e5215..d9c8e87 100644 --- a/webmentions_ssg/templates/base.html +++ b/webmentions_ssg/templates/base.html @@ -45,6 +45,8 @@ SPDX-License-Identifier: BSD-3-Clause <div class="navbar-nav flex-row gap-3"> <a class="nav-link{% if request.endpoint == 'webmentions.received_list' %} active{% endif %}" href='{{ url_for("webmentions.received_list") }}'>Received</a> + <a class="nav-link{% if request.endpoint and request.endpoint.startswith('webmentions.source_domain') %} active{% endif %}" + href="{{ url_for('webmentions.source_domain_list') }}">Source rules</a> <a class="nav-link{% if request.endpoint == 'webmentions.source_list' %} active{% endif %}" href='{{ url_for("webmentions.source_list") }}'>Sent</a> <form action="{{ url_for('webmentions.logout') }}" diff --git a/webmentions_ssg/templates/received.html b/webmentions_ssg/templates/received.html index de3a9b6..5fd9866 100644 --- a/webmentions_ssg/templates/received.html +++ b/webmentions_ssg/templates/received.html @@ -127,6 +127,17 @@ SPDX-License-Identifier: BSD-3-Clause data-confirm-label="Reverify selected" data-confirm-class="btn-primary">Reverify selected</button> <button type="button" + class="btn btn-sm btn-outline-warning" + disabled + data-bs-toggle="modal" + data-bs-target="#confirmation-modal" + data-received-bulk-action="block-sources" + data-action="{{ url_for('webmentions.block_selected_received_sources', page=webmentions.page, **filters) }}" + data-title="Block selected source domains?" + data-message="Selected source domains and their subdomains will be blocked from future Webmentions. Existing Webmentions will be kept." + data-confirm-label="Block selected domains" + data-confirm-class="btn-warning">Block selected source domains</button> + <button type="button" class="btn btn-sm btn-outline-danger" disabled data-bs-toggle="modal" @@ -206,6 +217,15 @@ SPDX-License-Identifier: BSD-3-Clause data-confirm-label="Reverify" data-confirm-class="btn-primary">Reverify</button> <button type="button" + class="btn btn-sm btn-warning" + data-bs-toggle="modal" + data-bs-target="#confirmation-modal" + data-action="{{ url_for('webmentions.block_received_source', webmention_uuid=webmention.uuid, page=webmentions.page, **filters) }}" + data-title="Block this source domain?" + data-message="Future Webmentions from this source hostname and its subdomains will be rejected." + data-confirm-label="Block domain" + data-confirm-class="btn-warning">Block this domain</button> + <button type="button" class="btn btn-sm btn-danger" data-bs-toggle="modal" data-bs-target="#confirmation-modal" diff --git a/webmentions_ssg/templates/source_domains.html b/webmentions_ssg/templates/source_domains.html new file mode 100644 index 0000000..2db942f --- /dev/null +++ b/webmentions_ssg/templates/source_domains.html @@ -0,0 +1,68 @@ +<!-- +SPDX-FileCopyrightText: 2026 Dennis Fink <me+coding@dennisfink.me> + +SPDX-License-Identifier: BSD-3-Clause +--> +{% extends "base.html" %} + +{% block content %} + <h1 class="mb-3">Source domain rules</h1> + <p> + Entries match the named hostname and all of its subdomains (not similarly named domains). + Blocked domains always take precedence over allowed domains. Changes affect new + submissions and future verification attempts; existing mentions are not deleted. + </p> + <p> + Allowlist mode is <strong>{{ "enabled" if allowlist_enabled else "disabled" }}</strong>. + Set <code>SOURCE_ALLOWLIST_ENABLED = True</code> in the server configuration to + accept only listed source domains. An empty enabled allowlist rejects all sources. + </p> + {% for kind, entries in (("blocked", blocked), ("allowed", allowed)) %} + <section class="mb-4" aria-labelledby="{{ kind }}-heading"> + <h2 id="{{ kind }}-heading">{{ "Blocked" if kind == "blocked" else "Allowed" }} domains</h2> + <form action="{{ url_for('webmentions.source_domain_add', kind=kind) }}" + method="post" + class="row g-2 align-items-end mb-3"> + <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"> + <div class="col-sm-8 col-md-5"> + <label class="form-label" for="{{ kind }}-domain">Source domain</label> + <input class="form-control" + type="text" + id="{{ kind }}-domain" + name="domain" + placeholder="example.org" + required> + </div> + <div class="col-auto"> + <button type="submit" class="btn btn-primary">Add domain</button> + </div> + </form> + {% if entries %} + <table class="table table-striped align-middle"> + <thead> + <tr> + <th scope="col">Domain</th> + <th scope="col">Action</th> + </tr> + </thead> + <tbody> + {% for entry in entries %} + <tr> + <td class="text-break">{{ entry.domain }}</td> + <td> + <form action="{{ url_for('webmentions.source_domain_delete', kind=kind, entry_id=entry.id) }}" + method="post"> + <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"> + <button type="submit" class="btn btn-sm btn-outline-danger">{{ "Unblock" if kind == "blocked" else "Remove" }}</button> + </form> + </td> + </tr> + {% endfor %} + </tbody> + </table> + {% else %} + <p class="text-body-secondary">No {{ kind }} domains.</p> + {% endif %} + </section> + {% endfor %} +{% endblock %} |
