Skip to content

Commit

Permalink
Remove v15 fallback for SAML SP apps
Browse files Browse the repository at this point in the history
  • Loading branch information
zmb3 committed Oct 28, 2024
1 parent 3fe2c3d commit 657192f
Showing 1 changed file with 1 addition and 42 deletions.
43 changes: 1 addition & 42 deletions lib/web/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,7 @@ func (h *Handler) clusterAppsGet(w http.ResponseWriter, r *http.Request, p httpr

page, err := apiclient.GetResourcePage[types.AppServerOrSAMLIdPServiceProvider](r.Context(), clt, req)
if err != nil {
// If the error returned is due to types.KindAppOrSAMLIdPServiceProvider being unsupported, then fallback to attempting to just fetch types.AppServers.
// This is for backwards compatibility with leaf clusters that don't support this new type yet.
// DELETE IN 15.0
if trace.IsNotImplemented(err) {
req, err = convertListResourcesRequest(r, types.KindAppServer)
if err != nil {
return nil, trace.Wrap(err)
}
appServerPage, err := apiclient.GetResourcePage[types.AppServer](r.Context(), clt, req)
if err != nil {
return nil, trace.Wrap(err)
}
// Convert the ResourcePage returned containing AppServers to a ResourcePage containing AppServerOrSAMLIdPServiceProviders.
page = appServerOrSPPageFromAppServerPage(appServerPage)
} else {
return nil, trace.Wrap(err)
}
return nil, trace.Wrap(err)
}

userGroups, err := apiclient.GetAllResources[types.UserGroup](r.Context(), clt, &proto.ListResourcesRequest{
Expand Down Expand Up @@ -449,28 +433,3 @@ func (h *Handler) proxyDNSNames() (dnsNames []string) {
}
return dnsNames
}

// appServerOrSPPageFromAppServerPage converts a ResourcePage containing AppServers to a ResourcePage containing AppServerOrSAMLIdPServiceProviders.
// DELETE IN 15.0
//
//nolint:staticcheck // SA1019. To be deleted along with the API in 16.0.
func appServerOrSPPageFromAppServerPage(appServerPage apiclient.ResourcePage[types.AppServer]) apiclient.ResourcePage[types.AppServerOrSAMLIdPServiceProvider] {
resources := make([]types.AppServerOrSAMLIdPServiceProvider, len(appServerPage.Resources))

for i, appServer := range appServerPage.Resources {
// Create AppServerOrSAMLIdPServiceProvider object from appServer.
appServerOrSP := &types.AppServerOrSAMLIdPServiceProviderV1{
Resource: &types.AppServerOrSAMLIdPServiceProviderV1_AppServer{
AppServer: appServer.(*types.AppServerV3),
},
}

resources[i] = appServerOrSP
}

return apiclient.ResourcePage[types.AppServerOrSAMLIdPServiceProvider]{
Resources: resources,
Total: appServerPage.Total,
NextKey: appServerPage.NextKey,
}
}

0 comments on commit 657192f

Please sign in to comment.