Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v13] Fix nil user group entries. #29326

Merged
merged 2 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/web/apiserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4284,7 +4284,7 @@ func TestClusterAppsGet(t *testing.T) {
Spec: types.AppSpecV3{
URI: "https://console.aws.amazon.com", // sets field awsConsole to true
PublicAddr: "publicaddrs",
UserGroups: []string{"ug1"},
UserGroups: []string{"ug1", "ug2"}, // ug2 doesn't exist in the backend, so its lookup will fail.
},
},
},
Expand Down
9 changes: 4 additions & 5 deletions lib/web/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/gravitational/trace"
"github.com/julienschmidt/httprouter"

"github.com/gravitational/teleport/api/client"
apiclient "github.com/gravitational/teleport/api/client"
"github.com/gravitational/teleport/api/client/proto"
apidefaults "github.com/gravitational/teleport/api/defaults"
Expand Down Expand Up @@ -60,7 +59,7 @@ func (h *Handler) clusterAppsGet(w http.ResponseWriter, r *http.Request, p httpr
return nil, trace.Wrap(err)
}

page, err := client.GetResourcePage[types.AppServer](r.Context(), clt, req)
page, err := apiclient.GetResourcePage[types.AppServer](r.Context(), clt, req)
if err != nil {
return nil, trace.Wrap(err)
}
Expand All @@ -86,15 +85,15 @@ func (h *Handler) clusterAppsGet(w http.ResponseWriter, r *http.Request, p httpr

app := server.GetApp()

ugs := make(types.UserGroups, len(app.GetUserGroups()))
for i, userGroupName := range app.GetUserGroups() {
ugs := types.UserGroups{}
for _, userGroupName := range app.GetUserGroups() {
userGroup := userGroupLookup[userGroupName]
if userGroup == nil {
h.log.Debugf("Unable to find user group %s when creating user groups, skipping", userGroupName)
continue
}

ugs[i] = userGroup
ugs = append(ugs, userGroup)
}
sort.Sort(ugs)
appsToUserGroups[app.GetName()] = ugs
Expand Down
Loading