зеркало из https://github.com/golang/build.git
go.tools/dashboard/app: only accept commits when given master key
R=dvyukov, rsc CC=golang-dev https://golang.org/cl/37790044
This commit is contained in:
Родитель
15e4abe30d
Коммит
0a2063b286
|
@ -17,6 +17,7 @@ import (
|
|||
|
||||
"appengine"
|
||||
"appengine/datastore"
|
||||
|
||||
"cache"
|
||||
)
|
||||
|
||||
|
@ -47,6 +48,9 @@ func commitHandler(r *http.Request) (interface{}, error) {
|
|||
if r.Method != "POST" {
|
||||
return nil, errBadMethod(r.Method)
|
||||
}
|
||||
if !isMasterKey(c, r.FormValue("key")) {
|
||||
return nil, errors.New("can only POST commits with master key")
|
||||
}
|
||||
|
||||
// POST request
|
||||
defer r.Body.Close()
|
||||
|
@ -433,13 +437,11 @@ func validHash(hash string) bool {
|
|||
}
|
||||
|
||||
func validKey(c appengine.Context, key, builder string) bool {
|
||||
if appengine.IsDevAppServer() {
|
||||
return true
|
||||
}
|
||||
if key == secretKey(c) {
|
||||
return true
|
||||
}
|
||||
return key == builderKey(c, builder)
|
||||
return isMasterKey(c, key) || key == builderKey(c, builder)
|
||||
}
|
||||
|
||||
func isMasterKey(c appengine.Context, key string) bool {
|
||||
return appengine.IsDevAppServer() || key == secretKey(c)
|
||||
}
|
||||
|
||||
func builderKey(c appengine.Context, builder string) string {
|
||||
|
|
Загрузка…
Ссылка в новой задаче