Skip to content

Instantly share code, notes, and snippets.

@sprt
Created July 14, 2016 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sprt/6ccf25182025bb7c4066369dddd4b491 to your computer and use it in GitHub Desktop.
Save sprt/6ccf25182025bb7c4066369dddd4b491 to your computer and use it in GitHub Desktop.
gorilla/csrf App Engine bug
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>`)
}
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