Skip to content

Commit

Permalink
Add CheckAccessHTTP to vtworker actions
Browse files Browse the repository at this point in the history
  • Loading branch information
aaijazi committed Jan 23, 2015
1 parent 7344215 commit 5fb5738
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions go/cmd/vtworker/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"net/http"
"strings"

"github.com/youtube/vitess/go/acl"
"github.com/youtube/vitess/go/vt/servenv"
)

Expand Down Expand Up @@ -60,6 +61,10 @@ func initStatusHandling() {
// code to serve /status
workerTemplate := mustParseTemplate("worker", workerStatusHTML)
http.HandleFunc("/status", func(w http.ResponseWriter, r *http.Request) {
if err := acl.CheckAccessHTTP(r, acl.ADMIN); err != nil {
acl.SendError(w, err)
return
}
currentWorkerMutex.Lock()
wrk := currentWorker
logger := currentMemoryLogger
Expand Down Expand Up @@ -90,6 +95,10 @@ func initStatusHandling() {

// reset handler
http.HandleFunc("/reset", func(w http.ResponseWriter, r *http.Request) {
if err := acl.CheckAccessHTTP(r, acl.ADMIN); err != nil {
acl.SendError(w, err)
return
}
currentWorkerMutex.Lock()
wrk := currentWorker
done := currentDone
Expand Down Expand Up @@ -117,6 +126,10 @@ func initStatusHandling() {

// cancel handler
http.HandleFunc("/cancel", func(w http.ResponseWriter, r *http.Request) {
if err := acl.CheckAccessHTTP(r, acl.ADMIN); err != nil {
acl.SendError(w, err)
return
}
currentWorkerMutex.Lock()
wrk := currentWorker
currentWorkerMutex.Unlock()
Expand Down

0 comments on commit 5fb5738

Please sign in to comment.