Skip to content

Commit 57c2ca7

Browse files
authored
Fix invalid CSRF token bug, make sure CSRF tokens can be up-to-date (#19338)
There was a bug that the CSRF token wouldn't in 24h. This fix just does what the CSRF function comment says: If this request is a GET request, it will generate a new token. Then the CSRF token can be kept up-to-date.
1 parent 0704009 commit 57c2ca7

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

modules/context/csrf.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ func Csrfer(opt CsrfOptions, ctx *Context) CSRF {
229229
}
230230
}
231231

232+
needsNew = needsNew || ctx.Req.Method == "GET" // If this request is a Get request, it will generate a new token, make sure the token is always up-to-date.
232233
if needsNew {
233234
// FIXME: actionId.
234235
x.Token = GenerateToken(x.Secret, x.ID, "POST")

0 commit comments

Comments
 (0)