| Index: server/auth/xsrf/xsrf.go
|
| diff --git a/server/auth/xsrf/xsrf.go b/server/auth/xsrf/xsrf.go
|
| index 7fa964a9668c2d975fef651c8a6eeddf880f6d8e..59203839226643f73e79141aab82fbaf97dde0f4 100644
|
| --- a/server/auth/xsrf/xsrf.go
|
| +++ b/server/auth/xsrf/xsrf.go
|
| @@ -16,14 +16,13 @@ import (
|
| "net/http"
|
| "time"
|
|
|
| - "github.com/julienschmidt/httprouter"
|
| "golang.org/x/net/context"
|
|
|
| "github.com/luci/luci-go/common/errors"
|
| "github.com/luci/luci-go/common/logging"
|
|
|
| "github.com/luci/luci-go/server/auth"
|
| - "github.com/luci/luci-go/server/middleware"
|
| + "github.com/luci/luci-go/server/router"
|
| "github.com/luci/luci-go/server/tokens"
|
| )
|
|
|
| @@ -70,20 +69,21 @@ func TokenField(c context.Context) template.HTML {
|
| // If searches for the token in "xsrf_token" POST form field (as generated by
|
| // TokenField). Aborts the request with HTTP 403 if XSRF token is missing or
|
| // invalid.
|
| -func WithTokenCheck(h middleware.Handler) middleware.Handler {
|
| - return func(c context.Context, rw http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
| - tok := r.PostFormValue("xsrf_token")
|
| +func WithTokenCheck() router.Handler {
|
| + return func(c *router.Context) {
|
| + tok := c.Request.PostFormValue("xsrf_token")
|
| if tok == "" {
|
| - replyError(c, rw, http.StatusForbidden, "XSRF token is missing")
|
| + replyError(c.Context, c.Writer, http.StatusForbidden, "XSRF token is missing")
|
| + c.Abort()
|
| return
|
| }
|
| - switch err := Check(c, tok); {
|
| + switch err := Check(c.Context, tok); {
|
| case errors.IsTransient(err):
|
| - replyError(c, rw, http.StatusInternalServerError, "Transient error when checking XSRF token - %s", err)
|
| + replyError(c.Context, c.Writer, http.StatusInternalServerError, "Transient error when checking XSRF token - %s", err)
|
| + c.Abort()
|
| case err != nil:
|
| - replyError(c, rw, http.StatusForbidden, "Bad XSRF token - %s", err)
|
| - default:
|
| - h(c, rw, r, p)
|
| + replyError(c.Context, c.Writer, http.StatusForbidden, "Bad XSRF token - %s", err)
|
| + c.Abort()
|
| }
|
| }
|
| }
|
|
|