A CSRF protection middleware for Go that prevents Cross-Site Request Forgery attacks in any HTTP application.
nosurf is an HTTP middleware package for Go that prevents Cross-Site Request Forgery (CSRF) attacks. It wraps any http.Handler to automatically validate CSRF tokens on non-safe HTTP methods, addressing a common security vulnerability in Go's micro-framework ecosystem.
Go developers building web applications or services with any HTTP handler or framework that lacks built-in CSRF protection, particularly those using lightweight or custom setups.
Developers choose nosurf for its minimal, dependency-free design that integrates seamlessly with any Go HTTP application, offering flexible exemption rules, BREACH attack mitigation, and manual token verification for non-standard use cases.
CSRF protection middleware for Go.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Works with any http.Handler, including custom handlers and frameworks like Gorilla Mux, ensuring compatibility with virtually any Go HTTP application.
Allows exempting endpoints from CSRF checks using exact URLs, globs, or regular expressions, as shown in the README for APIs or webhooks.
Uses masked tokens to protect against BREACH attacks, providing enhanced security over basic CSRF implementations.
Relies solely on the Go standard library, keeping the package lightweight and easy to integrate without external dependencies.
For JSON APIs or non-standard token transmission, developers must manually exempt endpoints and verify tokens, increasing code complexity and potential for errors.
Focuses on basic CSRF protection without built-in support for token rotation, session management, or integration with other security middleware.
CSRF tokens must be manually passed to HTML templates, as demonstrated in the example, lacking automatic injection for streamlined development.