Skip to content

[4x] Delete redundant universal route check from prevent access MW#1427

Open
lukinovec wants to merge 3 commits intomasterfrom
redundant-check
Open

[4x] Delete redundant universal route check from prevent access MW#1427
lukinovec wants to merge 3 commits intomasterfrom
redundant-check

Conversation

@lukinovec
Copy link
Copy Markdown
Contributor

@lukinovec lukinovec commented Dec 29, 2025

The PreventAcessFromUnwantedDomains MW had the tenancy()->routeIsUniversal($route) check either for returning early, or it was a leftover from some older implementation, so I removed it.

The middleware aborts if the $this->accessingTenantRouteFromCentralDomain($request, $route) || $this->accessingCentralRouteFromTenantDomain($request, $route) check passes. Meaning, for the middleware to abort, the route has to be either in central or tenant mode. When the route is in universal mode, the middleware will never reach return $abortRequest(). return $next($request) will always get reached, even when the || tenancy()->routeIsUniversal($route) check is deleted from the previous condition, so that check was basically useless.

Resolves #1418

Summary by CodeRabbit

  • Bug Fixes
    • Fixed domain access restrictions to be consistently enforced across all route types, preventing unauthorized access that was previously bypassed.

The PreventAcessFromUnwantedDomains MW had the routeIsUniversal check either for returning early, or it was a leftover from some older implementation.
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.03%. Comparing base (c32f52c) to head (360b0ca).

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1427   +/-   ##
=========================================
  Coverage     86.03%   86.03%           
+ Complexity     1156     1155    -1     
=========================================
  Files           184      184           
  Lines          3381     3381           
=========================================
  Hits           2909     2909           
  Misses          472      472           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/Middleware/PreventAccessFromUnwantedDomains.php
@lukinovec lukinovec marked this pull request as draft December 29, 2025 16:07
@lukinovec lukinovec marked this pull request as ready for review February 10, 2026 07:25
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 22f539c6-b340-4131-addf-9d52648cb003

📥 Commits

Reviewing files that changed from the base of the PR and between 60dd522 and 55f03dc.

📒 Files selected for processing (1)
  • src/Middleware/PreventAccessFromUnwantedDomains.php

📝 Walkthrough

Walkthrough

The middleware's handle() method was simplified to remove a redundant universal route check. The method now relies exclusively on shouldBeSkipped($route) for determining whether to skip access-prevention logic, eliminating duplicate logic.

Changes

Cohort / File(s) Summary
Middleware Logic Simplification
src/Middleware/PreventAccessFromUnwantedDomains.php
Removed explicit Tenancy::routeIsUniversal($route) check from the condition that determines whether to skip access-prevention logic. The shouldBeSkipped($route) method already handles universal route detection, making the explicit check redundant.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A hop, skip, and logic refine,
One less check makes the code align,
Universal routes now clearly flow,
Through shouldBeSkipped()'s guiding glow! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: removing a redundant universal route check from the middleware.
Linked Issues check ✅ Passed The PR directly addresses issue #1418 by removing the redundant tenancy()->routeIsUniversal($route) check that was unnecessarily duplicated from shouldBeSkipped().
Out of Scope Changes check ✅ Passed The change is narrowly focused on removing a single redundant condition as requested in issue #1418; no unrelated modifications are present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch redundant-check

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes a redundant universal-route short-circuit from PreventAccessFromUnwantedDomains, relying on the existing route-mode checks to ensure universal routes naturally pass through without triggering access prevention.

Changes:

  • Removed tenancy()->routeIsUniversal($route) from the early-return condition in the middleware.
  • Leaves skipping behavior solely to shouldBeSkipped($route).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@stancl stancl self-assigned this Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

is PreventAccessFromUnwantedDomains useful when InitializeTenancyByRequestData is used?

3 participants