aboutsummaryrefslogtreecommitdiffstats
path: root/dashboard/app/api.go
diff options
context:
space:
mode:
authorGreg Steuck <gnezdo@google.com>2021-06-15 11:37:27 -0700
committerDmitry Vyukov <dvyukov@google.com>2021-06-16 15:21:18 +0200
commitaba2b2fb3544d9e42991237c13d8cada421deda5 (patch)
tree46adf0ee465695d8d31535f4690737e3b9ae541b /dashboard/app/api.go
parentc06f97ad4b8a38e6396ff90f6084063f2303ad43 (diff)
dashboard/app: document the values in maps and rename local vars
The previous names confused a couple of unrelated concepts.
Diffstat (limited to 'dashboard/app/api.go')
-rw-r--r--dashboard/app/api.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/dashboard/app/api.go b/dashboard/app/api.go
index dc09a32fc..99dd0e7fd 100644
--- a/dashboard/app/api.go
+++ b/dashboard/app/api.go
@@ -104,6 +104,7 @@ func handleAPI(c context.Context, r *http.Request) (reply interface{}, err error
client := r.PostFormValue("client")
method := r.PostFormValue("method")
log.Infof(c, "api %q from %q", method, client)
+ // Somewhat confusingly the "key" parameter is the password.
ns, err := checkClient(c, client, r.PostFormValue("key"))
if err != nil {
if client != "" {
@@ -142,19 +143,19 @@ func handleAPI(c context.Context, r *http.Request) (reply interface{}, err error
return nsHandler(c, ns, r, payload)
}
-func checkClient(c context.Context, name0, key0 string) (string, error) {
- for name, key := range config.Clients {
+func checkClient(c context.Context, name0, password0 string) (string, error) {
+ for name, password := range config.Clients {
if name == name0 {
- if key != key0 {
+ if password != password0 {
return "", ErrAccess
}
return "", nil
}
}
for ns, cfg := range config.Namespaces {
- for name, key := range cfg.Clients {
+ for name, password := range cfg.Clients {
if name == name0 {
- if key != key0 {
+ if password != password0 {
return "", ErrAccess
}
return ns, nil