Repository navigation
🐛 Fix the anti-lockout allow-list when Nova is mounted at the root ("/") path - #4
Merged
Merged
Conversation
…/") path
trim(Nova::path(), '/') empties a root path, so "{$novaPath}/user-security" became
"/user-security" — which never matches Request::is()'s slash-less path, blocking
the 2FA enrolment subtree and locking admins out. Build the prefix with a trailing
slash only when there is one.
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved issues were identified, and all reviewers assessed it as ready.
Review effort: Lite
Findings: None
What changed in this PR
Fixes Nova’s anti-lockout path matching when mounted at /, preserving access to the 2FA enrollment flow.
Changes:
- Corrects root-safe User Security path patterns.
- Adds regression tests for access and redirect behavior.
| File | Summary |
|---|---|
tests/Feature/MiddlewareTest.php |
Adds root-path enrollment and redirect coverage. |
src/Http/Middleware/EnsureTwoFactorEnabled.php |
Corrects allow-list matching for root-mounted Nova. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When Nova is mounted at the root path (
config('nova.path') = '/'),EnsureTwoFactorEnabledfails to allow-list the User Security enrolment subtree — so an un-enrolled admin is redirected away from the very page where they'd set up 2FA (lockout / redirect loop).Cause
Request::is()matches against the slash-lessdecodedPath()(user-security), so the leading-slash pattern/user-securitynever matches.Fix
Build the prefix with a trailing slash only when there is one, so the patterns become
user-security/user-security/*at the root:Tests
Added two tests with
config(['nova.path' => '/']): the enrolment subtree is allow-listed, and an un-enrolled admin is still redirected. Pint ✅ · PHPStan ✅ · Pest 45 tests, 100% coverage.