Project

General

Profile

Actions

Feature #17586

open

Remove duplicated permissions via migration

Added by Lukas Zapletal about 8 years ago. Updated about 8 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

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", []]]

Related issues 1 (1 open0 closed)

Related to Foreman - Bug #16617: Duplicate filters can be createdNeeds design09/20/2016Actions
Actions

Also available in: Atom PDF