{"repo":"gorilla/csrf","free":true,"listed":false,"github":"https://github.com/gorilla/csrf","clone":"git clone https://github.com/gorilla/csrf.git","description":"Package gorilla/csrf provides Cross Site Request Forgery (CSRF) prevention middleware for Go web applications & services 🔒","language":"Go","stars":1205,"topics":["csrf-protection","gorilla","middleware","golang","security","csrf","xsrf","csrf-tokens","go","gorilla-web-toolkit"],"license":"BSD-3-Clause","category":"security-tools","readme_excerpt":"gorilla/csrf gorilla/csrf is a HTTP middleware library that provides cross-site request forgery (CSRF) protection. It includes: - The csrf.Protect middleware/handler provides CSRF protection on routes attached to a router or a sub-router. - A csrf.Token function that provides the token to pass into your response, whether that be a HTML form or a JSON response body. - ... and a csrf.TemplateField helper that you can pass into your html/template templates to replace a {{ .csrfField }} template tag with a hidden input field. gorilla/csrf is designed to work with any Go web framework, including: - The Gorilla toolkit - Go's built-in net/http package - Goji - see the tailored fork - Gin - Echo - ... and any other router/framework that rallies around Go's http.Handler interface. gorilla/csrf is also compatible with middleware 'helper' libraries like Alice and Negroni. Contents Install Examples + HTML Forms + JavaScript Applications + Google App Engine + Setting SameSite + Setting Options Design Notes License Install With a properly configured Go toolchain: Examples - HTML Forms - JavaScript Apps - Google App Engine - Setting SameSite - Setting Options gorilla/csrf is easy to use: add the middleware to your router with the below: ...and then collect the token with csrf.Token(r) in your handlers before passing it to the template, JSON body or HTTP header (see below). Note that the authentication key passed to csrf.Protect([]byte(key)) should: - be 32-bytes long - persist across appli","default_branch":null,"files":null,"tree":[],"storefront":"/r/gorilla","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/gorilla/csrf/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}