Actions
Feature #17586
openRemove duplicated permissions via migration
Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Description
For some time, our permission framework allowed creating duplicated permissions. This is no longer possible, but Foreman database may contain duplicated entries created by users. Also few duplicated entries were created via migrations (e.g. in discovery, haven't tested other plugins). This is a proposal to create Role#remove_duplicated_permissions method and call it during seeding stage to remove these.
Role.all.map{|r| [r.name, r.permissions.map{|x| [x.name, x.resource_type]}.group_by {|e| e}.select { |k,v| v.size > 1}.keys]} => [["Tasks Manager", []], ["Tasks Reader", []], ["Boot disk access", []], ["Discovery Reader", [["view_hosts", "Host"], ["view_architectures", "Architecture"], ["view_domains", "Domain"], ["view_environments", "Environment"], ["view_hostgroups", "Hostgroup"], ["view_media", "Medium"], ["view_models", "Model"], ["view_operatingsystems", "Operatingsystem"], ["view_provisioning_templates", "ProvisioningTemplate"], ["view_ptables", "Ptable"], ["view_puppetclasses", "Puppetclass"], ["view_realms", "Realm"], ["view_smart_proxies", "SmartProxy"], ["view_subnets", "Subnet"]]], ["Discovery Manager", [["create_hosts", "Host"], ["view_hosts", "Host"], ["view_architectures", "Architecture"], ["view_domains", "Domain"], ["view_environments", "Environment"], ["view_hostgroups", "Hostgroup"], ["view_media", "Medium"], ["view_models", "Model"], ["view_operatingsystems", "Operatingsystem"], ["view_provisioning_templates", "ProvisioningTemplate"], ["view_ptables", "Ptable"], ["view_puppetclasses", "Puppetclass"], ["view_realms", "Realm"], ["view_smart_proxies", "SmartProxy"], ["view_subnets", "Subnet"]]], ["Manager", []], ["Edit partition tables", []], ["View hosts", []], ["Edit hosts", []], ["Viewer", []], ["Site manager", []], ["Default role", []]]
Actions