Skip to content

Commit

Permalink
chore: add actor to policy errors for later use
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Aug 13, 2024
1 parent f0c6e86 commit 622561d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/ash/error/forbidden/policy.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions lib/ash/policy/authorizer/authorizer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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: []
)}
Expand All @@ -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: []
)}

Expand Down

0 comments on commit 622561d

Please sign in to comment.