Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
6ff4231
Implement RateLimiter user management functions
claude Nov 11, 2025
7185658
Merge branch 'dev' and enhance RateLimiter with production-ready impl…
claude Nov 12, 2025
a7e88c4
Fix compilation error and reduce nesting in get_user_limits
claude Nov 12, 2025
45bb15a
Fix remaining string interpolation in documentation
claude Nov 12, 2025
1ed3ef1
Remove @doc from private functions and clean up unused helpers
claude Nov 12, 2025
fec6ca0
Merge pull request #27 from timujinne/claude/implement-rate-limiter-s…
timujinne Nov 12, 2025
7973855
Merge branch 'dev' of https://github.com/BeamLabEU/phoenix_kit into dev
timujinne Nov 12, 2025
b95e9f8
Fix AWS region selection circular dependency in email settings
claude Nov 14, 2025
599024b
Merge pull request #28 from timujinne/claude/fix-aws-region-loop-01XK…
timujinne Nov 14, 2025
8f0964b
Fix AWS credentials verification and improve region selection UX
timujinne Nov 15, 2025
c8b72bf
Merge branch 'dev' of https://github.com/BeamLabEU/phoenix_kit into dev
timujinne Nov 15, 2025
c1c3a0b
Refactor AWS credentials verification to reduce complexity
timujinne Nov 15, 2025
e45683a
Update version to 1.6.4 with AWS verification improvements
timujinne Nov 15, 2025
0c2be64
Fix configuration timing issue in phoenix_kit.update task
claude Nov 15, 2025
f86ea82
Merge branch 'dev' into claude/fix-phoenix-kit-config-timing-01JAPHWR…
timujinne Nov 15, 2025
92a4d78
Fix compilation error: move super calls into run/1 function
claude Nov 15, 2025
c4613be
Remove unused direct file manipulation functions for Hammer config
claude Nov 15, 2025
5121d3b
Merge pull request #29 from timujinne/claude/fix-phoenix-kit-config-t…
timujinne Nov 15, 2025
2ecfbd8
Fix Hammer configuration detection and two-pass update logic
timujinne Nov 15, 2025
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
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
## 1.6.4 - 2025-11-15

### Fixed
- **AWS Credentials Verification** - Fixed STS response parsing to support ExAws map format
- Added support for both XML string and parsed map responses from AWS STS
- Fixed `parse_sts_response/1` to handle ExAws automatic XML-to-map conversion
- Resolved `CaseClauseError` when verifying credentials with valid AWS keys
- Added comprehensive error handling for all AWS verification failure types

### Changed
- **AWS Region Selection UX** - Streamlined region input workflow from 7 steps to 4
- Replace dropdown-only region field with text input by default
- Add optional "Load regions" button to fetch and display region dropdown
- Enable manual region entry without waiting for region list loading
- Remove requirement for double-saving credentials and region
- Update setup instructions to reflect simplified workflow
- **Code Quality** - Refactored AWS credentials verification handler
- Extract verification logic into separate helper functions
- Reduce cyclomatic complexity from 14 to acceptable level
- Improve code readability and maintainability

## 1.6.3 - 2025-11-12

### Added
Expand Down
121 changes: 110 additions & 11 deletions lib/mix/tasks/phoenix_kit.install.ex
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,34 @@ if Code.ensure_loaded?(Igniter.Mix.Task) do
]
)

# Run standard igniter process
result = super(argv)

# After igniter is done, handle interactive migration
MigrationStrategy.handle_interactive_migration_after_config(elem(opts, 1))

# Always rebuild assets unless explicitly skipped
unless Keyword.get(elem(opts, 1), :skip_assets, false) do
AssetRebuild.check_and_rebuild(verbose: true)
# CRITICAL: Check if required configuration exists BEFORE starting app
# This prevents configuration timing issues where config is added via Igniter
# but the app has already started with cached (missing) configuration
config_status = check_required_configuration()

case config_status do
:missing ->
# First pass: Add configuration via Igniter without starting app
show_missing_config_message(argv)
result = super(argv)
show_config_added_message(argv)
result

:ok ->
# Second pass: Configuration exists, safe to start app and complete installation
# Run standard igniter process
result = super(argv)

# After igniter is done, handle interactive migration
MigrationStrategy.handle_interactive_migration_after_config(elem(opts, 1))

# Always rebuild assets unless explicitly skipped
unless Keyword.get(elem(opts, 1), :skip_assets, false) do
AssetRebuild.check_and_rebuild(verbose: true)
end

result
end

result
end
end

Expand Down Expand Up @@ -249,6 +265,89 @@ if Code.ensure_loaded?(Igniter.Mix.Task) do
""")
end

# Display message about missing configuration
defp show_missing_config_message(argv) do
Mix.shell().info("""

⚠️ Required configuration is missing from config/config.exs

PhoenixKit requires configuration for:
- Ueberauth (OAuth authentication)
- Hammer (rate limiting)

This configuration will be added now.

After this completes, please run the install command again:
mix phoenix_kit.install #{Enum.join(argv, " ")}
""")
end

# Display message after configuration is added
defp show_config_added_message(argv) do
Mix.shell().info("""

✅ Configuration added successfully!

Next step: Run the install command again to complete the installation:
mix phoenix_kit.install #{Enum.join(argv, " ")}
""")
end

# Check if all required configuration exists
# Returns :ok if all config present, :missing if any config is missing
defp check_required_configuration do
config_file = "config/config.exs"

if File.exists?(config_file) do
content = File.read!(config_file)
lines = String.split(content, "\n")

cond do
# Missing Ueberauth configuration entirely
!String.contains?(content, "config :ueberauth") ->
:missing

# Incorrect Ueberauth configuration (providers: [] instead of providers: %{})
String.contains?(content, "config :ueberauth, Ueberauth") &&
Regex.match?(~r/providers:\s*\[\s*\]/, content) ->
:missing

# Missing Hammer configuration (check for active, non-commented config)
!has_active_hammer_config?(lines) ->
:missing

# All required configuration present
true ->
:ok
end
else
# config.exs doesn't exist - let normal flow handle this error
:ok
end
rescue
# If we can't read config, proceed with normal flow
_ -> :ok
end

# Check if active (non-commented) Hammer configuration exists
defp has_active_hammer_config?(lines) do
has_hammer_config =
Enum.any?(lines, fn line ->
trimmed = String.trim(line)
# Not a comment and contains config :hammer
!String.starts_with?(trimmed, "#") and String.starts_with?(trimmed, "config :hammer")
end)

has_expiry_ms =
Enum.any?(lines, fn line ->
trimmed = String.trim(line)
# Not a comment and contains expiry_ms
!String.starts_with?(trimmed, "#") and String.contains?(line, "expiry_ms")
end)

has_hammer_config and has_expiry_ms
end

# Add completion notice with essential next steps (reduced duplication)
defp add_completion_notice(igniter) do
notice = """
Expand Down
Loading
Loading