chore: fix errors from previous commit

This commit is contained in:
Zach Daniel 2024-08-09 09:37:42 -04:00
parent b75097dd3e
commit 652983be5a
5 changed files with 18 additions and 6 deletions

View file

@ -68,6 +68,18 @@ Currently supported strategies:
3. `AshAuthentication.Strategy.MagicLink`
- authenticate by sending a single-use link to the user.
### HTTP client settings
Most of the authentication strategies based on `OAuth2` wrap the [`assent`](https://hex.pm/packages/assent) package.
If you needs to customize the behavior of the http client used by `assent`, define a custom `http_adapter` in the
application settings:
`config :ash_authentication, :http_adapter, {Assent.HTTPAdapter.Finch, supervisor: MyApp.CustomFinch}`
See [`assent's documentation`](https://hexdocs.pm/assent/README.html#http-client) for more details on the supported
http clients and their configuration.
## Add-ons
Add-ons are like strategies, except that they don't actually provide

View file

@ -87,12 +87,12 @@ defmodule AshAuthentication.Plug.Helpers do
"purpose" => "user"
},
tenant: Ash.PlugHelpers.get_tenant(conn),
context: Ash.PlugHelpers.get_context(conn)
context: Ash.PlugHelpers.get_context(conn) || %{}
),
{:ok, user} <-
AshAuthentication.subject_to_user(subject, resource,
tenant: Ash.PlugHelpers.get_tenant(conn),
context: Ash.PlugHelpers.get_context(conn)
context: Ash.PlugHelpers.get_context(conn) || %{}
) do
Conn.assign(conn, current_subject_name, user)
else
@ -141,7 +141,7 @@ defmodule AshAuthentication.Plug.Helpers do
{:ok, user} <-
AshAuthentication.subject_to_user(subject, resource,
tenant: Ash.PlugHelpers.get_tenant(conn),
context: Ash.PlugHelpers.get_context(conn)
context: Ash.PlugHelpers.get_context(conn) || %{}
),
{:ok, subject_name} <- Info.authentication_subject_name(resource),
current_subject_name <- current_subject_name(subject_name) do

View file

@ -55,7 +55,7 @@ defmodule AshAuthentication.Strategy.MagicLink.Plug do
end
defp opts(conn) do
[actor: get_actor(conn), tenant: get_tenant(conn), context: get_context(conn)]
[actor: get_actor(conn), tenant: get_tenant(conn), context: get_context(conn) || %{}]
|> Enum.reject(&is_nil(elem(&1, 1)))
end
end

View file

@ -74,7 +74,7 @@ defmodule AshAuthentication.Strategy.OAuth2.Plug do
end
defp action_opts(conn) do
[actor: get_actor(conn), tenant: get_tenant(conn), get_context(conn)]
[actor: get_actor(conn), tenant: get_tenant(conn), context: get_context(conn) || %{}]
|> Enum.reject(&is_nil(elem(&1, 1)))
end

View file

@ -46,7 +46,7 @@ defmodule AshAuthentication.TokenResource.ActionsTest do
DateTime.utc_now()
|> DateTime.to_unix()
10..1
10..1//-1
|> Enum.each(fn i ->
{:ok, token, _} = Jwt.token_for_user(user, %{"exp" => now - i})
:ok = Actions.revoke(Example.Token, token)