Skip to content

Commit

Permalink
lxd: Return IsFineGrained as part of api.IdentityInfo
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Mougard <[email protected]>
  • Loading branch information
gabrielmougard committed Nov 5, 2024
1 parent 55b61ee commit ef895ab
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lxd/identities.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down Expand Up @@ -1116,6 +1121,7 @@ func getCurrentIdentityInfo(d *Daemon, r *http.Request) response.Response {
Identity: *apiIdentity,
EffectiveGroups: effectiveGroups,
EffectivePermissions: effectivePermissions,
IsFineGrained: isFineGrained,
})
}

Expand Down

0 comments on commit ef895ab

Please sign in to comment.