Skip to content
C

Csrf

Package gorilla/csrf provides Cross Site Request Forgery

by gorillaFree

#1854in Developer Tools
0In stores

Description

gorilla/csrf is an HTTP middleware library for Go that protects web applications against cross-site request forgery. Token returns the token…

Highlights

  • CSRF middleware for net/http and routers
  • csrf.Token for forms, JSON and headers
  • Template field helper for html/template
  • Works with Gin, Echo and Gorilla
  • Examples for JavaScript apps and SameSite

Ratings & Reviews

No ratings yet

Be the first to rate Csrf.

People also visit

C

csrf-cross-site-request-forgery

CSRF testing playbook

AI Skills
Get
G

golang-security

Security best practices and vulnerability prevention for Golang

AI Skills
Get
W

Wafris RB

Wafris Client for Rails and Rack applications

Developer Tools
Launch
G

Go Http Metrics

Go modular http middleware to measure HTTP requests independent of metrics…

Developer Tools
Launch
G

Goshs

Feature-rich single-binary file server for red teamers and developers

Developer Tools
Launch
E

Express Openid Connect

An Express.js middleware to protect OpenID Connect web applications

Developer Tools
Launch

Csrf FAQ

What is gorilla/csrf?

A Go middleware library that protects web applications from cross-site request forgery.

Which frameworks does it work with?

Any framework built on Go's http.Handler interface, including the Gorilla toolkit, net/http, Goji, Gin and Echo.

How do I add a token to a form?

Use csrf.TemplateField in html/template to insert a hidden field, or get the value with csrf.Token(r) and send it in a JSON body or a header.

What key should I use?

A 32-byte key that persists across restarts and is kept secret. Do not hardcode it in open-source code, and a new random key will invalidate existing cookies.

Does it work with JavaScript apps?

Yes. The README has an example for JavaScript applications that send the token with their requests.

What are the best Csrf alternatives?

Popular alternatives to Csrf include Wafris RB, Go Http Metrics and Goshs. See all Csrf alternatives

Developer Stuff

Badges