Compare commits

...

2 Commits

Author SHA1 Message Date
Gabriel Mabille
2f71c8f562 More logs 2026-01-08 17:10:29 +01:00
Gabriel Mabille
d7a3d61726 Add debug logs, because I'm blind 2026-01-08 17:07:32 +01:00

View File

@@ -170,42 +170,56 @@ func (r *ResourcePermissionsAuthorizer) FilterList(ctx context.Context, list run
if !ok { if !ok {
return nil, storewrapper.ErrUnauthenticated return nil, storewrapper.ErrUnauthenticated
} }
r.logger.Debug("filtering resource permissions list with auth info",
"namespace", authInfo.GetNamespace(),
"identity Subject", authInfo.GetSubject(),
"identity UID", authInfo.GetUID(),
"identity type", authInfo.GetIdentityType(),
)
switch l := list.(type) { switch l := list.(type) {
case *iamv0.ResourcePermissionList: case *iamv0.ResourcePermissionList:
r.logger.Debug("filtering list of length", "length", len(l.Items))
var ( var (
filteredItems []iamv0.ResourcePermission filteredItems []iamv0.ResourcePermission
err error err error
canViewFuncs = map[schema.GroupResource]types.ItemChecker{} canViewFuncs = map[schema.GroupResource]types.ItemChecker{}
) )
for _, item := range l.Items { for _, item := range l.Items {
gr := schema.GroupResource{ target := item.Spec.Resource
Group: item.Spec.Resource.ApiGroup, targetGR := schema.GroupResource{Group: target.ApiGroup, Resource: target.Resource}
Resource: item.Spec.Resource.Resource,
} r.logger.Debug("target resource",
"group", target.ApiGroup,
"resource", target.Resource,
"name", target.Name,
)
// Reuse the same canView for items with the same resource // Reuse the same canView for items with the same resource
canView, found := canViewFuncs[gr] canView, found := canViewFuncs[targetGR]
if !found { if !found {
listReq := types.ListRequest{ listReq := types.ListRequest{
Namespace: item.Namespace, Namespace: item.Namespace,
Group: item.Spec.Resource.ApiGroup, Group: target.ApiGroup,
Resource: item.Spec.Resource.Resource, Resource: target.Resource,
Verb: utils.VerbGetPermissions, Verb: utils.VerbGetPermissions,
} }
r.logger.Debug("compiling list request",
"namespace", item.Namespace,
"group", target.ApiGroup,
"resource", target.Resource,
"verb", utils.VerbGetPermissions,
)
canView, _, err = r.accessClient.Compile(ctx, authInfo, listReq) canView, _, err = r.accessClient.Compile(ctx, authInfo, listReq)
if err != nil { if err != nil {
return nil, err return nil, err
} }
canViewFuncs[gr] = canView canViewFuncs[targetGR] = canView
} }
target := item.Spec.Resource
targetGR := schema.GroupResource{Group: target.ApiGroup, Resource: target.Resource}
parent := "" parent := ""
// Fetch the parent of the resource // Fetch the parent of the resource
// It's not efficient to do for every item in the list, but it's a good starting point. // It's not efficient to do for every item in the list, but it's a good starting point.
@@ -223,6 +237,13 @@ func (r *ResourcePermissionsAuthorizer) FilterList(ctx context.Context, list run
) )
continue continue
} }
r.logger.Debug("fetched parent",
"parent", p,
"namespace", item.Namespace,
"group", target.ApiGroup,
"resource", target.Resource,
"name", target.Name,
)
parent = p parent = p
} }