Repository navigation
Releases
Releases · erwagasore/httpz-csrf
v1.0.0
[1.0.0] — 2026-04-30
Breaking Changes
- Require Zig 0.16.x and the Zig 0.16-compatible httpz API
- Require
Config.io: std.Ioso CSRF token generation uses Zig 0.16std.Io.randomSecure
Features
- Upgrade the middleware, example server, and documentation to Zig 0.16
- Use the configured CSRF header name for both response and request token headers
Other
- Pin httpz to a Zig 0.16-compatible commit
- Replace removed Zig 0.15 APIs with Zig 0.16 equivalents
- Avoid duplicate HMAC verification on unsafe requests
- Run optional Origin/Referer validation before cookie HMAC work on unsafe requests
- Propagate example response allocation failures with
try
v0.1.2
Fixes
- Use
req.formData()instead ofreq.query()in example POST handler — query reads URL params, not form body - Use httpz native
res.setCookie()API instead of manual header formatting — properly propagates allocation errors - Unsafe methods without a cookie now reject immediately without generating a token — no wasted arena allocation or misleading
Set-Cookieon 403 responses
Other
- Make
parseCookieValueprivate (internal use only) - Remove unused
selfparameter fromvalidateOrigin - Remove unused
encoded_sig_lenconstant - Fix API names in DESIGN.md (
timing_safe.eqlnottimingSafeEql) - Pin dependency snippet in README to release tag instead of
#main - Add tests for
safe_customconfig, origin validation integration, and noSet-Cookieon rejected requests (37 → 41 tests)
v0.1.1
Fixes
- Use
formData().get()instead ofparam()for form field token extraction —param()reads URL route parameters, not POST body fields, so every form-based CSRF submission was silently rejected
Other
- Validate
__Host-cookie prefix invariants at init (Secure=true,Path=/) - Document expected client flow (GET first, then POST) in README
- Add form field fallback and config validation tests
v0.1.0
Features
- Stateless CSRF protection middleware using Signed Double-Submit Cookie pattern with HMAC-SHA256
- Token generation with 32-byte random nonce and base64url encoding (87 chars)
- Constant-time token verification via
timing_safe.eql - Cookie management with configurable name, path, max-age, Secure, and SameSite attributes
- Origin/Referer validation (opt-in defence-in-depth)
- Configurable rejection status and body
- Safe method detection with custom method support
- Token extraction from header (
x-csrf-token) with form field (_csrf) fallback - Example server with form-based CSRF flow