From aba2b2fb3544d9e42991237c13d8cada421deda5 Mon Sep 17 00:00:00 2001 From: Greg Steuck Date: Tue, 15 Jun 2021 11:37:27 -0700 Subject: dashboard/app: document the values in maps and rename local vars The previous names confused a couple of unrelated concepts. --- dashboard/app/api.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'dashboard/app/api.go') 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 -- cgit mrf-deployment