What's new in Larz 1.1 — 2FA, social login, uploads & marketplace payouts
Six batteries-included additions — 2FA, social login, uploads, marketplace payouts, more providers, and a test client — all still on the standard library.
Larz 1.1 is on PyPI. Every addition keeps the promise: zero runtime
dependencies, everything on the Python standard library. pip install -U larz
and you have it.
pip install --upgrade larz # 1.1.0
Two-factor authentication
Real TOTP (RFC 6238) that works with Google Authenticator, Authy and 1Password —
no library, just hmac and base64:
import larz.auth as auth, larz.twofa as twofa
auth.enable(app); twofa.enable(app, issuer="MyApp")
uri, secret = app.twofa.begin(req.user) # render `uri` as a QR
codes = app.twofa.activate(req.user, code) # one-time backup codes
@app.twofa_required
@app.get("/billing")
def billing(req): ...
Social login
Google, GitHub, or any OAuth2 provider — the whole flow runs over urllib:
import larz.oauth as oauth
oauth.enable(app, providers={
"google": {"client_id": "...", "client_secret": "..."},
"github": {"client_id": "...", "client_secret": "..."},
})
# links appear at /larz/oauth/google/login — finds-or-creates a User by email
File uploads & storage
from larz.storage import LocalStorage
store = LocalStorage("uploads", url_prefix="/files").mount(app)
@app.post("/upload")
def upload(req):
f = req.files.get("avatar")
return {"url": store.url(store.save(f))}
Marketplace payouts
The money-native thesis, extended to two-sided marketplaces: record what every seller is owed with one call.
app.money.split([("seller:42", "$8.50"), ("platform", "$1.50")], sku=order.id)
app.money.owed("seller:42") # 850 (cents pending)
app.money.mark_paid(payout_id)
Four more payment providers
Square, Razorpay, Mollie and Coinbase Commerce join the roster — 14 providers now, all behind the same two-method adapter contract. Swap any of them in with one line.
A first-class test client
from larz.testing import Client
c = Client(app)
assert c.get("/").status == 200
c.post("/signup", form={"email": "a@b.com", "password": "pw123456"})
assert c.get("/app").json["projects"] == [] # cookies persist across calls
Plus flash messages, req.htmx and Response.hx_trigger() for
HTMX apps, and a runnable
marketplace
example. Full details in the changelog.
Read the docs PyPI Marketplace course
FAQ
Is Larz 1.1 still zero-dependency?
Yes. TOTP, OAuth, multipart uploads and every new provider are built on the Python standard library — the only thing you install is Larz.
How do I upgrade?
Run pip install --upgrade larz. 1.1 is backward-compatible with 1.0; the new modules (twofa, oauth, storage, testing) are opt-in.
Does the 2FA work with Google Authenticator?
Yes — it implements standard TOTP (RFC 6238), so any authenticator app (Google Authenticator, Authy, 1Password, Microsoft Authenticator) works, plus one-time backup codes.
release1.1