Skip to content

Commit

Permalink
chore: use a better config name
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Sep 4, 2024
1 parent 06cd509 commit a2cfaa5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if Mix.env() == :test do
Ash.Test.Support.PolicySimple.Domain
]

config :ash, :policy, forbid_static_forbidden_reads?: false
config :ash, :policy, no_filter_static_forbidden_reads?: false

config :ash, :custom_expressions, [Ash.Test.Expressions.JaroDistance]

Expand Down
2 changes: 1 addition & 1 deletion documentation/tutorials/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ config :ash,
default_page_type: :keyset

config :ash, :policies,
forbid_static_forbidden_reads?: false
no_filter_static_forbidden_reads?: false
```

### Try our first resource out
Expand Down
7 changes: 4 additions & 3 deletions lib/ash/policy/authorizer/authorizer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1557,14 +1557,15 @@ defmodule Ash.Policy.Authorizer do
end

defp forbidden_due_to_strict_policy?(authorizer) do
forbid_static_forbidden_reads? =
no_filter_static_forbidden_reads? =
Keyword.get(
Application.get_env(:ash, :policy, []),
:forbid_static_forbidden_reads?,
:no_filter_static_forbidden_reads?,
true
)

if forbid_static_forbidden_reads? || authorizer.for_fields || authorizer.action.type != :read do
if no_filter_static_forbidden_reads? || authorizer.for_fields ||
authorizer.action.type != :read do
true
else
authorizer.policies
Expand Down
6 changes: 3 additions & 3 deletions lib/ash/policy/filter_check.ex
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ defmodule Ash.Policy.FilterCheck do
|> filter(authorizer, opts)
|> Ash.Expr.fill_template(actor, Ash.Policy.FilterCheck.args(authorizer), context)
|> then(fn expr ->
forbid_static_forbidden_reads? =
no_filter_static_forbidden_reads? =
Keyword.get(
Application.get_env(:ash, :policy, []),
:forbid_static_forbidden_reads?,
:no_filter_static_forbidden_reads?,
true
)

if forbid_static_forbidden_reads? || authorizer.for_fields ||
if no_filter_static_forbidden_reads? || authorizer.for_fields ||
authorizer.action.type != :read ||
context[:private][:pre_flight_authorization?] do
try_eval(expr, authorizer)
Expand Down
2 changes: 1 addition & 1 deletion lib/mix/tasks/install/ash.install.ex
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ defmodule Mix.Tasks.Ash.Install do
|> Igniter.Project.Config.configure(
"config.exs",
:ash,
[:policies, :forbid_static_forbidden_reads?],
[:policies, :no_filter_static_forbidden_reads?],
false
)
|> then(fn igniter ->
Expand Down

0 comments on commit a2cfaa5

Please sign in to comment.