utrack / gin-csrf Goto Github PK
View Code? Open in Web Editor NEWThis project forked from tommy351/gin-csrf
CSRF protection middleware for Gin.
License: MIT License
This project forked from tommy351/gin-csrf
CSRF protection middleware for Gin.
License: MIT License
I can submit the form data over and over again, Do you guys really sure it's correct for csrf protection.
Since this is a valid option, this should be implemented, so that one can decide in which session the csrf Token is stored.
The original repo has LICENSE, but here does not. Is this repo also MIT?
I have a scenario that needs to receive a third-party post.
Thanks!
When using utrack/gin-csrf in module-aware project:
$ go get -u github.com/utrack/gin-csrf
go: finding github.com/utrack/gin-csrf latest
go: github.com/utrack/[email protected]: parsing go.mod: unexpected module path "github.com/apsdsm/gin-csrf"
go get: error loading module requirements
this example code already has an error:
NewCookieStore undefined
please write more examples I can't understand how to use this package...
i never get "CSRF token is valid"...
I always get this error: "CSRF token mismatch"
`
package main
import (
"github.com/gin-gonic/gin"
"github.com/gin-contrib/sessions"
"github.com/utrack/gin-csrf"
)
func main(){
r := gin.Default()
store := sessions.NewCookieStore([]byte("secret"))
r.Use(sessions.Sessions("mysession", store))
r.Use(csrf.Middleware(csrf.Options{
Secret: "secret123",
ErrorFunc: func(c *gin.Context){
c.String(400, "CSRF token mismatch")
c.Abort()
},
}))
r.GET("/protected", func(c *gin.Context){
c.String(200, csrf.GetToken(c))
})
r.POST("/protected", func(c *gin.Context){
c.String(200, "CSRF token is valid")
})
}
`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.