Skip to content

Commit

Permalink
resolver: handle nil group properly
Browse files Browse the repository at this point in the history
Signed-off-by: Tonis Tiigi <[email protected]>
  • Loading branch information
tonistiigi committed Aug 11, 2020
1 parent 4111533 commit e9fa571
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions util/resolver/authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/base64"
"fmt"
"net/http"
"path"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -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
}
}
}
}

Expand All @@ -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
}
Expand All @@ -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) {
Expand Down

0 comments on commit e9fa571

Please sign in to comment.