ash/test/support/policy_rbac/resources/file.ex

38 lines
768 B
Elixir
Raw Normal View History

2022-07-22 02:19:47 +12:00
defmodule Ash.Test.Support.PolicyRbac.File do
@moduledoc false
use Ash.Resource,
data_layer: Ash.DataLayer.Ets,
authorizers: [Ash.Policy.Authorizer]
2022-07-22 02:19:47 +12:00
import Ash.Test.Support.PolicyRbac.Checks.RoleChecks, only: [can?: 1]
policies do
policy always() do
authorize_if(can?(:file))
end
policy actor_attribute_equals(:rel_check, true) do
forbid_if selecting(:forbidden)
authorize_if always()
end
end
ets do
private?(true)
end
actions do
defaults [:create, :read, :update, :destroy]
end
attributes do
uuid_primary_key(:id)
attribute(:name, :string)
attribute(:forbidden, :string)
end
relationships do
2022-07-22 02:19:47 +12:00
belongs_to(:organization, Ash.Test.Support.PolicyRbac.Organization)
end
end