From f314110c7f79d04b70e20cbb5da9d738061c3e34 Mon Sep 17 00:00:00 2001 From: "construct.d" Date: Thu, 20 Nov 2025 19:42:58 +0000 Subject: [PATCH] Install igniter by default --- CONTRIBUTING.md | 2 +- README.md | 29 ++++++++++++++++++++++++---- lib/mix/tasks/phoenix_kit.install.ex | 4 ++-- lib/mix/tasks/phoenix_kit.update.ex | 4 ++-- mix.exs | 2 +- 5 files changed, 31 insertions(+), 10 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a20286515..09bdadeff 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -30,7 +30,7 @@ cd your_app_name defp deps do [ {:phoenix_kit, path: "../phoenix_kit"}, - {:igniter, "~> 0.6.0", only: [:dev]}, # Required for phoenix_kit.install task + {:igniter, "~> 0.7"}, # Required for phoenix_kit.install task # ... other Phoenix dependencies ] end diff --git a/README.md b/README.md index 9284fc884..8a2d2b964 100644 --- a/README.md +++ b/README.md @@ -16,14 +16,13 @@ With PhoenixKit, you will be able to create production-ready Elixir/Phoenix apps PhoenixKit provides pretty simple installation method, powered by igniter library, which takes care of all configuration needs. -Add both `phoenix_kit` and `igniter` to your project dependencies: +Add `phoenix_kit` to your project dependencies. `igniter` installed in `phoenix_kit`. ```elixir # mix.exs def deps do [ - {:phoenix_kit, "~> 1.6"}, - {:igniter, "~> 0.7", only: [:dev]} + {:phoenix_kit, "~> 1.6"} ] end ``` @@ -36,6 +35,7 @@ mix phoenix_kit.install ``` This will automatically: + - Auto-detect your Ecto repository - **Validate PostgreSQL compatibility** with adapter detection - Generate migration files for authentication tables @@ -46,6 +46,7 @@ This will automatically: - Add authentication routes to your router ## 📦 Current PhoenixKit Features / Modules: + ``` ✅ Simple installation using Igniter ✅ Tailwind and DaisyUI integration @@ -91,6 +92,7 @@ This will automatically: - [x] Pages Module ## 🛣️ Roadmap / Ideas / Feature requests + - User Auth - 2FA - Fail2ban (userbased, ip based, region based) @@ -181,7 +183,7 @@ Add both `phoenix_kit` and `igniter` to your project dependencies: def deps do [ {:phoenix_kit, "~> 1.4.3"}, - {:igniter, "~> 0.6.0", only: [:dev]} + {:igniter, "~> 0.7"} ] end ``` @@ -194,6 +196,7 @@ mix phoenix_kit.install ``` This will automatically: + - ✅ Auto-detect your Ecto repository - ✅ **Validate PostgreSQL compatibility** with adapter detection - ✅ Generate migration files for authentication tables @@ -228,6 +231,7 @@ mix phoenix_kit.install --router-path lib/my_app_web/router.ex ## Quick Start Visit these URLs after installation: + - `http://localhost:4000/{prefix}/users/register` - User registration - `http://localhost:4000/{prefix}/users/log-in` - User login @@ -236,6 +240,7 @@ Where `{prefix}` is your configured PhoenixKit URL prefix (default: `/phoenix_ki ## Configuration ### Basic Setup + ```elixir # config/config.exs (automatically added by installer) config :phoenix_kit, @@ -253,6 +258,7 @@ config :phoenix_kit, PhoenixKit.Mailer, ``` ### Layout Integration + ```elixir # Use your app's layout (optional) config :phoenix_kit, @@ -265,6 +271,7 @@ config :phoenix_kit, PhoenixKit supports multiple email providers with automatic setup assistance: #### AWS SES (Complete Setup) + For AWS SES, PhoenixKit automatically configures required dependencies and HTTP client: ```elixir @@ -283,6 +290,7 @@ config :phoenix_kit, PhoenixKit.Mailer, ``` **AWS SES Checklist:** + - ✅ Create AWS IAM user with SES permissions (`ses:*`) - ✅ Verify sender email address in AWS SES Console - ✅ Verify recipient emails (if in sandbox mode) @@ -291,6 +299,7 @@ config :phoenix_kit, PhoenixKit.Mailer, - ✅ Set environment variables: `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` #### Other Email Providers + ```elixir # SendGrid config :phoenix_kit, PhoenixKit.Mailer, @@ -318,6 +327,7 @@ proxy_set_header X-Forwarded-Proto $scheme; See [OAuth Setup Guide](guides/oauth_and_magic_link_setup.md) for details. ### Advanced Options + - Custom URL prefix: `phoenix_kit_routes("/authentication")` - PostgreSQL schemas: `mix phoenix_kit.install --prefix "auth" --create-schema` - Custom repository: `mix phoenix_kit.install --repo MyApp.CustomRepo` @@ -325,21 +335,25 @@ See [OAuth Setup Guide](guides/oauth_and_magic_link_setup.md) for details. ## Routes ### Public Routes + - `GET {prefix}/users/register` - Registration form - `GET {prefix}/users/log-in` - Login form - `GET {prefix}/users/reset-password` - Password reset - `GET {prefix}/users/confirm/:token` - Email confirmation ### Authenticated Routes + - `GET {prefix}/users/settings` - User settings ### Admin Routes (Owner/Admin only) + - `GET {prefix}/admin/dashboard` - Admin dashboard - `GET {prefix}/admin/users` - User management ## API Usage ### Current User Access + ```elixir # In your controller or LiveView user = conn.assigns[:phoenix_kit_current_user] @@ -350,6 +364,7 @@ PhoenixKit.Users.Auth.Scope.authenticated?(scope) ``` ### Role-Based Access + ```elixir # Check user roles PhoenixKit.Users.Roles.user_has_role?(user, "Admin") @@ -362,6 +377,7 @@ on_mount: [{PhoenixKitWeb.Users.Auth, :phoenix_kit_ensure_admin}] ``` ### Authentication Helpers + ```elixir # In your LiveView sessions on_mount: [{PhoenixKitWeb.Users.Auth, :phoenix_kit_mount_current_scope}] @@ -371,6 +387,7 @@ on_mount: [{PhoenixKitWeb.Users.Auth, :phoenix_kit_ensure_authenticated_scope}] ## Database Schema PhoenixKit creates these PostgreSQL tables: + - `phoenix_kit_users` - User accounts with email, names, status - `phoenix_kit_users_tokens` - Authentication tokens (session, reset, confirm) - `phoenix_kit_user_roles` - System and custom roles @@ -380,11 +397,13 @@ PhoenixKit creates these PostgreSQL tables: ## Role-Based Access Control ### System Roles + - **Owner** - Full system access (first user) - **Admin** - Management privileges - **User** - Standard access (default) ### Role Management + ```elixir # Check roles PhoenixKit.Users.Roles.get_user_roles(user) @@ -399,12 +418,14 @@ PhoenixKit.Users.Roles.create_role(%{name: "Manager", description: "Team lead"}) ``` ### Built-in Admin Interface + - `{prefix}/admin/dashboard` - System statistics - `{prefix}/admin/users` - User management with role controls ## Architecture PhoenixKit follows professional library patterns: + - **Library-First**: No OTP application, minimal dependencies - **Dynamic Repository**: Uses your existing Ecto repo - **Versioned Migrations**: Oban-style schema management diff --git a/lib/mix/tasks/phoenix_kit.install.ex b/lib/mix/tasks/phoenix_kit.install.ex index 028e0de66..7fc440c38 100644 --- a/lib/mix/tasks/phoenix_kit.install.ex +++ b/lib/mix/tasks/phoenix_kit.install.ex @@ -371,7 +371,7 @@ else This task requires the Igniter library to be available. Please add it to your mix.exs: - {:igniter, "~> 0.6.27"} + {:igniter, "~> 0.7"} Then run: mix deps.get """ @@ -389,7 +389,7 @@ else def deps do [ - {:igniter, "~> 0.6.27"} + {:igniter, "~> 0.7"} # ... your other dependencies ] end diff --git a/lib/mix/tasks/phoenix_kit.update.ex b/lib/mix/tasks/phoenix_kit.update.ex index 29b6393ef..430079d75 100644 --- a/lib/mix/tasks/phoenix_kit.update.ex +++ b/lib/mix/tasks/phoenix_kit.update.ex @@ -870,7 +870,7 @@ else This task requires the Igniter library to be available. Please add it to your mix.exs: - {:igniter, "~> 0.6.27"} + {:igniter, "~> 0.7"} Then run: mix deps.get """ @@ -888,7 +888,7 @@ else def deps do [ - {:igniter, "~> 0.6.27"} + {:igniter, "~> 0.7"} # ... your other dependencies ] end diff --git a/mix.exs b/mix.exs index 3d0af8fa7..39f34939e 100644 --- a/mix.exs +++ b/mix.exs @@ -129,7 +129,7 @@ defmodule PhoenixKit.MixProject do {:finch, "~> 0.18"}, # Code generation and project patching - {:igniter, "~> 0.7", optional: true} + {:igniter, "~> 0.7"} ] end