From ef895ab712b3db1650c89613e5c5f653a755fdef Mon Sep 17 00:00:00 2001 From: Gabriel Mougard Date: Tue, 5 Nov 2024 16:10:31 +0100 Subject: [PATCH] lxd: Return `IsFineGrained` as part of `api.IdentityInfo` Signed-off-by: Gabriel Mougard --- lxd/identities.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lxd/identities.go b/lxd/identities.go index 0782494d13ae..8c6dde176b3f 100644 --- a/lxd/identities.go +++ b/lxd/identities.go @@ -1062,12 +1062,17 @@ func getCurrentIdentityInfo(d *Daemon, r *http.Request) response.Response { var apiIdentity *api.Identity var effectiveGroups []string var effectivePermissions []api.Permission + var isFineGrained bool err = s.DB.Cluster.Transaction(r.Context(), func(ctx context.Context, tx *db.ClusterTx) error { id, err := dbCluster.GetIdentity(ctx, tx.Tx(), dbCluster.AuthMethod(protocol), identifier) if err != nil { return fmt.Errorf("Failed to get current identity from database: %w", err) } + if identity.IsFineGrainedIdentityType(string(id.Type)) { + isFineGrained = true + } + // Using a permission checker here is redundant, we know who the user is, and we know that they are allowed // to view the groups that they are a member of. apiIdentity, err = id.ToAPI(ctx, tx.Tx(), func(entityURL *api.URL) bool { return true }) @@ -1116,6 +1121,7 @@ func getCurrentIdentityInfo(d *Daemon, r *http.Request) response.Response { Identity: *apiIdentity, EffectiveGroups: effectiveGroups, EffectivePermissions: effectivePermissions, + IsFineGrained: isFineGrained, }) }