Skip to content

Commit 3f31192

Browse files
committed
fix: app scoped role assgnmt not properly linking to AZApp
1 parent 33ab1f3 commit 3f31192

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

cmd/list-role-assignments.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,17 @@ func listRoleAssignments(ctx context.Context, client client.AzureClient, roles <
9999
count = 0
100100
filter = fmt.Sprintf("roleDefinitionId eq '%s'", id)
101101
)
102-
for item := range client.ListAzureADRoleAssignments(ctx, filter, "", "", "", nil) {
102+
// We expand directoryScope in order to obtain the appId from app specific scoped role assignments
103+
for item := range client.ListAzureADRoleAssignments(ctx, filter, "", "", "directoryScope", nil) {
103104
if item.Error != nil {
104105
log.Error(item.Error, "unable to continue processing role assignments for this role", "roleDefinitionId", id)
105106
} else {
106107
log.V(2).Info("found role assignment", "roleAssignments", item)
107108
count++
109+
// To ensure proper linking to AZApp nodes we want to supply the AppId instead when role assignments are app specific scoped
110+
if item.Ok.DirectoryScopeId != "/" {
111+
item.Ok.DirectoryScopeId = fmt.Sprintf("/%s", item.Ok.DirectoryScope.AppId)
112+
}
108113
roleAssignments.RoleAssignments = append(roleAssignments.RoleAssignments, item.Ok)
109114
}
110115
}

models/azure/unified_role_assignment.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ type UnifiedRoleAssignment struct {
6767
// The directory object that is the scope of the assignment.
6868
// Read-only.
6969
// Supports $expand.
70-
DirectoryScope json.RawMessage
70+
DirectoryScope Application `json:"directoryScope,omitempty"`
7171

7272
// Read-only property with details of the app specific scope when the assignment scope is app specific.
7373
// Containment entity.

0 commit comments

Comments
 (0)