Created
July 14, 2016 20:56
-
-
Save sprt/6ccf25182025bb7c4066369dddd4b491 to your computer and use it in GitHub Desktop.
gorilla/csrf App Engine bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package app | |
import ( | |
"fmt" | |
"net/http" | |
"github.com/gorilla/csrf" | |
) | |
func init() { | |
r := http.NewServeMux() | |
r.HandleFunc("/", handler) | |
http.Handle("/", csrf.Protect([]byte("test"), csrf.Secure(false))(r)) | |
} | |
func handler(w http.ResponseWriter, r *http.Request) { | |
w.Header().Set("Content-Type", "text/html") | |
w.Header().Set("X-CSRF-Token", csrf.Token(r)) | |
fmt.Fprint(w, `<form method="post"><input name="foo"><button type="submit">Submit</button></form>`) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
runtime: go | |
api_version: go1 | |
handlers: | |
- url: /*. | |
script: _go_app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment