mirror of
https://github.com/team-alembic/ash_authentication.git
synced 2024-09-19 21:03:23 +12:00
chore: fix errors from previous commit
This commit is contained in:
parent
b75097dd3e
commit
652983be5a
5 changed files with 18 additions and 6 deletions
|
@ -68,6 +68,18 @@ Currently supported strategies:
|
||||||
3. `AshAuthentication.Strategy.MagicLink`
|
3. `AshAuthentication.Strategy.MagicLink`
|
||||||
- authenticate by sending a single-use link to the user.
|
- 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
|
||||||
|
|
||||||
Add-ons are like strategies, except that they don't actually provide
|
Add-ons are like strategies, except that they don't actually provide
|
||||||
|
|
|
@ -87,12 +87,12 @@ defmodule AshAuthentication.Plug.Helpers do
|
||||||
"purpose" => "user"
|
"purpose" => "user"
|
||||||
},
|
},
|
||||||
tenant: Ash.PlugHelpers.get_tenant(conn),
|
tenant: Ash.PlugHelpers.get_tenant(conn),
|
||||||
context: Ash.PlugHelpers.get_context(conn)
|
context: Ash.PlugHelpers.get_context(conn) || %{}
|
||||||
),
|
),
|
||||||
{:ok, user} <-
|
{:ok, user} <-
|
||||||
AshAuthentication.subject_to_user(subject, resource,
|
AshAuthentication.subject_to_user(subject, resource,
|
||||||
tenant: Ash.PlugHelpers.get_tenant(conn),
|
tenant: Ash.PlugHelpers.get_tenant(conn),
|
||||||
context: Ash.PlugHelpers.get_context(conn)
|
context: Ash.PlugHelpers.get_context(conn) || %{}
|
||||||
) do
|
) do
|
||||||
Conn.assign(conn, current_subject_name, user)
|
Conn.assign(conn, current_subject_name, user)
|
||||||
else
|
else
|
||||||
|
@ -141,7 +141,7 @@ defmodule AshAuthentication.Plug.Helpers do
|
||||||
{:ok, user} <-
|
{:ok, user} <-
|
||||||
AshAuthentication.subject_to_user(subject, resource,
|
AshAuthentication.subject_to_user(subject, resource,
|
||||||
tenant: Ash.PlugHelpers.get_tenant(conn),
|
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),
|
{:ok, subject_name} <- Info.authentication_subject_name(resource),
|
||||||
current_subject_name <- current_subject_name(subject_name) do
|
current_subject_name <- current_subject_name(subject_name) do
|
||||||
|
|
|
@ -55,7 +55,7 @@ defmodule AshAuthentication.Strategy.MagicLink.Plug do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp opts(conn) do
|
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)))
|
|> Enum.reject(&is_nil(elem(&1, 1)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -74,7 +74,7 @@ defmodule AshAuthentication.Strategy.OAuth2.Plug do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp action_opts(conn) do
|
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)))
|
|> Enum.reject(&is_nil(elem(&1, 1)))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ defmodule AshAuthentication.TokenResource.ActionsTest do
|
||||||
DateTime.utc_now()
|
DateTime.utc_now()
|
||||||
|> DateTime.to_unix()
|
|> DateTime.to_unix()
|
||||||
|
|
||||||
10..1
|
10..1//-1
|
||||||
|> Enum.each(fn i ->
|
|> Enum.each(fn i ->
|
||||||
{:ok, token, _} = Jwt.token_for_user(user, %{"exp" => now - i})
|
{:ok, token, _} = Jwt.token_for_user(user, %{"exp" => now - i})
|
||||||
:ok = Actions.revoke(Example.Token, token)
|
:ok = Actions.revoke(Example.Token, token)
|
||||||
|
|
Loading…
Reference in a new issue