From 622561dc905927457b92caa2231e1e056333c97a Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Tue, 13 Aug 2024 10:10:49 -0400 Subject: [PATCH] chore: add actor to policy errors for later use --- lib/ash/error/forbidden/policy.ex | 1 + lib/ash/policy/authorizer/authorizer.ex | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib/ash/error/forbidden/policy.ex b/lib/ash/error/forbidden/policy.ex index 6a16c4cb6..183720573 100644 --- a/lib/ash/error/forbidden/policy.ex +++ b/lib/ash/error/forbidden/policy.ex @@ -11,6 +11,7 @@ defmodule Ash.Error.Forbidden.Policy do scenarios: [], facts: %{}, filter: nil, + actor: nil, policy_breakdown?: false, must_pass_strict_check?: false, for_fields: nil, diff --git a/lib/ash/policy/authorizer/authorizer.ex b/lib/ash/policy/authorizer/authorizer.ex index a8fe4dfd1..d50d09de2 100644 --- a/lib/ash/policy/authorizer/authorizer.ex +++ b/lib/ash/policy/authorizer/authorizer.ex @@ -484,6 +484,7 @@ defmodule Ash.Policy.Authorizer do policies: Map.get(state, :policies), resource: Map.get(state, :resource), action: Map.get(state, :action), + actor: Map.get(state, :actor), changeset_doesnt_match_filter: true, filter: filter ) @@ -496,6 +497,7 @@ defmodule Ash.Policy.Authorizer do policies: Map.get(state, :policies), resource: Map.get(state, :resource), action: Map.get(state, :action), + actor: Map.get(state, :actor), must_pass_strict_check?: true ) end @@ -507,6 +509,7 @@ defmodule Ash.Policy.Authorizer do policies: Map.get(state, :policies), resource: Map.get(state, :resource), action: Map.get(state, :action), + actor: Map.get(state, :actor), must_pass_strict_check?: true ) end @@ -1507,6 +1510,7 @@ defmodule Ash.Policy.Authorizer do context_description: opts[:context_description], for_fields: opts[:for_fields], resource: Map.get(authorizer, :resource), + actor: Map.get(authorizer, :action), action: Map.get(authorizer, :action), scenarios: [] )} @@ -1529,6 +1533,7 @@ defmodule Ash.Policy.Authorizer do for_fields: opts[:for_fields], resource: Map.get(authorizer, :resource), action: Map.get(authorizer, :action), + actor: Map.get(authorizer, :action), scenarios: [] )}