Skip to content

Commit

Permalink
chore: fix errors from previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Aug 9, 2024
1 parent b75097d commit 652983b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
12 changes: 12 additions & 0 deletions documentation/dsls/DSL:-AshAuthentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions lib/ash_authentication/plug/helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/ash_authentication/strategies/magic_link/plug.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/ash_authentication/strategies/oauth2/plug.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion test/ash_authentication/token_resource/actions_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 652983b

Please sign in to comment.