More debug info for auth

This commit is contained in:
jamesread 2023-12-21 01:26:17 +00:00
parent 00927f3ba3
commit 6b0e414932
3 changed files with 15 additions and 5 deletions

View File

@ -110,8 +110,10 @@ func buildUserAcls(cfg *config.Config, user *AuthenticatedUser) {
} }
} }
func isACLRelevant(cfg *config.Config, actionAcls []string, acl config.AccessControlList, user *AuthenticatedUser) bool { func isACLRelevantToAction(cfg *config.Config, actionAcls []string, acl config.AccessControlList, user *AuthenticatedUser) bool {
if !slices.Contains(user.acls, acl.Name) { if !slices.Contains(user.acls, acl.Name) {
// If the user does not have this ACL, then it is not relevant
return false return false
} }
@ -130,7 +132,7 @@ func getRelevantAcls(cfg *config.Config, actionAcls []string, user *Authenticate
var ret []*config.AccessControlList var ret []*config.AccessControlList
for _, acl := range cfg.AccessControlLists { for _, acl := range cfg.AccessControlLists {
if isACLRelevant(cfg, actionAcls, acl, user) { if isACLRelevantToAction(cfg, actionAcls, acl, user) {
ret = append(ret, &acl) ret = append(ret, &acl)
} }
} }

View File

@ -23,6 +23,8 @@ func parseHttpHeaderForAuth(req *http.Request) (string, string) {
username, ok := req.Header[cfg.AuthHttpHeaderUsername] username, ok := req.Header[cfg.AuthHttpHeaderUsername]
if !ok { if !ok {
log.Warnf("Config has AuthHttpHeaderUsername set to %v, but it was not found", cfg.AuthHttpHeaderUsername)
return "", "" return "", ""
} }
@ -30,10 +32,16 @@ func parseHttpHeaderForAuth(req *http.Request) (string, string) {
usergroup, ok := req.Header[cfg.AuthHttpHeaderUserGroup] usergroup, ok := req.Header[cfg.AuthHttpHeaderUserGroup]
if ok { if ok {
log.Debugf("HTTP Header Auth found a username and usergroup")
return username[0], usergroup[0] return username[0], usergroup[0]
} else {
log.Warnf("Config has AuthHttpHeaderUserGroup set to %v, but it was not found", cfg.AuthHttpHeaderUserGroup)
} }
} }
log.Debugf("HTTP Header Auth found a username, but usergroup is not being used")
return username[0], "" return username[0], ""
} }
@ -54,7 +62,7 @@ func parseRequestMetadata(ctx context.Context, req *http.Request) metadata.MD {
"usergroup", usergroup, "usergroup", usergroup,
) )
log.Debugf("jwt usable claims: %+v", md) log.Debugf("api request metadata: %+v", md)
return md return md
} }

View File

@ -38,7 +38,7 @@ func StartSingleHTTPFrontend(cfg *config.Config) {
}) })
mux.HandleFunc("/websocket", func(w http.ResponseWriter, r *http.Request) { mux.HandleFunc("/websocket", func(w http.ResponseWriter, r *http.Request) {
log.Debugf("websocket req: %q", r.URL) log.Debugf("ws req: %q", r.URL)
websocket.HandleWebsocket(w, r) websocket.HandleWebsocket(w, r)
}) })