From ccb68e60176817d9ebfba7e92ab3d726f1f969a2 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Tue, 11 Aug 2020 16:38:42 -0700 Subject: [PATCH] resolver: handle nil group properly Signed-off-by: Tonis Tiigi --- util/resolver/authorizer.go | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/util/resolver/authorizer.go b/util/resolver/authorizer.go index d63dded7945b9..e4eab01b34878 100644 --- a/util/resolver/authorizer.go +++ b/util/resolver/authorizer.go @@ -5,7 +5,6 @@ import ( "encoding/base64" "fmt" "net/http" - "path" "strings" "sync" "time" @@ -40,24 +39,19 @@ func newAuthHandlerNS(sm *session.Manager) *authHandlerNS { } func (a *authHandlerNS) get(host string, sm *session.Manager, g session.Group) *authHandler { - if g == nil { - return nil - } - - iter := g.SessionIterator() - if iter == nil { - return nil - } - - for { - id := iter.NextSession() - if id == "" { - break - } - h, ok := a.handlers[path.Join(host, id)] - if ok { - h.lastUsed = time.Now() - return h + if g != nil { + if iter := g.SessionIterator(); iter != nil { + for { + id := iter.NextSession() + if id == "" { + break + } + h, ok := a.handlers[host+"/"+id] + if ok { + h.lastUsed = time.Now() + return h + } + } } } @@ -71,7 +65,7 @@ func (a *authHandlerNS) get(host string, sm *session.Manager, g session.Group) * session, username, password, err := sessionauth.CredentialsFunc(sm, g)(host) if err == nil { if username == h.common.Username && password == h.common.Secret { - a.handlers[path.Join(host, session)] = h + a.handlers[host+"/"+session] = h h.lastUsed = time.Now() return h } @@ -83,7 +77,7 @@ func (a *authHandlerNS) get(host string, sm *session.Manager, g session.Group) * } func (a *authHandlerNS) set(host, session string, h *authHandler) { - a.handlers[path.Join(host, session)] = h + a.handlers[host+"/"+session] = h } func (a *authHandlerNS) delete(h *authHandler) {