Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow only subutai user use update config rest
  • Loading branch information
emli committed Mar 19, 2018
1 parent ad48c41 commit fa85e24
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,20 @@ func delTag(values map[string][]string) (int, error) {
}

func ModifyConfig(w http.ResponseWriter, r *http.Request) {
token := r.URL.Query().Get("token")
owner := strings.ToLower(db.CheckToken(token))
if len(token) == 0 || len(owner) == 0 {
w.WriteHeader(http.StatusUnauthorized)
w.Write([]byte("Not authorized"))
log.Warn(r.RemoteAddr + " - rejecting unauthorized owner request")
return
}
if owner != "subutai" {
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte("Only allowed users can update template config"))
log.Warn(r.RemoteAddr + " - rejecting update request")
return
}
list := db.Search("")
for _, k := range list {
if db.CheckRepo("", "template", k) == 0 {
Expand Down

0 comments on commit fa85e24

Please sign in to comment.