feat: Make strategy names optional where possible. (#113)

This commit is contained in:
James Harton 2023-01-09 15:02:48 +13:00 committed by GitHub
parent f117200ad4
commit 792ec056b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 8 deletions

View file

@ -211,7 +211,7 @@ defmodule AshAuthentication.Dsl do
end
"""
],
args: [:name],
args: [{:optional, :name, :password}],
hide: [:name],
target: Password,
modules: [:hash_provider],
@ -302,7 +302,7 @@ defmodule AshAuthentication.Dsl do
%Entity{
name: :oauth2,
describe: "OAuth2 authentication",
args: [:name],
args: [{:optional, :name, :oauth2}],
target: OAuth2,
modules: [
:authorize_path,
@ -581,7 +581,7 @@ defmodule AshAuthentication.Dsl do
%Entity{
name: :confirmation,
describe: "User confirmation flow",
args: [:name],
args: [{:optional, :name, :confirm}],
target: Confirmation,
modules: [:sender],
schema:
@ -694,6 +694,7 @@ defmodule AshAuthentication.Dsl do
|> strategy()
|> Map.merge(%{
name: :auth0,
args: [{:optional, :name, :auth0}],
describe: "Auth0 authentication",
auto_set_fields: [
authorization_params: [scope: "openid profile email"],

View file

@ -115,7 +115,7 @@ defmodule AshAuthentication.MixProject do
defp deps do
[
{:ash, ash_version("~> 2.4")},
{:spark, "~> 0.3"},
{:spark, "~> 0.3.4"},
{:jason, "~> 1.4"},
{:joken, "~> 2.5"},
{:plug, "~> 1.13"},

View file

@ -57,7 +57,7 @@
"providers": {:hex, :providers, "1.8.1", "70b4197869514344a8a60e2b2a4ef41ca03def43cfb1712ecf076a0f3c62f083", [:rebar3], [{:getopt, "1.0.1", [hex: :getopt, repo: "hexpm", optional: false]}], "hexpm", "e45745ade9c476a9a469ea0840e418ab19360dc44f01a233304e118a44486ba0"},
"ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"},
"sourceror": {:hex, :sourceror, "0.11.2", "549ce48be666421ac60cfb7f59c8752e0d393baa0b14d06271d3f6a8c1b027ab", [:mix], [], "hexpm", "9ab659118896a36be6eec68ff7b0674cba372fc8e210b1e9dc8cf2b55bb70dfb"},
"spark": {:hex, :spark, "0.3.3", "e9bddc3fdb7ab0cf480c37a70f6d5c721a10c9984840c3747baad57a16848559", [:mix], [{:nimble_options, "~> 0.5", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:sourceror, "~> 0.1", [hex: :sourceror, repo: "hexpm", optional: false]}], "hexpm", "cbc6469c1f20d12ea09dd57896f8ad4e54104e7bb11ccdac3775c968c851cd96"},
"spark": {:hex, :spark, "0.3.4", "0084ce931c0e444194d5198b6f872c74c85607b6e5672436056e9f5b6fa41139", [:mix], [{:nimble_options, "~> 0.5", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:sourceror, "~> 0.1", [hex: :sourceror, repo: "hexpm", optional: false]}], "hexpm", "7816d3a43916c5fac2bb2308f9a3442644950e5e269014e4cdc5b2cab0bab5e0"},
"stream_data": {:hex, :stream_data, "0.5.0", "b27641e58941685c75b353577dc602c9d2c12292dd84babf506c2033cd97893e", [:mix], [], "hexpm", "012bd2eec069ada4db3411f9115ccafa38540a3c78c4c0349f151fc761b9e271"},
"telemetry": {:hex, :telemetry, "1.2.0", "a8ce551485a9a3dac8d523542de130eafd12e40bbf76cf0ecd2528f24e812a44", [:rebar3], [], "hexpm", "1427e73667b9a2002cf1f26694c422d5c905df889023903c4518921d53e3e883"},
"typable": {:hex, :typable, "0.3.0", "0431e121d124cd26f312123e313d2689b9a5322b15add65d424c07779eaa3ca1", [:mix], [], "hexpm", "880a0797752da1a4c508ac48f94711e04c86156f498065a83d160eef945858f8"},

View file

@ -132,7 +132,7 @@ defmodule Example.User do
end
strategies do
password :password do
password do
resettable do
sender fn user, token ->
Logger.debug(
@ -142,7 +142,7 @@ defmodule Example.User do
end
end
oauth2 :oauth2 do
oauth2 do
client_id &get_config/2
redirect_uri &get_config/2
client_secret &get_config/2
@ -155,7 +155,7 @@ defmodule Example.User do
identity_resource Example.UserIdentity
end
auth0 :auth0 do
auth0 do
client_id &get_config/2
redirect_uri &get_config/2
client_secret &get_config/2