simple-module-hosting 0.0.41__tar.gz → 0.0.43__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/.gitignore +3 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/PKG-INFO +6 -6
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/pyproject.toml +6 -6
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/__init__.py +2 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_db_health.py +2 -5
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_deferred_startup.py +7 -1
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_error_handlers.py +15 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_error_negotiation.py +2 -3
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_error_page.py +9 -1
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_inertia_shared.py +36 -34
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_lease_redis.py +30 -5
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_lifespan.py +33 -55
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_middleware_pipeline.py +15 -25
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_observability.py +4 -2
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_preapp_config.py +2 -1
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_rate_limit.py +6 -2
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_spa_mount.py +41 -1
- simple_module_hosting-0.0.43/simple_module_hosting/data_compatibility.py +37 -0
- simple_module_hosting-0.0.43/simple_module_hosting/errors.py +28 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/health.py +25 -15
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/host_settings.py +13 -2
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/i18n_middleware.py +20 -8
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/inertia_deps.py +14 -2
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/inertia_utils.py +7 -9
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/log_sinks.py +4 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/maintenance.py +4 -2
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/middleware.py +39 -25
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/migrations.py +5 -0
- simple_module_hosting-0.0.43/simple_module_hosting/path_matching.py +8 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/setup_gate.py +18 -13
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/setup_wizard/migrate.py +21 -4
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/setup_wizard/payloads.py +4 -5
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/setup_wizard/routes.py +4 -4
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/shared_props.py +2 -1
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_boot_drift_check.py +40 -7
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_error_page_shared_props.py +16 -37
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_grant_sources.py +2 -1
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_health.py +1 -1
- simple_module_hosting-0.0.43/tests/test_hosting_config_sources.py +85 -0
- simple_module_hosting-0.0.43/tests/test_hosting_csp_nonce.py +138 -0
- simple_module_hosting-0.0.41/tests/test_csp_providers.py → simple_module_hosting-0.0.43/tests/test_hosting_csp_providers.py +3 -1
- simple_module_hosting-0.0.43/tests/test_hosting_data_compatibility.py +165 -0
- simple_module_hosting-0.0.43/tests/test_hosting_health_bounded.py +86 -0
- simple_module_hosting-0.0.43/tests/test_hosting_inertia_body_validation.py +115 -0
- simple_module_hosting-0.0.43/tests/test_hosting_inertia_cache.py +23 -0
- simple_module_hosting-0.0.43/tests/test_hosting_inertia_validation_errors.py +78 -0
- simple_module_hosting-0.0.43/tests/test_hosting_lazy_layout_catalogs.py +198 -0
- simple_module_hosting-0.0.43/tests/test_hosting_lease_timeouts.py +163 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_hosting_log_sinks.py +37 -0
- simple_module_hosting-0.0.43/tests/test_hosting_migration_target.py +78 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_hosting_permissions.py +6 -5
- simple_module_hosting-0.0.43/tests/test_hosting_public_error_page.py +36 -0
- simple_module_hosting-0.0.43/tests/test_hosting_public_path_boundaries.py +77 -0
- simple_module_hosting-0.0.43/tests/test_hosting_spa_mount_nonce.py +61 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_inertia_i18n_shared_props.py +41 -30
- simple_module_hosting-0.0.43/tests/test_inertia_protocol_middleware.py +90 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_inertia_shared_providers.py +28 -13
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_lifespan_deferred_startup.py +4 -1
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_locale_middleware.py +35 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_maintenance_mode.py +11 -11
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_menu_providers_wiring.py +18 -17
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_middleware_order.py +8 -20
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_migration_listing.py +7 -2
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_spa_mounts_541.py +2 -10
- simple_module_hosting-0.0.41/simple_module_hosting/_inertia_cache.py +0 -104
- simple_module_hosting-0.0.41/tests/test_inertia_cache.py +0 -187
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/LICENSE +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/README.md +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/__main__.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_anonymous.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_api_version.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_app_boot.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_body_limit.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_boot_checks.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_cors.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_csp_dynamic.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_dev_boot.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_favicon.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_forwarded_host.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_host_services.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_host_settings_support.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_hydrate_step.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_i18n_build.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_i18n_target.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_inertia_setup.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_insecure_transport.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_module_routes.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_openapi.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_phase_helpers.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_process_services.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_project_root.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_rate_limit_keys.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_rate_limit_store.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_registrations.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_request_guard_responses.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_route_access.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_route_guard.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_route_paths.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_secret_key.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_settings_registration.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_tenant.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/app_builder.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/assets.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/bootstrap_settings.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/csrf.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/db_options.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/host_cli.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/i18n_deps.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/i18n_manifest.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/i18n_routes.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/leases.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/locales/de.json +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/locales/en.json +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/locales/es.json +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/logging.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/manifest.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/page_globs.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/pagination.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/permissions.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/public_access.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/py.typed +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/rate_limit_deps.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/redirects.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/resource_deps.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/sentry.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/sentry_scrub.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/sentry_scrub_text.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/session.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/settings.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/setup_wizard/__init__.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/setup_wizard/_migration_lock.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/setup_wizard/components/ConnectionList.tsx +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/setup_wizard/components/StepForm.tsx +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/setup_wizard/pages/Wizard.tsx +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/static_files.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/tenancy.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/token_guard.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/ui_locales/de.json +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/ui_locales/en.json +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/ui_locales/es.json +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/_hosting_settings_db.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/_resacc_models.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/_sentry_transport.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/conftest.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_api_error_negotiation.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_app.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_auth_provider_setting.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_boot_config_hardening.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_branding_head.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_build_time_settings_marked.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_check_migrations.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_check_migrations_expression_note.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_csp_module_sources.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_db_health_check.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_design_packs_wiring.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_diagnostics_state.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_error_status_coverage.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_favicon_default.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_forwarded_host.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_home_url_default.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_host_cli.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_host_settings_fields.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_hosting_asset_version.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_hosting_cors_api.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_hosting_cors_unset.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_hosting_csrf.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_hosting_csrf_shared_prop.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_hosting_error_handling_policy.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_hosting_error_json_and_session_cookie.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_hosting_lease_backends.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_hosting_lease_selection.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_hosting_lifespan_cleanup.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_hosting_openapi.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_hosting_openapi_security.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_hosting_pagination_deps.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_hosting_public_access.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_hosting_sentry.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_hosting_sentry_scrub.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_hosting_sentry_scrub_gaps.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_i18n_build_overrides.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_i18n_manifest.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_i18n_manifest_published_target.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_i18n_routes.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_i18n_types_cover_installed_modules.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_i18n_ui_namespace.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_insecure_transport_warning.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_invalidation_wiring.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_lifespan_order.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_logging.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_manifest.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_menu_urls_are_canonical.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_merge_host_settings_strict.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_migration_multihead.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_native_link_prefixes_strip.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_preapp_config.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_preapp_invalid_values.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_preapp_read_failures.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_precompressed_static.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_principal_permissions_claim.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_proxy_headers.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_rate_limit_rules_redis.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_rate_limit_rules_registry.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_rate_limit_store_shared.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_redirects.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_request_guard_auth_parity.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_request_guard_body_limit.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_request_guard_body_limit_middleware_read.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_request_guard_body_limit_started.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_request_guard_rate_limit.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_resource_deps.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_resource_policy_owned.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_resource_policy_parity.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_resource_types_wiring.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_response_compression.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_route_guard.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_route_guard_fastapi_contract.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_route_paths.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_secret_key_bootstrap.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_server_rendered_head.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_session_cookie_secure.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_session_cookie_security.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_session_cookie_window.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_session_vary_dedupe.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_settings_i18n.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_settings_secrets.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_setup_gate.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_setup_gate_single_flight.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_setup_migrate_error_redaction.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_setup_migrate_worker_lock.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_setup_public_routes.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_setup_registry.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_setup_routes.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_sqlite_path_anchor.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_static_caching.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_strict_discovery_wiring.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_tenancy_api.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_tenant_middleware.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_tenant_resolver_diagnostic.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_tenant_resolver_types.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_tenant_scope_helpers.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_tenant_source.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_token_guard_effective_route.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_token_route_guard.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_translator_dep.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests/test_view_prefixes.py +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tests-js/hosting_SetupWizard.test.tsx +0 -0
- {simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/tsconfig.json +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: simple_module_hosting
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.43
|
|
4
4
|
Summary: FastAPI + Inertia.js host runtime for simple_module — app_builder, middleware stack, CLI (sm / simple-module), scaffolding
|
|
5
5
|
Project-URL: Homepage, https://github.com/antosubash/simple_module_python
|
|
6
6
|
Project-URL: Repository, https://github.com/antosubash/simple_module_python
|
|
@@ -22,18 +22,18 @@ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
|
22
22
|
Classifier: Typing :: Typed
|
|
23
23
|
Requires-Python: >=3.12
|
|
24
24
|
Requires-Dist: click<9,>=8.1
|
|
25
|
-
Requires-Dist: fastapi<0.
|
|
25
|
+
Requires-Dist: fastapi<0.163,>=0.140
|
|
26
26
|
Requires-Dist: httpx<0.29,>=0.27
|
|
27
27
|
Requires-Dist: itsdangerous<3,>=2.0
|
|
28
28
|
Requires-Dist: jinja2<4,>=3.1
|
|
29
|
-
Requires-Dist: simple-module-core==0.0.
|
|
30
|
-
Requires-Dist: simple-module-db==0.0.
|
|
31
|
-
Requires-Dist: simple-module-inertia==0.0.
|
|
29
|
+
Requires-Dist: simple-module-core==0.0.43
|
|
30
|
+
Requires-Dist: simple-module-db==0.0.43
|
|
31
|
+
Requires-Dist: simple-module-inertia==0.0.43
|
|
32
32
|
Requires-Dist: starlette<2,>=0.44
|
|
33
33
|
Requires-Dist: tomlkit<0.16,>=0.13
|
|
34
34
|
Requires-Dist: uvicorn[standard]<0.55,>=0.34
|
|
35
35
|
Provides-Extra: redis
|
|
36
|
-
Requires-Dist: redis<
|
|
36
|
+
Requires-Dist: redis<9,>=5; extra == 'redis'
|
|
37
37
|
Provides-Extra: sentry
|
|
38
38
|
Requires-Dist: sentry-sdk[celery,fastapi]<3,>=2.20; extra == 'sentry'
|
|
39
39
|
Description-Content-Type: text/markdown
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "simple_module_hosting"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.43"
|
|
4
4
|
description = "FastAPI + Inertia.js host runtime for simple_module — app_builder, middleware stack, CLI (sm / simple-module), scaffolding"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
@@ -22,16 +22,16 @@ classifiers = [
|
|
|
22
22
|
]
|
|
23
23
|
dependencies = [
|
|
24
24
|
"click>=8.1,<9",
|
|
25
|
-
"fastapi>=0.140,<0.
|
|
25
|
+
"fastapi>=0.140,<0.163",
|
|
26
26
|
"httpx>=0.27,<0.29",
|
|
27
27
|
# SessionMiddleware (starlette.middleware.sessions) imports itsdangerous at
|
|
28
28
|
# module import time; starlette treats it as an optional extra, so declare
|
|
29
29
|
# it directly — out-of-tree hosts have nothing else pulling it in.
|
|
30
30
|
"itsdangerous>=2.0,<3",
|
|
31
31
|
"jinja2>=3.1,<4",
|
|
32
|
-
"simple_module_core==0.0.
|
|
33
|
-
"simple_module_db==0.0.
|
|
34
|
-
"simple_module_inertia==0.0.
|
|
32
|
+
"simple_module_core==0.0.43",
|
|
33
|
+
"simple_module_db==0.0.43",
|
|
34
|
+
"simple_module_inertia==0.0.43",
|
|
35
35
|
"starlette>=0.44,<2",
|
|
36
36
|
"tomlkit>=0.13,<0.16",
|
|
37
37
|
"uvicorn[standard]>=0.34,<0.55",
|
|
@@ -39,7 +39,7 @@ dependencies = [
|
|
|
39
39
|
|
|
40
40
|
[project.optional-dependencies]
|
|
41
41
|
# Shared rate-limiter store (SM_REDIS_URL). Without it the limiter counts per worker.
|
|
42
|
-
redis = ["redis>=5,<
|
|
42
|
+
redis = ["redis>=5,<9"]
|
|
43
43
|
# Error reporting (SM_SENTRY_DSN). Never imported unless the DSN is set.
|
|
44
44
|
sentry = ["sentry-sdk[fastapi,celery]>=2.20,<3"]
|
|
45
45
|
|
{simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/__init__.py
RENAMED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from simple_module_hosting._preapp_config import merge_host_settings
|
|
4
4
|
from simple_module_hosting.app_builder import create_app
|
|
5
|
+
from simple_module_hosting.errors import render_error_page
|
|
5
6
|
from simple_module_hosting.logging import correlation_id, setup_logging
|
|
6
7
|
from simple_module_hosting.settings import Settings
|
|
7
8
|
from simple_module_hosting.shared_props import (
|
|
@@ -16,5 +17,6 @@ __all__ = [
|
|
|
16
17
|
"create_app",
|
|
17
18
|
"merge_host_settings",
|
|
18
19
|
"register_inertia_shared_provider",
|
|
20
|
+
"render_error_page",
|
|
19
21
|
"setup_logging",
|
|
20
22
|
]
|
{simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_db_health.py
RENAMED
|
@@ -29,11 +29,8 @@ def build_database_check(db_state):
|
|
|
29
29
|
"""Return an async check issuing the cheapest possible round trip."""
|
|
30
30
|
|
|
31
31
|
async def check() -> HealthCheckResult:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
await session.execute(text("SELECT 1"))
|
|
35
|
-
except Exception as exc:
|
|
36
|
-
return HealthCheckResult(status=HealthStatus.UNHEALTHY, detail=str(exc))
|
|
32
|
+
async with db_state.session_factory() as session:
|
|
33
|
+
await session.execute(text("SELECT 1"))
|
|
37
34
|
return HealthCheckResult(status=HealthStatus.HEALTHY, detail="Database reachable")
|
|
38
35
|
|
|
39
36
|
return check
|
|
@@ -11,6 +11,7 @@ from simple_module_core.module_settings import get_module_settings_registry
|
|
|
11
11
|
from simple_module_db.stored_settings import SessionOverrideSource, settings_table_exists
|
|
12
12
|
|
|
13
13
|
from simple_module_hosting._hydrate_step import hydrate_all
|
|
14
|
+
from simple_module_hosting.data_compatibility import check_data_compatibility
|
|
14
15
|
|
|
15
16
|
logger = logging.getLogger(__name__)
|
|
16
17
|
|
|
@@ -45,8 +46,13 @@ async def run_deferred_startup(app: FastAPI) -> None:
|
|
|
45
46
|
operator's out-of-band ``make migrate``) still finishes starting its
|
|
46
47
|
modules. Serialised per app; a hook that fails again is logged and dropped
|
|
47
48
|
rather than raised, because this runs after the migrations have already
|
|
48
|
-
committed
|
|
49
|
+
committed. Compatibility checks run first and still raise: an incompatible
|
|
50
|
+
security state must keep the setup gate closed.
|
|
49
51
|
"""
|
|
52
|
+
pending_checks = getattr(app.state, "deferred_data_compatibility", None)
|
|
53
|
+
if pending_checks:
|
|
54
|
+
await check_data_compatibility(app, pending_checks)
|
|
55
|
+
app.state.deferred_data_compatibility = []
|
|
50
56
|
deferred = get_deferred_startup(app)
|
|
51
57
|
if not deferred:
|
|
52
58
|
return
|
|
@@ -9,6 +9,7 @@ from fastapi.exceptions import RequestValidationError
|
|
|
9
9
|
from fastapi.responses import JSONResponse
|
|
10
10
|
from simple_module_core.exceptions import NotFoundError
|
|
11
11
|
from simple_module_core.permission_denied import PermissionDenied
|
|
12
|
+
from simple_module_inertia import errors_from_validation, is_inertia_request
|
|
12
13
|
from starlette.exceptions import HTTPException
|
|
13
14
|
from starlette.requests import Request
|
|
14
15
|
from starlette.responses import Response
|
|
@@ -16,10 +17,12 @@ from starlette.responses import Response
|
|
|
16
17
|
from simple_module_hosting._error_negotiation import _wants_json
|
|
17
18
|
from simple_module_hosting._error_page import render_error_page
|
|
18
19
|
from simple_module_hosting._observability import CorrelationIdMiddleware
|
|
20
|
+
from simple_module_hosting.inertia_utils import redirect_back_with_errors
|
|
19
21
|
|
|
20
22
|
logger = logging.getLogger(__name__)
|
|
21
23
|
|
|
22
24
|
_INERTIA_ERROR_STATUSES = frozenset({401, 403, 404, 413, 419, 422, 429, 500, 503})
|
|
25
|
+
_FORM_METHODS = frozenset({"POST", "PUT", "PATCH", "DELETE"})
|
|
23
26
|
|
|
24
27
|
|
|
25
28
|
async def http_exception_handler(request: Request, exc: HTTPException) -> Response:
|
|
@@ -51,7 +54,19 @@ async def request_validation_error_handler(
|
|
|
51
54
|
|
|
52
55
|
Same negotiation rule as 403/404/500 (``_wants_json``), so one request
|
|
53
56
|
never sees two different error shapes depending on the error class.
|
|
57
|
+
|
|
58
|
+
An Inertia form submission whose *body* is invalid is the exception: like
|
|
59
|
+
a hand-written ``redirect_back_with_errors``, it goes back to the form with
|
|
60
|
+
one message per field, so ``useForm`` shows them in place. Invalid path,
|
|
61
|
+
query or header values keep the error page: no form field can show them,
|
|
62
|
+
and a GET redirected back could loop.
|
|
54
63
|
"""
|
|
64
|
+
if request.method in _FORM_METHODS and is_inertia_request(request.scope):
|
|
65
|
+
body_errors = [error for error in exc.errors() if tuple(error["loc"][:1]) == ("body",)]
|
|
66
|
+
if body_errors:
|
|
67
|
+
# Only body errors: a bad path/query value alongside them is no form field.
|
|
68
|
+
errors = errors_from_validation(body_errors, request_source=True)
|
|
69
|
+
return redirect_back_with_errors(request, errors)
|
|
55
70
|
if _wants_json(request):
|
|
56
71
|
return JSONResponse(status_code=422, content={"detail": jsonable_encoder(exc.errors())})
|
|
57
72
|
return await render_error_page(request, 422, "The requested URL contains invalid parameters.")
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"""Choose JSON or HTML for framework error responses."""
|
|
2
2
|
|
|
3
|
+
from simple_module_inertia import is_inertia_request
|
|
3
4
|
from starlette.requests import Request
|
|
4
5
|
|
|
5
|
-
from simple_module_hosting._inertia_shared import _INERTIA_HEADER
|
|
6
|
-
|
|
7
6
|
|
|
8
7
|
def _explicit_accept_q(accept: str, media_type: str) -> float | None:
|
|
9
8
|
"""Quality the Accept header gives ``media_type`` by explicit listing, or
|
|
@@ -51,7 +50,7 @@ def _wants_json(request: Request) -> bool:
|
|
|
51
50
|
view path keeps its pre-existing default and an ``/api/*`` path keeps
|
|
52
51
|
getting JSON either way.
|
|
53
52
|
"""
|
|
54
|
-
if request.
|
|
53
|
+
if is_inertia_request(request.scope):
|
|
55
54
|
return False
|
|
56
55
|
accept = request.headers.get("accept", "")
|
|
57
56
|
html_q = _explicit_accept_q(accept, "text/html")
|
{simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_error_page.py
RENAMED
|
@@ -17,6 +17,8 @@ from simple_module_inertia import (
|
|
|
17
17
|
from starlette.requests import Request
|
|
18
18
|
from starlette.responses import Response
|
|
19
19
|
|
|
20
|
+
from simple_module_hosting._inertia_shared import resolve_inertia_shared
|
|
21
|
+
|
|
20
22
|
logger = logging.getLogger(__name__)
|
|
21
23
|
|
|
22
24
|
# Statuses whose remedy is "sign in", so the page offers that as its primary
|
|
@@ -103,7 +105,13 @@ async def render_error_page(
|
|
|
103
105
|
# repeated here. Without it the error page renders raw translation keys
|
|
104
106
|
# (ui.error_page.not_found_title) and loses auth/menus, so a signed-in
|
|
105
107
|
# user's 404 has no layout.
|
|
106
|
-
|
|
108
|
+
try:
|
|
109
|
+
shared = await resolve_inertia_shared(request)
|
|
110
|
+
except Exception:
|
|
111
|
+
# Building the layout is what failed (a DB outage in the menus, say):
|
|
112
|
+
# still render the page, just without the shared layout props.
|
|
113
|
+
logger.warning("Error page: layout props unavailable", exc_info=True)
|
|
114
|
+
shared = {}
|
|
107
115
|
if shared:
|
|
108
116
|
inertia.share(**shared)
|
|
109
117
|
# The correlation id is the only handle a user has on their own failed
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import asyncio
|
|
5
6
|
import inspect
|
|
6
7
|
import logging
|
|
7
8
|
from collections.abc import Callable
|
|
@@ -9,6 +10,7 @@ from typing import Any
|
|
|
9
10
|
|
|
10
11
|
from simple_module_core.app_state import get_inertia_shared_providers, get_services
|
|
11
12
|
from simple_module_core.i18n import Translator
|
|
13
|
+
from simple_module_inertia import is_inertia_request
|
|
12
14
|
from starlette.datastructures import Headers
|
|
13
15
|
from starlette.requests import Request
|
|
14
16
|
from starlette.types import Scope
|
|
@@ -19,8 +21,7 @@ logger = logging.getLogger(__name__)
|
|
|
19
21
|
|
|
20
22
|
_I18N_SESSION_LOCALE_KEY = "__i18n_locale"
|
|
21
23
|
_I18N_SESSION_AUDIENCE_KEY = "__i18n_audience"
|
|
22
|
-
|
|
23
|
-
_INERTIA_HEADER_TRUE = "true"
|
|
24
|
+
I18N_CATALOG_HEADER = "X-SM-I18n"
|
|
24
25
|
#: Shared-prop key the frontend API client reads its ``X-CSRF-Token`` from (#504).
|
|
25
26
|
CSRF_SHARED_PROP = "csrfToken"
|
|
26
27
|
|
|
@@ -35,9 +36,9 @@ def build_i18n_block(scope: Scope, request: Request, *, is_authenticated: bool =
|
|
|
35
36
|
Rules:
|
|
36
37
|
|
|
37
38
|
* No registry / no locale → serve an empty English block and log once.
|
|
38
|
-
* Inertia
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
* Inertia visits (header presence) report their tab's cached catalog in
|
|
40
|
+
``X-SM-I18n: <locale>:<audience>``. Send messages only on a mismatch;
|
|
41
|
+
clients without that header retain the legacy session comparison.
|
|
41
42
|
* Full page loads and locale transitions ship the complete dict.
|
|
42
43
|
* Anonymous visitors receive the public snapshot: catalogs of modules
|
|
43
44
|
declaring ``i18n_audience="admin"`` are withheld (issue #248). A login
|
|
@@ -58,36 +59,25 @@ def build_i18n_block(scope: Scope, request: Request, *, is_authenticated: bool =
|
|
|
58
59
|
)
|
|
59
60
|
return {"locale": "en", "supportedLocales": ["en"], "messages": {}}
|
|
60
61
|
|
|
61
|
-
is_inertia =
|
|
62
|
+
is_inertia = is_inertia_request(scope)
|
|
62
63
|
audience = "full" if is_authenticated else "public"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
# skip the messages payload. Non-Inertia requests will always ship them
|
|
67
|
-
# regardless of the session state.
|
|
68
|
-
if session_dict is not None:
|
|
69
|
-
# Remembering the locale only pays off for a client that will come back
|
|
70
|
-
# with an Inertia XHR (to skip re-sending the catalog). A bare API or
|
|
71
|
-
# health-check call from a cookie-less client will not, and writing
|
|
72
|
-
# here would make Starlette's SessionMiddleware emit a two-week
|
|
73
|
-
# Set-Cookie on every anonymous response, which keeps shared caches
|
|
74
|
-
# from storing it (GH #349). So persist only when a session already
|
|
75
|
-
# exists (it has data) or the caller is page-shaped.
|
|
76
|
-
persist = bool(session_dict) or is_inertia or _accepts_html(scope)
|
|
77
|
-
last_locale = session_dict.get(_I18N_SESSION_LOCALE_KEY)
|
|
78
|
-
locale_changed = last_locale != locale
|
|
79
|
-
if locale_changed and persist:
|
|
80
|
-
session_dict[_I18N_SESSION_LOCALE_KEY] = locale
|
|
81
|
-
last_audience = session_dict.get(_I18N_SESSION_AUDIENCE_KEY)
|
|
82
|
-
audience_changed = last_audience != audience
|
|
83
|
-
if audience_changed and persist:
|
|
84
|
-
session_dict[_I18N_SESSION_AUDIENCE_KEY] = audience
|
|
64
|
+
cached_catalog = Headers(scope=scope).get(I18N_CATALOG_HEADER)
|
|
65
|
+
if cached_catalog is not None:
|
|
66
|
+
send_messages = not is_inertia or cached_catalog != f"{locale}:{audience}"
|
|
85
67
|
else:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
68
|
+
session = scope.get("session")
|
|
69
|
+
changed = session is not None and (
|
|
70
|
+
session.get(_I18N_SESSION_LOCALE_KEY) != locale
|
|
71
|
+
or session.get(_I18N_SESSION_AUDIENCE_KEY) != audience
|
|
72
|
+
)
|
|
73
|
+
# Legacy clients remember only page-shaped requests, never raw fetches.
|
|
74
|
+
if session is not None and (is_inertia or _accepts_html(scope)):
|
|
75
|
+
session[_I18N_SESSION_LOCALE_KEY] = locale
|
|
76
|
+
session[_I18N_SESSION_AUDIENCE_KEY] = audience
|
|
77
|
+
send_messages = not is_inertia or changed
|
|
89
78
|
return {
|
|
90
79
|
"locale": locale,
|
|
80
|
+
"audience": audience,
|
|
91
81
|
"supportedLocales": registry.available_locales(),
|
|
92
82
|
"messages": (
|
|
93
83
|
registry.messages_snapshot(locale, include_admin=is_authenticated)
|
|
@@ -116,9 +106,8 @@ def lazy_csrf_shared_prop(
|
|
|
116
106
|
) -> dict[str, Callable[[], str]]:
|
|
117
107
|
"""Like :func:`csrf_shared_prop`, but the token is resolved at render time.
|
|
118
108
|
|
|
119
|
-
The
|
|
120
|
-
|
|
121
|
-
``Set-Cookie``) on responses that have no use for the token. Inertia calls
|
|
109
|
+
The token stays lazy even after layout resolution, so an Inertia partial
|
|
110
|
+
that excludes it does not mint an unused session token. Inertia calls
|
|
122
111
|
the callable only when it serialises props.
|
|
123
112
|
"""
|
|
124
113
|
if not is_authenticated or request.scope.get("session") is None:
|
|
@@ -191,3 +180,16 @@ def default_home_url(app: Any) -> str:
|
|
|
191
180
|
sm = get_services(app)
|
|
192
181
|
prefix = getattr(sm, "view_prefixes", {}).get("Dashboard")
|
|
193
182
|
return f"{prefix}/" if prefix else "/"
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
async def resolve_inertia_shared(request: Request) -> dict:
|
|
186
|
+
"""Build layout props once on demand, keeping the resolved state dict public."""
|
|
187
|
+
factory = getattr(request.state, "inertia_shared_factory", None)
|
|
188
|
+
if factory is not None:
|
|
189
|
+
task = getattr(request.state, "inertia_shared_task", None)
|
|
190
|
+
if task is None:
|
|
191
|
+
context = getattr(request.state, "inertia_shared_context", None)
|
|
192
|
+
task = asyncio.create_task(factory(), context=context)
|
|
193
|
+
request.state.inertia_shared_task = task
|
|
194
|
+
request.state.inertia_shared = await task
|
|
195
|
+
return getattr(request.state, "inertia_shared", None) or {}
|
{simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_lease_redis.py
RENAMED
|
@@ -8,16 +8,21 @@
|
|
|
8
8
|
members whose score has passed, then admits while ``ZCARD < slots``.
|
|
9
9
|
* ``INCR <key>:fence`` hands out the fencing token, inside the same script.
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
There is no per-process fallback: unavailable Redis cannot confirm a lease.
|
|
12
|
+
Acquire connectivity errors become ConnectionError for the lease handle;
|
|
13
|
+
release connectivity errors are logged and return False. Refresh errors propagate.
|
|
13
14
|
"""
|
|
14
15
|
|
|
15
16
|
from __future__ import annotations
|
|
16
17
|
|
|
17
18
|
import asyncio
|
|
19
|
+
import logging
|
|
18
20
|
import os
|
|
19
21
|
from typing import Any
|
|
20
22
|
|
|
23
|
+
logger = logging.getLogger(__name__)
|
|
24
|
+
_SOCKET_TIMEOUT = 2.0
|
|
25
|
+
|
|
21
26
|
# Holder and fence-counter keys live under disjoint prefixes: a name is never
|
|
22
27
|
# parsed, so ``foo:fence`` cannot collide with the counter of ``foo``.
|
|
23
28
|
_HOLDER_PREFIX = "sm:lease:h:"
|
|
@@ -113,13 +118,33 @@ class RedisLeaseBackend:
|
|
|
113
118
|
self._client = self._factory()
|
|
114
119
|
else:
|
|
115
120
|
import redis.asyncio as aioredis
|
|
116
|
-
|
|
117
|
-
|
|
121
|
+
from redis.asyncio.retry import Retry
|
|
122
|
+
from redis.backoff import NoBackoff
|
|
123
|
+
|
|
124
|
+
self._client = aioredis.from_url(
|
|
125
|
+
self._url,
|
|
126
|
+
socket_timeout=_SOCKET_TIMEOUT,
|
|
127
|
+
socket_connect_timeout=_SOCKET_TIMEOUT,
|
|
128
|
+
# One reconnect, no backoff: a stale pooled connection gets a fresh
|
|
129
|
+
# socket, while the 2 s timeouts keep the worst case bounded.
|
|
130
|
+
retry=Retry(NoBackoff(), 1),
|
|
131
|
+
)
|
|
118
132
|
self._owner = owner
|
|
119
133
|
return self._client
|
|
120
134
|
|
|
121
135
|
async def _eval(self, script: str, keys: list[str], *args: Any) -> int:
|
|
122
|
-
|
|
136
|
+
from redis.exceptions import ConnectionError as RedisConnectionError
|
|
137
|
+
from redis.exceptions import TimeoutError as RedisTimeoutError
|
|
138
|
+
|
|
139
|
+
try:
|
|
140
|
+
return int(await self._redis().eval(script, len(keys), *keys, *args))
|
|
141
|
+
except (RedisConnectionError, RedisTimeoutError) as exc:
|
|
142
|
+
if script in (_ACQUIRE, _SEM_ACQUIRE):
|
|
143
|
+
raise ConnectionError("Redis lease acquire unavailable") from exc
|
|
144
|
+
if script not in (_RELEASE, _SEM_RELEASE):
|
|
145
|
+
raise
|
|
146
|
+
logger.warning("Redis lease release unavailable (%s)", type(exc).__name__)
|
|
147
|
+
return 0
|
|
123
148
|
|
|
124
149
|
@staticmethod
|
|
125
150
|
def _lease_keys(name: str) -> list[str]:
|
{simple_module_hosting-0.0.41 → simple_module_hosting-0.0.43}/simple_module_hosting/_lifespan.py
RENAMED
|
@@ -22,6 +22,7 @@ from simple_module_core.app_state import get_migration_status
|
|
|
22
22
|
|
|
23
23
|
from simple_module_hosting._deferred_startup import hydrate_settings_from_db
|
|
24
24
|
from simple_module_hosting._route_guard import guard_included_routers
|
|
25
|
+
from simple_module_hosting.data_compatibility import check_data_compatibility
|
|
25
26
|
from simple_module_hosting.migrations import migration_status
|
|
26
27
|
from simple_module_hosting.setup_gate import STEP_MIGRATIONS
|
|
27
28
|
|
|
@@ -29,67 +30,35 @@ logger = logging.getLogger(__name__)
|
|
|
29
30
|
|
|
30
31
|
|
|
31
32
|
async def _is_first_run(app: FastAPI) -> bool:
|
|
32
|
-
"""Whether this install has never been set up
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
Treating the second as "setup mode" is wrong twice over. It serves traffic
|
|
45
|
-
against a schema the code does not match — the failure ``SM010`` exists to
|
|
46
|
-
prevent — and it re-opens ``/setup``, whose migration endpoint is
|
|
47
|
-
unauthenticated, letting an anonymous request trigger an Alembic run on a
|
|
48
|
-
live system.
|
|
49
|
-
|
|
50
|
-
So: first run means *something other than the schema* is also outstanding.
|
|
51
|
-
``False`` when no registry exists, since an app built outside
|
|
52
|
-
``create_app`` has no steps to reason about and the old raising behaviour
|
|
53
|
-
is the safer default there.
|
|
54
|
-
|
|
55
|
-
Deliberately does not delegate to ``registry.incomplete()``: that method
|
|
56
|
-
treats a step whose predicate raises as *complete*, which is right for
|
|
57
|
-
``SetupMiddleware``'s steady-state gate (a transient DB error must not
|
|
58
|
-
lock a working install out) but wrong here. On a genuinely fresh
|
|
59
|
-
database the non-migration steps' own tables don't exist yet — the
|
|
60
|
-
administrator check is a query against a table migrations create — so it
|
|
61
|
-
raises too, and swallowing that would make every step but the schema
|
|
62
|
-
look satisfied, exactly the "is setup complete" trap this function
|
|
63
|
-
exists to avoid. A required step raising counts as pending only with
|
|
64
|
-
positive evidence the install is new: the database has never been
|
|
65
|
-
migrated at all (no ``alembic_version``). On a database with migration
|
|
66
|
-
history the same exception is far more likely a transient error on an
|
|
67
|
-
established install, and treating that as first run would serve the
|
|
68
|
-
unauthenticated migration endpoint on a live system — so boot fails
|
|
69
|
-
instead, with the "behind head" error.
|
|
33
|
+
"""Whether this install has never been set up, so boot serves ``/setup``.
|
|
34
|
+
|
|
35
|
+
Needs positive evidence on both counts. The database must never have been
|
|
36
|
+
migrated (no ``alembic_version``): a pending step on a database with
|
|
37
|
+
migration history is a configured install whose schema drifted, and serving
|
|
38
|
+
the unauthenticated migration endpoint there would run Alembic on a live
|
|
39
|
+
system. And no other required step may already report complete: a
|
|
40
|
+
never-migrated database that holds accounts (built with ``create_all``) is
|
|
41
|
+
not empty either. A step that raises counts as pending, since on a fresh
|
|
42
|
+
database its tables do not exist yet. An install whose only required step
|
|
43
|
+
is the migrations step (Keycloak) qualifies (#784).
|
|
70
44
|
"""
|
|
71
45
|
registry = getattr(app.state.sm, "setup_registry", None)
|
|
72
|
-
|
|
46
|
+
migration = get_migration_status(app)
|
|
47
|
+
if not registry or migration is None or migration.get("current_revision", "") is not None:
|
|
73
48
|
return False
|
|
74
49
|
for step in registry.required_steps:
|
|
75
50
|
if step.id == STEP_MIGRATIONS:
|
|
76
51
|
continue
|
|
77
52
|
try:
|
|
78
|
-
|
|
53
|
+
if await step.is_complete(app):
|
|
54
|
+
return False
|
|
79
55
|
except Exception:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
step.id,
|
|
87
|
-
exc_info=True,
|
|
88
|
-
)
|
|
89
|
-
return never_migrated
|
|
90
|
-
if not done:
|
|
91
|
-
return True
|
|
92
|
-
return False
|
|
56
|
+
logger.warning(
|
|
57
|
+
"Setup step %s raised on a never-migrated database; counting it as pending",
|
|
58
|
+
step.id,
|
|
59
|
+
exc_info=True,
|
|
60
|
+
)
|
|
61
|
+
return True
|
|
93
62
|
|
|
94
63
|
|
|
95
64
|
def build_lifespan(modules: Sequence) -> Callable:
|
|
@@ -104,8 +73,7 @@ def build_lifespan(modules: Sequence) -> Callable:
|
|
|
104
73
|
# running the migrations is one of the things that wizard does, and
|
|
105
74
|
# check_migrations' RuntimeError would make it unreachable. Anywhere
|
|
106
75
|
# else the original behaviour stands: a schema the code does not match
|
|
107
|
-
# fails the boot. See _is_first_run for
|
|
108
|
-
# told apart by "is setup complete".
|
|
76
|
+
# fails the boot. See _is_first_run for how the two are told apart.
|
|
109
77
|
app.state.migration = await migration_status(app.state.sm.db.engine)
|
|
110
78
|
if not app.state.migration["is_current"] and not await _is_first_run(app):
|
|
111
79
|
raise RuntimeError(
|
|
@@ -114,6 +82,16 @@ def build_lifespan(modules: Sequence) -> Callable:
|
|
|
114
82
|
f"{app.state.migration['head_revision']!r}). Run: make migrate"
|
|
115
83
|
)
|
|
116
84
|
|
|
85
|
+
# Only a schema at head can be judged: a first run that stopped part-way
|
|
86
|
+
# still has pre-upgrade columns, and refusing it would hide the wizard
|
|
87
|
+
# that finishes the migration. The setup gate runs deferred checks
|
|
88
|
+
# once the schema is current.
|
|
89
|
+
migration = app.state.migration
|
|
90
|
+
if migration["is_current"] and migration.get("current_revision") is not None:
|
|
91
|
+
await check_data_compatibility(app, modules)
|
|
92
|
+
else:
|
|
93
|
+
app.state.deferred_data_compatibility = list(modules)
|
|
94
|
+
|
|
117
95
|
await hydrate_settings_from_db(app)
|
|
118
96
|
|
|
119
97
|
# Behind head on a first run the tables a module's on_startup reads do
|
|
@@ -8,6 +8,7 @@ from fastapi import FastAPI
|
|
|
8
8
|
from simple_module_core.app_state import get_body_limits
|
|
9
9
|
from simple_module_core.environments import NON_PROD_ENVIRONMENTS
|
|
10
10
|
from simple_module_db import CommitBeforeResponseMiddleware
|
|
11
|
+
from simple_module_inertia import InertiaMiddleware
|
|
11
12
|
from starlette.middleware.gzip import GZipMiddleware
|
|
12
13
|
from uvicorn.middleware.proxy_headers import ProxyHeadersMiddleware
|
|
13
14
|
|
|
@@ -15,7 +16,6 @@ from simple_module_hosting import sentry
|
|
|
15
16
|
from simple_module_hosting._body_limit import BodyLimitMiddleware
|
|
16
17
|
from simple_module_hosting._cors import CorsMiddleware, host_policy
|
|
17
18
|
from simple_module_hosting._forwarded_host import ForwardedHostMiddleware
|
|
18
|
-
from simple_module_hosting._inertia_cache import InertiaCacheMiddleware
|
|
19
19
|
from simple_module_hosting._rate_limit import RateLimitMiddleware
|
|
20
20
|
from simple_module_hosting._route_access import API_PREFIX
|
|
21
21
|
from simple_module_hosting.i18n_middleware import LocaleMiddleware
|
|
@@ -88,43 +88,28 @@ def install_middleware(
|
|
|
88
88
|
Order matters: last added = first executed. Execution order:
|
|
89
89
|
(ForwardedHost, if trusted_proxy and forwarded_host_allowlist) →
|
|
90
90
|
(ProxyHeaders, if trusted_proxy) → CorrelationId → RequestLogging → CORS
|
|
91
|
-
→ BodyLimit → GZip → Security → Session → [module] →
|
|
92
|
-
multi_tenant) → Locale →
|
|
93
|
-
→ Maintenance → CommitBeforeResponse.
|
|
91
|
+
→ BodyLimit → GZip → Security → Session → InertiaMiddleware → [module] →
|
|
92
|
+
(Tenant, if multi_tenant) → Locale → InertiaLayoutData →
|
|
93
|
+
RateLimit → Setup → Maintenance → CommitBeforeResponse.
|
|
94
94
|
"""
|
|
95
95
|
# Added first, so it is innermost and its send-wrapper is the first to see
|
|
96
96
|
# the response: the request's DB work commits before any byte reaches the
|
|
97
97
|
# client, instead of in get_db's post-response exit code (GH #257).
|
|
98
98
|
app.add_middleware(CommitBeforeResponseMiddleware)
|
|
99
|
-
#
|
|
100
|
-
#
|
|
101
|
-
#
|
|
102
|
-
#
|
|
103
|
-
# keep out of caches. Added before Inertia so it *executes* after it: the
|
|
104
|
-
# page needs the shared props (auth, menus, i18n) to render with a layout,
|
|
105
|
-
# and auth + locale — both further out — to know who is asking and in which
|
|
106
|
-
# language to answer.
|
|
99
|
+
# Auth, locale and lazy layout resolution must precede the maintenance page.
|
|
100
|
+
# The outer adapter middleware applies protocol and cache rules to it: the
|
|
101
|
+
# 503 renders through Inertia with this user's auth block and menus, so it
|
|
102
|
+
# must stay non-cacheable like any other payload (GH #272).
|
|
107
103
|
app.add_middleware(MaintenanceMiddleware)
|
|
108
|
-
#
|
|
109
|
-
# never been set up has nothing meaningful to put into maintenance mode,
|
|
110
|
-
# and the setup redirect should win. Inside InertiaCache for the same
|
|
111
|
-
# reason Maintenance is — this short-circuits, and the redirect must not
|
|
112
|
-
# be stored by any cache.
|
|
104
|
+
# An install awaiting setup takes precedence over maintenance mode.
|
|
113
105
|
app.add_middleware(SetupMiddleware)
|
|
114
|
-
#
|
|
115
|
-
# can tell anonymous from signed-in), locale/shared props are in place for
|
|
116
|
-
# the error page, and a 429 is still marked non-cacheable.
|
|
106
|
+
# Auth and locale are available when rendering a rate-limit error page.
|
|
117
107
|
app.add_middleware(
|
|
118
108
|
RateLimitMiddleware,
|
|
119
109
|
public_rate=settings.rate_limit_public,
|
|
120
110
|
authenticated_rate=settings.rate_limit_authenticated,
|
|
121
111
|
store=rate_limit_store,
|
|
122
112
|
)
|
|
123
|
-
# Paired with InertiaLayoutDataMiddleware below, which is what puts this
|
|
124
|
-
# user's auth, permissions and menus into every Inertia payload: this one
|
|
125
|
-
# makes sure the payload that results is never stored where a page request
|
|
126
|
-
# can be answered with it.
|
|
127
|
-
app.add_middleware(InertiaCacheMiddleware)
|
|
128
113
|
app.add_middleware(
|
|
129
114
|
InertiaLayoutDataMiddleware,
|
|
130
115
|
menu_registry=menu_registry,
|
|
@@ -144,6 +129,11 @@ def install_middleware(
|
|
|
144
129
|
app.add_middleware(TenantMiddleware, fixed=settings.default_tenant)
|
|
145
130
|
for mod in modules:
|
|
146
131
|
mod.register_middleware(app)
|
|
132
|
+
# Outside every module middleware and the cache guard, so it normalises
|
|
133
|
+
# the final response — including redirects a module middleware issues
|
|
134
|
+
# itself (an expired session's login redirect after a DELETE must still
|
|
135
|
+
# become a 303) — while Session, further out, still sees its result.
|
|
136
|
+
app.add_middleware(InertiaMiddleware)
|
|
147
137
|
app.add_middleware(
|
|
148
138
|
SessionMiddleware,
|
|
149
139
|
secret_key=settings.secret_key,
|
|
@@ -10,6 +10,7 @@ from starlette.datastructures import Headers, MutableHeaders
|
|
|
10
10
|
from starlette.types import ASGIApp, Message, Receive, Scope, Send
|
|
11
11
|
|
|
12
12
|
from simple_module_hosting.logging import correlation_id
|
|
13
|
+
from simple_module_hosting.path_matching import matches_path
|
|
13
14
|
|
|
14
15
|
_LOGGER_NAME = "simple_module.request"
|
|
15
16
|
_request_logger = logging.getLogger(_LOGGER_NAME)
|
|
@@ -20,7 +21,8 @@ _EVENT_REQUEST_STARTED = "request.started"
|
|
|
20
21
|
_EVENT_REQUEST_COMPLETED = "request.completed"
|
|
21
22
|
|
|
22
23
|
# Paths that produce noisy, low-value log entries
|
|
23
|
-
|
|
24
|
+
_QUIET_EXACT = ("/health",)
|
|
25
|
+
_QUIET_PREFIXES = ("/health/", "/static/")
|
|
24
26
|
|
|
25
27
|
|
|
26
28
|
class CorrelationIdMiddleware:
|
|
@@ -77,7 +79,7 @@ class RequestLoggingMiddleware:
|
|
|
77
79
|
return
|
|
78
80
|
|
|
79
81
|
path = scope["path"]
|
|
80
|
-
if
|
|
82
|
+
if matches_path(path, exact=_QUIET_EXACT, prefixes=_QUIET_PREFIXES):
|
|
81
83
|
await self.app(scope, receive, send)
|
|
82
84
|
return
|
|
83
85
|
|
|
@@ -228,7 +228,8 @@ def merge_host_settings(
|
|
|
228
228
|
# relative sqlite paths against the discovered project root, and
|
|
229
229
|
# reconstructing Settings from env alone would redo that resolution
|
|
230
230
|
# against whatever the cwd happens to be.
|
|
231
|
-
fixed =
|
|
231
|
+
fixed = bootstrap.model_dump(include=bootstrap.model_fields_set)
|
|
232
|
+
fixed.update(secret_key=secret_key, database_url=bootstrap.database_url)
|
|
232
233
|
# Lenient, like the lifespan hydration: a stored value that parses but no
|
|
233
234
|
# longer validates (a Literal narrowed in an upgrade) falls back to its
|
|
234
235
|
# default with a WARNING instead of taking down every worker — and with
|