mirror of
https://github.com/team-alembic/ash_authentication.git
synced 2024-09-19 21:03:23 +12:00
improvement: use no_depend_modules
for better compile dependencies
This commit is contained in:
parent
e5a9f27c6a
commit
3562aea431
10 changed files with 24 additions and 12 deletions
|
@ -21,7 +21,7 @@ defmodule AshAuthentication.AddOn.Confirmation.Dsl do
|
||||||
describe: "User confirmation flow",
|
describe: "User confirmation flow",
|
||||||
args: [{:optional, :name, :confirm}],
|
args: [{:optional, :name, :confirm}],
|
||||||
target: Confirmation,
|
target: Confirmation,
|
||||||
modules: [:sender],
|
no_depend_modules: [:sender],
|
||||||
schema: [
|
schema: [
|
||||||
name: [
|
name: [
|
||||||
type: :atom,
|
type: :atom,
|
||||||
|
|
|
@ -41,7 +41,7 @@ defmodule AshAuthentication.Dsl do
|
||||||
%Section{
|
%Section{
|
||||||
name: :authentication,
|
name: :authentication,
|
||||||
describe: "Configure authentication for this resource",
|
describe: "Configure authentication for this resource",
|
||||||
modules: [:domain],
|
no_depend_modules: [:domain],
|
||||||
schema: [
|
schema: [
|
||||||
subject_name: [
|
subject_name: [
|
||||||
type: :atom,
|
type: :atom,
|
||||||
|
@ -70,7 +70,7 @@ defmodule AshAuthentication.Dsl do
|
||||||
%Section{
|
%Section{
|
||||||
name: :tokens,
|
name: :tokens,
|
||||||
describe: "Configure JWT settings for this resource",
|
describe: "Configure JWT settings for this resource",
|
||||||
modules: [:token_resource],
|
no_depend_modules: [:token_resource, :signing_secret],
|
||||||
schema: [
|
schema: [
|
||||||
enabled?: [
|
enabled?: [
|
||||||
type: :boolean,
|
type: :boolean,
|
||||||
|
|
|
@ -13,6 +13,7 @@ defmodule AshAuthentication.Strategy.MagicLink.Dsl do
|
||||||
args: [{:optional, :name, :magic_link}],
|
args: [{:optional, :name, :magic_link}],
|
||||||
hide: [:name],
|
hide: [:name],
|
||||||
target: MagicLink,
|
target: MagicLink,
|
||||||
|
no_depend_modules: [:sender],
|
||||||
schema: [
|
schema: [
|
||||||
name: [
|
name: [
|
||||||
type: :atom,
|
type: :atom,
|
||||||
|
|
|
@ -17,7 +17,7 @@ defmodule AshAuthentication.Strategy.OAuth2.Dsl do
|
||||||
describe: "OAuth2 authentication",
|
describe: "OAuth2 authentication",
|
||||||
args: [{:optional, :name, :oauth2}],
|
args: [{:optional, :name, :oauth2}],
|
||||||
target: OAuth2,
|
target: OAuth2,
|
||||||
modules: [
|
no_depend_modules: [
|
||||||
:authorize_url,
|
:authorize_url,
|
||||||
:base_url,
|
:base_url,
|
||||||
:client_id,
|
:client_id,
|
||||||
|
|
|
@ -202,7 +202,8 @@ defmodule AshAuthentication.Strategy.OAuth2.Plug do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp add_http_adapter(config) do
|
defp add_http_adapter(config) do
|
||||||
http_adapter = Application.get_env(
|
http_adapter =
|
||||||
|
Application.get_env(
|
||||||
:ash_authentication,
|
:ash_authentication,
|
||||||
:http_adapter,
|
:http_adapter,
|
||||||
{Finch, supervisor: AshAuthentication.Finch}
|
{Finch, supervisor: AshAuthentication.Finch}
|
||||||
|
|
|
@ -29,7 +29,7 @@ defmodule AshAuthentication.Strategy.Password.Dsl do
|
||||||
args: [{:optional, :name, :password}],
|
args: [{:optional, :name, :password}],
|
||||||
hide: [:name],
|
hide: [:name],
|
||||||
target: Password,
|
target: Password,
|
||||||
modules: [:hash_provider],
|
no_depend_modules: [:hash_provider],
|
||||||
singleton_entity_keys: [:resettable],
|
singleton_entity_keys: [:resettable],
|
||||||
schema: [
|
schema: [
|
||||||
name: [
|
name: [
|
||||||
|
@ -133,6 +133,7 @@ defmodule AshAuthentication.Strategy.Password.Dsl do
|
||||||
name: :resettable,
|
name: :resettable,
|
||||||
describe: "Configure password reset options for the resource",
|
describe: "Configure password reset options for the resource",
|
||||||
target: Password.Resettable,
|
target: Password.Resettable,
|
||||||
|
no_depend_modules: [:sender],
|
||||||
schema: [
|
schema: [
|
||||||
token_lifetime: [
|
token_lifetime: [
|
||||||
type:
|
type:
|
||||||
|
|
|
@ -43,6 +43,7 @@ defimpl AshAuthentication.Strategy, for: AshAuthentication.Strategy.Password do
|
||||||
|
|
||||||
@doc false
|
@doc false
|
||||||
@spec method_for_phase(Password.t(), phase) :: Strategy.http_method()
|
@spec method_for_phase(Password.t(), phase) :: Strategy.http_method()
|
||||||
|
def method_for_phase(_, phase) when phase in [:sign_in_with_token], do: :get
|
||||||
def method_for_phase(_, _), do: :post
|
def method_for_phase(_, _), do: :post
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
|
|
@ -5,7 +5,7 @@ defmodule AshAuthentication.TokenResource do
|
||||||
%Spark.Dsl.Section{
|
%Spark.Dsl.Section{
|
||||||
name: :token,
|
name: :token,
|
||||||
describe: "Configuration options for this token resource",
|
describe: "Configuration options for this token resource",
|
||||||
modules: [:domain],
|
no_depend_modules: [:domain],
|
||||||
schema: [
|
schema: [
|
||||||
domain: [
|
domain: [
|
||||||
type: {:behaviour, Ash.Domain},
|
type: {:behaviour, Ash.Domain},
|
||||||
|
|
|
@ -3,7 +3,7 @@ defmodule AshAuthentication.UserIdentity do
|
||||||
%Spark.Dsl.Section{
|
%Spark.Dsl.Section{
|
||||||
name: :user_identity,
|
name: :user_identity,
|
||||||
describe: "Configure identity options for this resource",
|
describe: "Configure identity options for this resource",
|
||||||
modules: [:domain, :user_resource],
|
no_depend_modules: [:domain, :user_resource],
|
||||||
schema: [
|
schema: [
|
||||||
domain: [
|
domain: [
|
||||||
type: {:behaviour, Ash.Domain},
|
type: {:behaviour, Ash.Domain},
|
||||||
|
|
|
@ -68,6 +68,14 @@ defmodule AshAuthentication.Strategy.Password.StrategyTest do
|
||||||
|> Strategy.method_for_phase(unquote(phase))
|
|> Strategy.method_for_phase(unquote(phase))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for phase <- ~w[sign_in_with_token]a do
|
||||||
|
test "it is get for the #{phase} phase" do
|
||||||
|
assert :get ==
|
||||||
|
%Password{}
|
||||||
|
|> Strategy.method_for_phase(unquote(phase))
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "Strategy.routes/1" do
|
describe "Strategy.routes/1" do
|
||||||
|
|
Loading…
Reference in a new issue