diff --git a/CHANGELOG.md b/CHANGELOG.md index edc07e3..05e8ee5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.0.1] - 2026-10-31 + +### Fixed + +- Page links built from the request said `http://` behind an HTTPS reverse proxy + (RSS/OPML ``s and microformats `u-url`/`u-uid` permalinks). All absolute + URLs in templates now come from `SITE_URL` via `absolute_url_for()`. +- Container builds in Gitea Actions: build through the server's rootless BuildKit + and log in to the public registry name (the old workflow never succeeded). + ## [2.0.0] - 2026-10-31 ### Changed (breaking) diff --git a/starpunk/__init__.py b/starpunk/__init__.py index a15dbda..a240108 100644 --- a/starpunk/__init__.py +++ b/starpunk/__init__.py @@ -191,6 +191,10 @@ def create_app(config=None): register_routes(app) # Template context processor - Inject author profile (v1.2.0 Phase 2) + from starpunk.utils import absolute_url_for + + app.jinja_env.globals["absolute_url_for"] = absolute_url_for + @app.context_processor def inject_author(): """ @@ -436,5 +440,5 @@ def create_app(config=None): # Package version (Semantic Versioning 2.0.0) # See docs/standards/versioning-strategy.md for details -__version__ = "2.0.0" -__version_info__ = (2, 0, 0) +__version__ = "2.0.1" +__version_info__ = (2, 0, 1) diff --git a/starpunk/indieauth.py b/starpunk/indieauth.py index 8d6d05c..b8f10b9 100644 --- a/starpunk/indieauth.py +++ b/starpunk/indieauth.py @@ -22,6 +22,7 @@ from bs4 import BeautifulSoup from flask import current_app from starpunk.database import get_db +from starpunk.utils import absolute_url_for CODE_LIFETIME_MINUTES = 10 SUPPORTED_SCOPES = ["create", "update", "delete", "media", "profile"] @@ -55,13 +56,6 @@ def issuer() -> str: return current_app.config["SITE_URL"].rstrip("/") + "/" -def site_url_for(endpoint: str) -> str: - """Absolute URL built from SITE_URL (request host/scheme is unreliable behind a proxy)""" - from flask import url_for - - return current_app.config["SITE_URL"].rstrip("/") + url_for(endpoint) - - def admin_me() -> str: """The single identity StarPunk issues tokens for""" return current_app.config["ADMIN_ME"] diff --git a/starpunk/routes/indieauth.py b/starpunk/routes/indieauth.py index d8c12dc..efb2cc5 100644 --- a/starpunk/routes/indieauth.py +++ b/starpunk/routes/indieauth.py @@ -34,11 +34,11 @@ from starpunk.indieauth import ( issuer, redeem_authorization_code, revoke_access_token, - site_url_for, validate_authorization_request, verify_access_token, ) from starpunk.micropub import extract_bearer_token +from starpunk.utils import absolute_url_for bp = Blueprint("indieauth", __name__) @@ -89,9 +89,9 @@ def metadata(): return _json( { "issuer": issuer(), - "authorization_endpoint": site_url_for("indieauth.authorize"), - "token_endpoint": site_url_for("indieauth.token"), - "revocation_endpoint": site_url_for("indieauth.revoke"), + "authorization_endpoint": absolute_url_for("indieauth.authorize"), + "token_endpoint": absolute_url_for("indieauth.token"), + "revocation_endpoint": absolute_url_for("indieauth.revoke"), "revocation_endpoint_auth_methods_supported": ["none"], "scopes_supported": SUPPORTED_SCOPES, "response_types_supported": ["code"], diff --git a/starpunk/utils.py b/starpunk/utils.py index 674b874..738fb91 100644 --- a/starpunk/utils.py +++ b/starpunk/utils.py @@ -681,3 +681,15 @@ def parse_iso8601(date_string: str) -> datetime: # Parse using fromisoformat return datetime.fromisoformat(date_string) + + +def absolute_url_for(endpoint: str, **values) -> str: + """ + Absolute URL for an endpoint, built from SITE_URL + + Use instead of url_for(..., _external=True): behind a reverse proxy the + request arrives over plain HTTP, so _external URLs would say http://. + """ + from flask import current_app, url_for + + return current_app.config["SITE_URL"].rstrip("/") + url_for(endpoint, **values) diff --git a/templates/base.html b/templates/base.html index c9d39f8..4ec772d 100644 --- a/templates/base.html +++ b/templates/base.html @@ -5,16 +5,16 @@