feat(middleware): harden routing with fail-closed policy, custom subdomain management, and perf fixes
- Fix IPv6 host parsing with _strip_port() utility - Remove dangerous StorePlatform→Store.subdomain silent fallback - Close storefront gate bypass when frontend_type is None - Add custom subdomain management UI and API for stores - Add domain health diagnostic tool - Convert db.add() in loops to db.add_all() (24 PERF-006 fixes) - Add tests for all new functionality (18 subdomain service tests) - Add .github templates for validator compliance Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -85,8 +85,9 @@ class ErrorPageRenderer:
|
||||
Returns:
|
||||
HTMLResponse with rendered error page
|
||||
"""
|
||||
# Get frontend type
|
||||
frontend_type = get_frontend_type(request)
|
||||
# Get frontend type — default to PLATFORM in error rendering context
|
||||
# (errors can occur before FrontendTypeMiddleware runs)
|
||||
frontend_type = get_frontend_type(request) or FrontendType.PLATFORM
|
||||
|
||||
# Prepare template data
|
||||
template_data = ErrorPageRenderer._prepare_template_data(
|
||||
@@ -291,7 +292,7 @@ class ErrorPageRenderer:
|
||||
# TODO: Implement actual admin check based on JWT/session
|
||||
# For now, check if we're in admin frontend
|
||||
frontend_type = get_frontend_type(request)
|
||||
return frontend_type == FrontendType.ADMIN
|
||||
return frontend_type is not None and frontend_type == FrontendType.ADMIN
|
||||
|
||||
@staticmethod
|
||||
def _render_basic_html_fallback(
|
||||
|
||||
@@ -388,7 +388,7 @@ def _redirect_to_login(request: Request) -> RedirectResponse:
|
||||
Uses FrontendType detection to determine admin vs store vs storefront login.
|
||||
Properly handles multi-access routing (domain, subdomain, path-based).
|
||||
"""
|
||||
frontend_type = get_frontend_type(request)
|
||||
frontend_type = get_frontend_type(request) or FrontendType.PLATFORM
|
||||
|
||||
if frontend_type == FrontendType.ADMIN:
|
||||
logger.debug("Redirecting to /admin/login")
|
||||
|
||||
Reference in New Issue
Block a user