Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: app scoped role assignment not properly linking to AZApp #78

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading