diff --git a/lib/auth/auth_with_roles.go b/lib/auth/auth_with_roles.go index fa358340a3c5b..c6dea70fba05c 100644 --- a/lib/auth/auth_with_roles.go +++ b/lib/auth/auth_with_roles.go @@ -1572,7 +1572,15 @@ func (a *ServerWithRoles) ListUnifiedResources(ctx context.Context, req *proto.L return &proto.ListUnifiedResourcesResponse{}, nil } unifiedResources, err = a.authServer.UnifiedResourceCache.GetUnifiedResourcesByIDs(ctx, prefs.ClusterPreferences.PinnedResources.GetResourceIds(), func(resource types.ResourceWithLabels) bool { - if err := resourceChecker.CanAccess(resource); err != nil { + var err error + switch r := resource.(type) { + // TODO (avatus) we should add this type into the `resourceChecker.CanAccess` method + case types.SAMLIdPServiceProvider: + err = a.action(apidefaults.Namespace, types.KindSAMLIdPServiceProvider, types.VerbList) + default: + err = resourceChecker.CanAccess(r) + } + if err != nil { return false } match, _ := services.MatchResourceByFilters(resource, filter, nil) @@ -1581,6 +1589,13 @@ func (a *ServerWithRoles) ListUnifiedResources(ctx context.Context, req *proto.L if err != nil { return nil, trace.Wrap(err, "getting unified resources by ID") } + + // we need to sort pinned resources manually because they are fetched in the order they were pinned + if req.SortBy.Field != "" { + if err := unifiedResources.SortByCustom(req.SortBy); err != nil { + return nil, trace.Wrap(err, "sorting unified resources") + } + } } else { unifiedResources, nextKey, err = a.authServer.UnifiedResourceCache.IterateUnifiedResources(ctx, func(resource types.ResourceWithLabels) (bool, error) { var err error diff --git a/lib/services/unified_resource.go b/lib/services/unified_resource.go index f60ef1517438c..b68318538c7b4 100644 --- a/lib/services/unified_resource.go +++ b/lib/services/unified_resource.go @@ -17,6 +17,7 @@ package services import ( "bytes" "context" + "strings" "sync" "time" @@ -386,8 +387,10 @@ func makeResourceSortKey(resource types.Resource) resourceSortKey { } return resourceSortKey{ - byName: backend.Key(prefix, name, kind), - byType: backend.Key(prefix, kind, name), + // names should be stored as lowercase to keep items sorted as + // expected, regardless of case + byName: backend.Key(prefix, strings.ToLower(name), kind), + byType: backend.Key(prefix, kind, strings.ToLower(name)), } } diff --git a/web/packages/teleport/src/UnifiedResources/Resources.tsx b/web/packages/teleport/src/UnifiedResources/Resources.tsx index 407478b7e75ff..5e64f896f742f 100644 --- a/web/packages/teleport/src/UnifiedResources/Resources.tsx +++ b/web/packages/teleport/src/UnifiedResources/Resources.tsx @@ -434,8 +434,8 @@ export function resourceName(resource: UnifiedResource) { function NoPinned() { return ( - - You have not pinned any resources + + You have not pinned any resources ); } @@ -443,7 +443,7 @@ function NoPinned() { function PinningNotSupported() { return ( - {PINNING_NOT_SUPPORTED_MESSAGE} + {PINNING_NOT_SUPPORTED_MESSAGE} ); }