Skip to content

Commit 753227c

Browse files
authored
feat: extract sign-in setup task, register OAuth strategies (#725)
* feat: extract sign-in infrastructure into composable setup task, register OAuth strategies - New `ash_authentication_phoenix.setup` task extracts sign-in infrastructure (AuthController, routes, pipeline plugs, LiveUserAuth, overrides, tailwind) from the install task into a standalone, composable task - Install task now composes with setup instead of inlining the logic, eliminating code duplication for security-critical auth infrastructure - Register all 8 OAuth/OIDC strategies in the AAP dispatcher, pointing to the setup task for Phoenix-side integration - OAuth strategies auto-render as buttons in the sign-in page via the strategy's `icon` field — no provider-specific Phoenix components needed * chore(deps): require ash_authentication 5.0.0-rc.3
1 parent 4819b63 commit 753227c

5 files changed

Lines changed: 570 additions & 433 deletions

File tree

lib/mix/tasks/ash_authentication_phoenix.add_strategy.ex

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,30 @@ if Code.ensure_loaded?(Igniter) do
1616
"magic_link" => "ash_authentication.add_strategy.magic_link",
1717
"api_key" => "ash_authentication.add_strategy.api_key",
1818
"totp" => "ash_authentication.add_strategy.totp",
19-
"recovery_code" => "ash_authentication.add_strategy.recovery_code"
19+
"recovery_code" => "ash_authentication.add_strategy.recovery_code",
20+
"github" => "ash_authentication.add_strategy.github",
21+
"google" => "ash_authentication.add_strategy.google",
22+
"apple" => "ash_authentication.add_strategy.apple",
23+
"auth0" => "ash_authentication.add_strategy.auth0",
24+
"microsoft" => "ash_authentication.add_strategy.microsoft",
25+
"slack" => "ash_authentication.add_strategy.slack",
26+
"oidc" => "ash_authentication.add_strategy.oidc",
27+
"oauth2" => "ash_authentication.add_strategy.oauth2"
2028
}
2129

2230
@aap_strategy_tasks %{
2331
"password" => "ash_authentication_phoenix.add_strategy.password",
2432
"magic_link" => "ash_authentication_phoenix.add_strategy.magic_link",
2533
"totp" => "ash_authentication_phoenix.add_strategy.totp",
26-
"recovery_code" => "ash_authentication_phoenix.add_strategy.recovery_code"
34+
"recovery_code" => "ash_authentication_phoenix.add_strategy.recovery_code",
35+
"github" => "ash_authentication_phoenix.setup",
36+
"google" => "ash_authentication_phoenix.setup",
37+
"apple" => "ash_authentication_phoenix.setup",
38+
"auth0" => "ash_authentication_phoenix.setup",
39+
"microsoft" => "ash_authentication_phoenix.setup",
40+
"slack" => "ash_authentication_phoenix.setup",
41+
"oidc" => "ash_authentication_phoenix.setup",
42+
"oauth2" => "ash_authentication_phoenix.setup"
2743
}
2844

2945
@strategy_names Map.keys(@aa_strategy_tasks)
@@ -36,7 +52,15 @@ if Code.ensure_loaded?(Igniter) do
3652
api_key: "Sign in with an API key.",
3753
totp: "Authenticate with a time-based one-time password (TOTP).",
3854
recovery_code:
39-
"Authenticate with one-time recovery codes as a 2FA fallback."
55+
"Authenticate with one-time recovery codes as a 2FA fallback.",
56+
github: "Sign in with GitHub.",
57+
google: "Sign in with Google.",
58+
apple: "Sign in with Apple.",
59+
auth0: "Sign in with Auth0.",
60+
microsoft: "Sign in with Microsoft.",
61+
slack: "Sign in with Slack.",
62+
oidc: "Sign in with a generic OpenID Connect provider.",
63+
oauth2: "Sign in with a generic OAuth2 provider."
4064
]
4165
|> Enum.map_join("\n", fn {name, description} ->
4266
" * `#{name}` - #{description}"
@@ -89,7 +113,12 @@ if Code.ensure_loaded?(Igniter) do
89113
identity_field: :string,
90114
hash_provider: :string,
91115
mode: :string,
92-
name: :string
116+
name: :string,
117+
base_url: :string,
118+
authorize_url: :string,
119+
token_url: :string,
120+
user_url: :string,
121+
team_id: :string
93122
],
94123
aliases: [
95124
a: :accounts,

0 commit comments

Comments
 (0)