Skip to main content

splent_feature_cloudflare

The cloudflare feature of a SPLENT product line.

A SPLENT feature is a Python package that a product composes with others. Its models, routes, services, templates and hooks are registered when the product starts. What this feature provides and requires is listed in the [tool.splent.contract] section of pyproject.toml, which splent feature:contract --write keeps in sync with the source.

What it does

Cloudflare Turnstile as the product's captcha. It registers the generic CaptchaService, gives templates captcha_script() and captcha_widget(), and vetoes the comment, contact and careers submissions whose token does not verify. The keys come from the settings stored by the panel first and from TURNSTILE_SITE_KEY and TURNSTILE_SECRET_KEY second. Their defaults are Cloudflare's test keys, which always pass, so development works out of the box.

The panel edits the keys at /admin/captcha.

Access

/admin/captcha opens only for the accounts whose role is admin. The keys are site secrets and switch the captcha of every form, so staff are refused too. Any other signed-in account gets 403 and does not see the Captcha link in the sidebar, and an anonymous visitor is sent to log in. The feature has no public screen of its own. Its check runs, through their signals, inside the forms other features open to everyone, signed in or not.

There is no setting for this role, and a refinement cannot replace the view that checks it, because it may add routes to this feature but never replace one of its own. Another feature can decide for this screen with an access policy registered for the prefix cloudflare.admin (register_access_policy, splent_framework 1.20.0). The framework asks the policy before the role. It answers True to let an account in, False to refuse it, or None to leave the decision to the role, and the sidebar link follows the same answer. That is the way to let a group of accounts manage only this section, for example the people who run the site's integrations, without giving them the admin role. See Access control.

Without such a feature, give the person's account the admin role. The staff role does not open this screen. Staff opens every panel screen that asks for PANEL_ROLES, and this one asks for ADMIN_ROLES.

splent feature:auth set-role someone@example.com admin

The stored secret key is never sent back to the browser. The settings screen says whether one is stored and leaves its field empty. Saving with the field empty keeps the stored secret, typing a new one replaces it, and the remove box clears it, so the product's TURNSTILE_SECRET_KEY is used again.

Two secrets leave the forms open, even when a real site key is stored. One is an empty secret, with which the check lets every submission through, and the other is Cloudflare's always-pass test key, the default of TURNSTILE_SECRET_KEY. CloudflareService.leaves_forms_open(secret) is true for both. While the secret in effect is one of them, the settings screen warns that the captcha does not protect the forms, with a message for each case. When a real secret is stored and the product's is empty or the test key, the remove box says that removing it leaves the forms unprotected, again naming the case. A live site stores its real secret here or sets it in its configuration.

Use it in a product

splent feature:add splent_feature_cloudflare

Develop

splent feature:test splent_feature_cloudflare
splent feature:contract splent_feature_cloudflare

Release

splent feature:release splent_feature_cloudflare --dry-run --bump patch
splent feature:release splent_feature_cloudflare

The first command rehearses the release and changes nothing. The second publishes it to the git forge and to PyPI, and a PyPI version is permanent.

Metadata

Release files for splent-feature-cloudflare 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for splent-feature-cloudflare 0.2.0
File Size Uploaded Provenance
splent_feature_cloudflare-0.2.0.tar.gz 25.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for splent-feature-cloudflare 0.2.0
File Interpreter ABI Platform
splent_feature_cloudflare-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 55.7 kB

Release files / splent_feature_cloudflare-0.2.0.tar.gz

Download URL splent_feature_cloudflare-0.2.0.tar.gz
Size 25.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d0c64a7e77be915826ffa4cab549da9630f27ca8b36369f043c0baec77cab21a
BLAKE2b-256 checksum
How to use checksums
08a1753b4e2f3ee08c05cc9cf0e7904c661f7161c377f6c35d6f310634ceefdd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Release files / splent_feature_cloudflare-0.2.0-py3-none-any.whl

Download URL splent_feature_cloudflare-0.2.0-py3-none-any.whl
Size 29.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ad2470f1a558b825a5930d513dfe3ebe32b4db7cddc29320508c96ae6dd84a2a
BLAKE2b-256 checksum
How to use checksums
4155417d4460739d055f719b5d4c3708c0f8d8d2a9646d9c11fe4faad3b0ec15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Security for splent-feature-cloudflare 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page