Skip to content

Commit

Permalink
fix: app scoped role assignment not properly linking to AZApp
Browse files Browse the repository at this point in the history
  • Loading branch information
mistahj67 authored Apr 26, 2024
2 parents 33ab1f3 + 3f31192 commit 9f36bca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion cmd/list-role-assignments.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,17 @@ func listRoleAssignments(ctx context.Context, client client.AzureClient, roles <
count = 0
filter = fmt.Sprintf("roleDefinitionId eq '%s'", id)
)
for item := range client.ListAzureADRoleAssignments(ctx, filter, "", "", "", nil) {
// We expand directoryScope in order to obtain the appId from app specific scoped role assignments
for item := range client.ListAzureADRoleAssignments(ctx, filter, "", "", "directoryScope", nil) {
if item.Error != nil {
log.Error(item.Error, "unable to continue processing role assignments for this role", "roleDefinitionId", id)
} else {
log.V(2).Info("found role assignment", "roleAssignments", item)
count++
// To ensure proper linking to AZApp nodes we want to supply the AppId instead when role assignments are app specific scoped
if item.Ok.DirectoryScopeId != "/" {
item.Ok.DirectoryScopeId = fmt.Sprintf("/%s", item.Ok.DirectoryScope.AppId)
}
roleAssignments.RoleAssignments = append(roleAssignments.RoleAssignments, item.Ok)
}
}
Expand Down
2 changes: 1 addition & 1 deletion models/azure/unified_role_assignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type UnifiedRoleAssignment struct {
// The directory object that is the scope of the assignment.
// Read-only.
// Supports $expand.
DirectoryScope json.RawMessage
DirectoryScope Application `json:"directoryScope,omitempty"`

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

0 comments on commit 9f36bca

Please sign in to comment.