Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 25 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -91,6 +92,7 @@ This will automatically:
- [x] Pages Module

## 🛣️ Roadmap / Ideas / Feature requests

- User Auth
- 2FA
- Fail2ban (userbased, ip based, region based)
Expand Down Expand Up @@ -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
```
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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,
Expand All @@ -253,6 +258,7 @@ config :phoenix_kit, PhoenixKit.Mailer,
```

### Layout Integration

```elixir
# Use your app's layout (optional)
config :phoenix_kit,
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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,
Expand Down Expand Up @@ -318,28 +327,33 @@ 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`

## 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]
Expand All @@ -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")
Expand All @@ -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}]
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/mix/tasks/phoenix_kit.install.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand All @@ -389,7 +389,7 @@ else

def deps do
[
{:igniter, "~> 0.6.27"}
{:igniter, "~> 0.7"}
# ... your other dependencies
]
end
Expand Down
4 changes: 2 additions & 2 deletions lib/mix/tasks/phoenix_kit.update.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand All @@ -888,7 +888,7 @@ else

def deps do
[
{:igniter, "~> 0.6.27"}
{:igniter, "~> 0.7"}
# ... your other dependencies
]
end
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading