What changed, and why it matters
This commit is mostly cosmetic reformatting and updating import statements to match newer FastAPI versions. The only functional code changes are adding explicit 'string' type annotations to several web endpoint parameters and removing a default 'None' value from two invoice-related endpoints so they now require a paywall ID. These changes are minor hardening: they make the API reject missing or wrong-typed inputs more cleanly, but they do not appear to fix an active vulnerability.
No urgent action. Treat as routine maintenance. If auditing, verify that downstream callers always supply paywall_id and that the database layer handles non-existent IDs safely, because the invoice endpoint still uses a bare assert paywall rather than a proper 404 check.
Security signals we found
route parameters now explicitly typed as str
paywall_id made required instead of optional (Query(None) removed) on invoice creation and invoice check endpoints
import migration from starlette to fastapi modules
Evidence from the diff
The diff updates JSON formatting, GitHub release tag pattern, and switches starlette. imports to fastapi. equivalents. In views.py and views_api.py, route parameters paywall_id gain str type hints, and in api_paywall_create_invoice / api_paywal_check_invoice the paywall_id parameter changes from str = Query(None) to a required str. Removing Query(None) makes the paywall_id mandatory for those POST endpoints, which prevents a caller from omitting it. The type hints reduce ambiguity but are not a security boundary by themselves. No explicit security bug is patched.
Changed components
views_api.py invoice and check_invoice POST endpointsviews.py display endpointFastAPI route parameter handlingInspect captured patch +21 / −22
### .github/workflows/release.yml
@@ -2,7 +2,7 @@ name: release github version
on:
push:
tags:
- - "[0-9]+.[0-9]+"
+ - "[0-9]+.[0-9]+.[0-9]+"
jobs:
build:
runs-on: ubuntu-latest
### __init__.py
@@ -1,5 +1,5 @@
from fastapi import APIRouter
-from starlette.staticfiles import StaticFiles
+from fastapi.staticfiles import StaticFiles
from lnbits.db import Database
from lnbits.helpers import template_renderer
### config.json
@@ -1,6 +1,6 @@
{
- "name": "Paywall",
- "short_description": "Create paywalls for content",
- "tile": "/paywall/static/image/paywall.png",
- "contributors": ["eillarra"]
+ "name": "Paywall",
+ "short_description": "Create paywalls for content",
+ "tile": "/paywall/static/image/paywall.png",
+ "contributors": ["eillarra"]
}
### manifest.json
@@ -1,9 +1,9 @@
{
- "repos": [
- {
- "id": "paywall",
- "organisation": "lnbits",
- "repository": "paywall"
- }
- ]
+ "repos": [
+ {
+ "id": "paywall",
+ "organisation": "lnbits",
+ "repository": "paywall"
+ }
+ ]
}
### templates/paywall/_api_docs.html
@@ -69,8 +69,7 @@ <h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
<code
><span class="text-green">POST</span>
/paywall/api/v1/paywalls/invoice/{paywall_id}
- </code
- >
+ </code>
<h5 class="text-caption q-mt-sm q-mb-none">Body (application/json)</h5>
<code>{"amount": <integer>}</code>
<h5 class="text-caption q-mt-sm q-mb-none">
### views.py
@@ -1,8 +1,8 @@
from http import HTTPStatus
from fastapi import Depends
-from starlette.exceptions import HTTPException
-from starlette.requests import Request
+from fastapi.exceptions import HTTPException
+from fastapi.requests import Request
from lnbits.core.models import User
from lnbits.decorators import check_user_exists
@@ -19,7 +19,7 @@ async def index(request: Request, user: User = Depends(check_user_exists)):
@paywall_ext.get("/{paywall_id}")
-async def display(request: Request, paywall_id):
+async def display(request: Request, paywall_id: str):
paywall = await get_paywall(paywall_id)
if not paywall:
raise HTTPException(
### views_api.py
@@ -1,7 +1,7 @@
from http import HTTPStatus
from fastapi import Depends, Query
-from starlette.exceptions import HTTPException
+from fastapi.exceptions import HTTPException
from lnbits.core.crud import get_user, get_wallet
from lnbits.core.services import check_transaction_status, create_invoice
@@ -35,7 +35,7 @@ async def api_paywall_create(
@paywall_ext.delete("/api/v1/paywalls/{paywall_id}")
async def api_paywall_delete(
- paywall_id, wallet: WalletTypeInfo = Depends(get_key_type)
+ paywall_id: str, wallet: WalletTypeInfo = Depends(get_key_type)
):
paywall = await get_paywall(paywall_id)
@@ -55,7 +55,7 @@ async def api_paywall_delete(
@paywall_ext.post("/api/v1/paywalls/invoice/{paywall_id}")
async def api_paywall_create_invoice(
- data: CreatePaywallInvoice, paywall_id: str = Query(None)
+ data: CreatePaywallInvoice, paywall_id: str
):
paywall = await get_paywall(paywall_id)
assert paywall
@@ -80,7 +80,7 @@ async def api_paywall_create_invoice(
@paywall_ext.post("/api/v1/paywalls/check_invoice/{paywall_id}")
async def api_paywal_check_invoice(
- data: CheckPaywallInvoice, paywall_id: str = Query(None)
+ data: CheckPaywallInvoice, paywall_id: str
):
paywall = await get_paywall(paywall_id)
payment_hash = data.payment_hashWhy this scored 22/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.