docs: change tutorial to help enable policy authorizers (#446)

* docs: add snippet to help enable policy authorizers

* docs: add info about `picosat_elixir` to 'Get Started' section

* docs: change wording to discourage use of `simple_sat` unless needed
This commit is contained in:
Nicholas Moen 2024-05-13 10:45:11 -06:00 committed by GitHub
parent 8583623551
commit c7ecd7214a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -33,7 +33,8 @@ defmodule Example.MixProject do
{:ash, "~> x.x"}, {:ash, "~> x.x"},
{:ash_authentication, "~> x.x"}, {:ash_authentication, "~> x.x"},
{:ash_authentication_phoenix, "~> x.x"}, {:ash_authentication_phoenix, "~> x.x"},
{:ash_postgres, "~> x.x"} {:ash_postgres, "~> x.x"},
{:picosat_elixir, "~> x.x"}
# <-- add these lines # <-- add these lines
] ]
end end
@ -46,6 +47,10 @@ Let's fetch everything:
$ mix deps.get $ mix deps.get
``` ```
> ### Picosat installation issues? {: .info}
>
> If you have trouble compiling `picosat_elixir`, then replace `{:picosat_elixir, "~> x.x"}` with `{:simple_sat, "~> x.x"}` to use a simpler (but mildly slower) solver. You can always switch back to `picosat_elixir` later once you're done with the tutorial.
### Formatter ### Formatter
We can make our life easier and the code more consistent by adding formatters to the project. We will use [Elixir's built-in formatter](https://hexdocs.pm/mix/master/Mix.Tasks.Format.html) for this. We can make our life easier and the code more consistent by adding formatters to the project. We will use [Elixir's built-in formatter](https://hexdocs.pm/mix/master/Mix.Tasks.Format.html) for this.
@ -212,6 +217,8 @@ defmodule Example.Accounts.User do
use Ash.Resource, use Ash.Resource,
domain: Example.Accounts, domain: Example.Accounts,
data_layer: AshPostgres.DataLayer, data_layer: AshPostgres.DataLayer,
# If using policies, enable the policy authorizer:
# authorizers: [Ash.Policy.Authorizer],
extensions: [AshAuthentication] extensions: [AshAuthentication]
attributes do attributes do
@ -281,6 +288,8 @@ defmodule Example.Accounts.Token do
use Ash.Resource, use Ash.Resource,
domain: Example.Accounts, domain: Example.Accounts,
data_layer: AshPostgres.DataLayer, data_layer: AshPostgres.DataLayer,
# If using policies, enable the policy authorizer:
# authorizers: [Ash.Policy.Authorizer],
extensions: [AshAuthentication.TokenResource] extensions: [AshAuthentication.TokenResource]
postgres do postgres do