Sha256: f9474d59ba58867d6f6ab6fa8b4b50693aecf069ae9e5d6d3c12da862783de9d
Contents?: true
Size: 805 Bytes
Versions: 10
Compression:
Stored size: 805 Bytes
Contents
module Ddr module Auth class LegacyPermissions attr_reader :permissions LEGACY_PERMISSION_ROLE_MAP = { "discover" => "Viewer", "read" => "Viewer", "edit" => "Editor" } def initialize(permissions) @permissions = permissions end def to_resource_roles to_roles(:resource) end def to_policy_roles to_roles(:policy) end def to_roles(scope) permissions.map do |perm| Roles::Role.build(type: role_type(perm), agent: perm[:name], scope: scope) end end private def role_type(perm) LEGACY_PERMISSION_ROLE_MAP[perm[:access]] end def agent_type(perm) perm[:type] == "group" ? :group : :person end end end end
Version data entries
10 entries across 10 versions & 1 rubygems