simple-module-hosting 0.0.42__tar.gz → 0.0.44__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.42 → simple_module_hosting-0.0.44}/.gitignore +3 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/PKG-INFO +6 -6
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/pyproject.toml +6 -6
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_api_version.py +3 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_app_boot.py +4 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_db_health.py +2 -5
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_error_handlers.py +15 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_error_negotiation.py +2 -3
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_error_page.py +9 -1
- simple_module_hosting-0.0.44/simple_module_hosting/_i18n_json.py +28 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_inertia_shared.py +38 -35
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_lease_redis.py +30 -5
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_lifespan.py +22 -55
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_middleware_pipeline.py +22 -26
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_observability.py +4 -2
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_phase_helpers.py +1 -1
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_preapp_config.py +2 -1
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_rate_limit.py +6 -2
- simple_module_hosting-0.0.44/simple_module_hosting/_security_headers.py +150 -0
- simple_module_hosting-0.0.44/simple_module_hosting/_server_timing.py +64 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_settings_registration.py +1 -1
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_spa_mount.py +41 -1
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/assets.py +10 -3
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/health.py +25 -15
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/host_settings.py +13 -2
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/i18n_middleware.py +20 -8
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/inertia_deps.py +14 -2
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/inertia_utils.py +7 -9
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/log_sinks.py +4 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/maintenance.py +5 -3
- simple_module_hosting-0.0.44/simple_module_hosting/middleware.py +165 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/migrations.py +5 -0
- simple_module_hosting-0.0.44/simple_module_hosting/path_matching.py +13 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/permissions.py +29 -5
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/setup_gate.py +9 -13
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/setup_wizard/migrate.py +12 -3
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/setup_wizard/payloads.py +4 -5
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/setup_wizard/routes.py +4 -4
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/shared_props.py +2 -1
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_boot_drift_check.py +40 -7
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_error_page_shared_props.py +16 -37
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_grant_sources.py +2 -1
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_health.py +1 -1
- simple_module_hosting-0.0.44/tests/test_hosting_api_version_cache.py +10 -0
- simple_module_hosting-0.0.44/tests/test_hosting_catalog_json_cache.py +64 -0
- simple_module_hosting-0.0.44/tests/test_hosting_config_sources.py +85 -0
- simple_module_hosting-0.0.44/tests/test_hosting_csp_nonce.py +138 -0
- simple_module_hosting-0.0.42/tests/test_csp_providers.py → simple_module_hosting-0.0.44/tests/test_hosting_csp_providers.py +3 -1
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_hosting_csrf_shared_prop.py +5 -6
- simple_module_hosting-0.0.44/tests/test_hosting_health_bounded.py +86 -0
- simple_module_hosting-0.0.44/tests/test_hosting_inertia_body_validation.py +115 -0
- simple_module_hosting-0.0.44/tests/test_hosting_inertia_cache.py +23 -0
- simple_module_hosting-0.0.44/tests/test_hosting_inertia_validation_errors.py +78 -0
- simple_module_hosting-0.0.44/tests/test_hosting_lazy_layout_catalogs.py +198 -0
- simple_module_hosting-0.0.44/tests/test_hosting_lease_timeouts.py +163 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_hosting_log_sinks.py +37 -0
- simple_module_hosting-0.0.44/tests/test_hosting_migration_target.py +78 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_hosting_openapi.py +3 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_hosting_permissions.py +6 -5
- simple_module_hosting-0.0.44/tests/test_hosting_platform_permissions.py +54 -0
- simple_module_hosting-0.0.44/tests/test_hosting_public_path_boundaries.py +82 -0
- simple_module_hosting-0.0.44/tests/test_hosting_security_static_headers.py +42 -0
- simple_module_hosting-0.0.44/tests/test_hosting_server_timing.py +70 -0
- simple_module_hosting-0.0.44/tests/test_hosting_spa_mount_nonce.py +61 -0
- simple_module_hosting-0.0.44/tests/test_hosting_ui_assets.py +52 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_inertia_i18n_shared_props.py +41 -30
- simple_module_hosting-0.0.44/tests/test_inertia_protocol_middleware.py +90 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_inertia_shared_providers.py +28 -13
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_invalidation_wiring.py +7 -7
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_locale_middleware.py +35 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_maintenance_mode.py +11 -11
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_menu_providers_wiring.py +18 -17
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_middleware_order.py +8 -20
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_migration_listing.py +7 -2
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_spa_mounts_541.py +2 -10
- simple_module_hosting-0.0.42/simple_module_hosting/_inertia_cache.py +0 -104
- simple_module_hosting-0.0.42/simple_module_hosting/middleware.py +0 -285
- simple_module_hosting-0.0.42/tests/test_inertia_cache.py +0 -187
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/LICENSE +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/README.md +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/__init__.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/__main__.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_anonymous.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_body_limit.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_boot_checks.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_cors.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_csp_dynamic.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_deferred_startup.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_dev_boot.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_favicon.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_forwarded_host.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_host_services.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_host_settings_support.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_hydrate_step.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_i18n_build.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_i18n_target.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_inertia_setup.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_insecure_transport.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_module_routes.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_openapi.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_process_services.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_project_root.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_rate_limit_keys.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_rate_limit_store.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_registrations.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_request_guard_responses.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_route_access.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_route_guard.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_route_paths.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_secret_key.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_tenant.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/app_builder.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/bootstrap_settings.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/csrf.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/data_compatibility.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/db_options.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/errors.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/host_cli.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/i18n_deps.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/i18n_manifest.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/i18n_routes.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/leases.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/locales/de.json +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/locales/en.json +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/locales/es.json +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/logging.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/manifest.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/page_globs.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/pagination.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/public_access.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/py.typed +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/rate_limit_deps.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/redirects.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/resource_deps.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/sentry.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/sentry_scrub.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/sentry_scrub_text.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/session.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/settings.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/setup_wizard/__init__.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/setup_wizard/_migration_lock.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/setup_wizard/components/ConnectionList.tsx +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/setup_wizard/components/StepForm.tsx +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/setup_wizard/pages/Wizard.tsx +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/static_files.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/tenancy.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/token_guard.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/ui_locales/de.json +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/ui_locales/en.json +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/simple_module_hosting/ui_locales/es.json +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/_hosting_settings_db.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/_resacc_models.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/_sentry_transport.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/conftest.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_api_error_negotiation.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_app.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_auth_provider_setting.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_boot_config_hardening.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_branding_head.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_build_time_settings_marked.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_check_migrations.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_check_migrations_expression_note.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_csp_module_sources.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_db_health_check.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_design_packs_wiring.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_diagnostics_state.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_error_status_coverage.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_favicon_default.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_forwarded_host.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_home_url_default.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_host_cli.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_host_settings_fields.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_hosting_asset_version.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_hosting_cors_api.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_hosting_cors_unset.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_hosting_csrf.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_hosting_data_compatibility.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_hosting_error_handling_policy.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_hosting_error_json_and_session_cookie.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_hosting_lease_backends.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_hosting_lease_selection.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_hosting_lifespan_cleanup.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_hosting_openapi_security.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_hosting_pagination_deps.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_hosting_public_access.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_hosting_public_error_page.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_hosting_sentry.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_hosting_sentry_scrub.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_hosting_sentry_scrub_gaps.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_i18n_build_overrides.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_i18n_manifest.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_i18n_manifest_published_target.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_i18n_routes.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_i18n_types_cover_installed_modules.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_i18n_ui_namespace.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_insecure_transport_warning.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_lifespan_deferred_startup.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_lifespan_order.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_logging.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_manifest.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_menu_urls_are_canonical.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_merge_host_settings_strict.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_migration_multihead.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_native_link_prefixes_strip.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_preapp_config.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_preapp_invalid_values.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_preapp_read_failures.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_precompressed_static.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_principal_permissions_claim.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_proxy_headers.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_rate_limit_rules_redis.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_rate_limit_rules_registry.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_rate_limit_store_shared.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_redirects.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_request_guard_auth_parity.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_request_guard_body_limit.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_request_guard_body_limit_middleware_read.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_request_guard_body_limit_started.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_request_guard_rate_limit.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_resource_deps.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_resource_policy_owned.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_resource_policy_parity.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_resource_types_wiring.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_response_compression.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_route_guard.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_route_guard_fastapi_contract.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_route_paths.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_secret_key_bootstrap.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_server_rendered_head.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_session_cookie_secure.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_session_cookie_security.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_session_cookie_window.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_session_vary_dedupe.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_settings_i18n.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_settings_secrets.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_setup_gate.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_setup_gate_single_flight.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_setup_migrate_error_redaction.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_setup_migrate_worker_lock.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_setup_public_routes.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_setup_registry.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_setup_routes.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_sqlite_path_anchor.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_static_caching.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_strict_discovery_wiring.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_tenancy_api.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_tenant_middleware.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_tenant_resolver_diagnostic.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_tenant_resolver_types.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_tenant_scope_helpers.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_tenant_source.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_token_guard_effective_route.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_token_route_guard.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_translator_dep.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests/test_view_prefixes.py +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/tests-js/hosting_SetupWizard.test.tsx +0 -0
- {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/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.44
|
|
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.44
|
|
30
|
+
Requires-Dist: simple-module-db==0.0.44
|
|
31
|
+
Requires-Dist: simple-module-inertia==0.0.44
|
|
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.44"
|
|
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.44",
|
|
33
|
+
"simple_module_db==0.0.44",
|
|
34
|
+
"simple_module_inertia==0.0.44",
|
|
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.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_app_boot.py
RENAMED
|
@@ -13,6 +13,7 @@ from simple_module_core.menu import MenuRegistry
|
|
|
13
13
|
from simple_module_core.permissions import PermissionRegistry
|
|
14
14
|
from simple_module_core.public_routes import PublicRouteRegistry
|
|
15
15
|
from simple_module_db.listeners import register_listeners
|
|
16
|
+
from simple_module_db.query_stats import install_query_stats
|
|
16
17
|
from simple_module_db.session import init_db
|
|
17
18
|
|
|
18
19
|
from simple_module_hosting._db_health import register_database_check
|
|
@@ -93,6 +94,9 @@ def init_database(settings: Settings, health_registry: HealthRegistry):
|
|
|
93
94
|
if not settings.multi_tenant and settings.default_tenant:
|
|
94
95
|
db_state.default_tenant_id = settings.default_tenant
|
|
95
96
|
register_listeners(db_state)
|
|
97
|
+
if settings.is_development:
|
|
98
|
+
# Feeds the development Server-Timing header (query count per request).
|
|
99
|
+
install_query_stats(db_state.engine)
|
|
96
100
|
configure_process_services(settings.redis_url, engine=db_state.engine)
|
|
97
101
|
# The host's own readiness signal, and the only probe-safe check in a
|
|
98
102
|
# default install — module checks reach third parties and are on-demand.
|
{simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/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
|
|
@@ -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.42 → simple_module_hosting-0.0.44}/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
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Serialized catalogs owned by a registry and replaced with its snapshots."""
|
|
2
|
+
|
|
3
|
+
from weakref import WeakKeyDictionary
|
|
4
|
+
|
|
5
|
+
from simple_module_core.i18n import I18nRegistry
|
|
6
|
+
from simple_module_inertia._json_snapshot import JsonSnapshot
|
|
7
|
+
|
|
8
|
+
_catalogs: WeakKeyDictionary[
|
|
9
|
+
I18nRegistry, dict[tuple[str, bool], tuple[dict[str, str], JsonSnapshot]]
|
|
10
|
+
] = WeakKeyDictionary()
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def catalog_json(registry: I18nRegistry, locale: str, *, include_admin: bool) -> JsonSnapshot:
|
|
14
|
+
snapshot = registry.messages_snapshot(locale, include_admin=include_admin)
|
|
15
|
+
try:
|
|
16
|
+
pool = _catalogs.setdefault(registry, {})
|
|
17
|
+
except TypeError:
|
|
18
|
+
# A stub registry (``__slots__``, unhashable dataclass) cannot key a weak
|
|
19
|
+
# dict; serve it uncached rather than fail the request.
|
|
20
|
+
return JsonSnapshot(snapshot)
|
|
21
|
+
key = (locale, include_admin)
|
|
22
|
+
cached = pool.get(key)
|
|
23
|
+
# load() replaces snapshots: identity is the catalog version, without a hash
|
|
24
|
+
# or a walk of the catalog on the request path.
|
|
25
|
+
if cached is None or cached[0] is not snapshot:
|
|
26
|
+
cached = (snapshot, JsonSnapshot(snapshot))
|
|
27
|
+
pool[key] = cached
|
|
28
|
+
return cached[1]
|
|
@@ -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,18 +10,19 @@ 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
|
|
15
17
|
|
|
18
|
+
from simple_module_hosting._i18n_json import catalog_json
|
|
16
19
|
from simple_module_hosting.csrf import get_csrf_token
|
|
17
20
|
|
|
18
21
|
logger = logging.getLogger(__name__)
|
|
19
22
|
|
|
20
23
|
_I18N_SESSION_LOCALE_KEY = "__i18n_locale"
|
|
21
24
|
_I18N_SESSION_AUDIENCE_KEY = "__i18n_audience"
|
|
22
|
-
|
|
23
|
-
_INERTIA_HEADER_TRUE = "true"
|
|
25
|
+
I18N_CATALOG_HEADER = "X-SM-I18n"
|
|
24
26
|
#: Shared-prop key the frontend API client reads its ``X-CSRF-Token`` from (#504).
|
|
25
27
|
CSRF_SHARED_PROP = "csrfToken"
|
|
26
28
|
|
|
@@ -35,9 +37,9 @@ def build_i18n_block(scope: Scope, request: Request, *, is_authenticated: bool =
|
|
|
35
37
|
Rules:
|
|
36
38
|
|
|
37
39
|
* No registry / no locale → serve an empty English block and log once.
|
|
38
|
-
* Inertia
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
* Inertia visits (header presence) report their tab's cached catalog in
|
|
41
|
+
``X-SM-I18n: <locale>:<audience>``. Send messages only on a mismatch;
|
|
42
|
+
clients without that header retain the legacy session comparison.
|
|
41
43
|
* Full page loads and locale transitions ship the complete dict.
|
|
42
44
|
* Anonymous visitors receive the public snapshot: catalogs of modules
|
|
43
45
|
declaring ``i18n_audience="admin"`` are withheld (issue #248). A login
|
|
@@ -58,39 +60,28 @@ def build_i18n_block(scope: Scope, request: Request, *, is_authenticated: bool =
|
|
|
58
60
|
)
|
|
59
61
|
return {"locale": "en", "supportedLocales": ["en"], "messages": {}}
|
|
60
62
|
|
|
61
|
-
is_inertia =
|
|
63
|
+
is_inertia = is_inertia_request(scope)
|
|
62
64
|
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
|
|
65
|
+
cached_catalog = Headers(scope=scope).get(I18N_CATALOG_HEADER)
|
|
66
|
+
if cached_catalog is not None:
|
|
67
|
+
send_messages = not is_inertia or cached_catalog != f"{locale}:{audience}"
|
|
85
68
|
else:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
69
|
+
session = scope.get("session")
|
|
70
|
+
changed = session is not None and (
|
|
71
|
+
session.get(_I18N_SESSION_LOCALE_KEY) != locale
|
|
72
|
+
or session.get(_I18N_SESSION_AUDIENCE_KEY) != audience
|
|
73
|
+
)
|
|
74
|
+
# Legacy clients remember only page-shaped requests, never raw fetches.
|
|
75
|
+
if session is not None and (is_inertia or _accepts_html(scope)):
|
|
76
|
+
session[_I18N_SESSION_LOCALE_KEY] = locale
|
|
77
|
+
session[_I18N_SESSION_AUDIENCE_KEY] = audience
|
|
78
|
+
send_messages = not is_inertia or changed
|
|
89
79
|
return {
|
|
90
80
|
"locale": locale,
|
|
81
|
+
"audience": audience,
|
|
91
82
|
"supportedLocales": registry.available_locales(),
|
|
92
83
|
"messages": (
|
|
93
|
-
registry
|
|
84
|
+
catalog_json(registry, locale, include_admin=is_authenticated)
|
|
94
85
|
if send_messages
|
|
95
86
|
else None
|
|
96
87
|
),
|
|
@@ -116,9 +107,8 @@ def lazy_csrf_shared_prop(
|
|
|
116
107
|
) -> dict[str, Callable[[], str]]:
|
|
117
108
|
"""Like :func:`csrf_shared_prop`, but the token is resolved at render time.
|
|
118
109
|
|
|
119
|
-
The
|
|
120
|
-
|
|
121
|
-
``Set-Cookie``) on responses that have no use for the token. Inertia calls
|
|
110
|
+
The token stays lazy even after layout resolution, so an Inertia partial
|
|
111
|
+
that excludes it does not mint an unused session token. Inertia calls
|
|
122
112
|
the callable only when it serialises props.
|
|
123
113
|
"""
|
|
124
114
|
if not is_authenticated or request.scope.get("session") is None:
|
|
@@ -191,3 +181,16 @@ def default_home_url(app: Any) -> str:
|
|
|
191
181
|
sm = get_services(app)
|
|
192
182
|
prefix = getattr(sm, "view_prefixes", {}).get("Dashboard")
|
|
193
183
|
return f"{prefix}/" if prefix else "/"
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
async def resolve_inertia_shared(request: Request) -> dict:
|
|
187
|
+
"""Build layout props once on demand, keeping the resolved state dict public."""
|
|
188
|
+
factory = getattr(request.state, "inertia_shared_factory", None)
|
|
189
|
+
if factory is not None:
|
|
190
|
+
task = getattr(request.state, "inertia_shared_task", None)
|
|
191
|
+
if task is None:
|
|
192
|
+
context = getattr(request.state, "inertia_shared_context", None)
|
|
193
|
+
task = asyncio.create_task(factory(), context=context)
|
|
194
|
+
request.state.inertia_shared_task = task
|
|
195
|
+
request.state.inertia_shared = await task
|
|
196
|
+
return getattr(request.state, "inertia_shared", None) or {}
|
{simple_module_hosting-0.0.42 → simple_module_hosting-0.0.44}/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.42 → simple_module_hosting-0.0.44}/simple_module_hosting/_lifespan.py
RENAMED
|
@@ -30,67 +30,35 @@ logger = logging.getLogger(__name__)
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
async def _is_first_run(app: FastAPI) -> bool:
|
|
33
|
-
"""Whether this install has never been set up
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
Treating the second as "setup mode" is wrong twice over. It serves traffic
|
|
46
|
-
against a schema the code does not match — the failure ``SM010`` exists to
|
|
47
|
-
prevent — and it re-opens ``/setup``, whose migration endpoint is
|
|
48
|
-
unauthenticated, letting an anonymous request trigger an Alembic run on a
|
|
49
|
-
live system.
|
|
50
|
-
|
|
51
|
-
So: first run means *something other than the schema* is also outstanding.
|
|
52
|
-
``False`` when no registry exists, since an app built outside
|
|
53
|
-
``create_app`` has no steps to reason about and the old raising behaviour
|
|
54
|
-
is the safer default there.
|
|
55
|
-
|
|
56
|
-
Deliberately does not delegate to ``registry.incomplete()``: that method
|
|
57
|
-
treats a step whose predicate raises as *complete*, which is right for
|
|
58
|
-
``SetupMiddleware``'s steady-state gate (a transient DB error must not
|
|
59
|
-
lock a working install out) but wrong here. On a genuinely fresh
|
|
60
|
-
database the non-migration steps' own tables don't exist yet — the
|
|
61
|
-
administrator check is a query against a table migrations create — so it
|
|
62
|
-
raises too, and swallowing that would make every step but the schema
|
|
63
|
-
look satisfied, exactly the "is setup complete" trap this function
|
|
64
|
-
exists to avoid. A required step raising counts as pending only with
|
|
65
|
-
positive evidence the install is new: the database has never been
|
|
66
|
-
migrated at all (no ``alembic_version``). On a database with migration
|
|
67
|
-
history the same exception is far more likely a transient error on an
|
|
68
|
-
established install, and treating that as first run would serve the
|
|
69
|
-
unauthenticated migration endpoint on a live system — so boot fails
|
|
70
|
-
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).
|
|
71
44
|
"""
|
|
72
45
|
registry = getattr(app.state.sm, "setup_registry", None)
|
|
73
|
-
|
|
46
|
+
migration = get_migration_status(app)
|
|
47
|
+
if not registry or migration is None or migration.get("current_revision", "") is not None:
|
|
74
48
|
return False
|
|
75
49
|
for step in registry.required_steps:
|
|
76
50
|
if step.id == STEP_MIGRATIONS:
|
|
77
51
|
continue
|
|
78
52
|
try:
|
|
79
|
-
|
|
53
|
+
if await step.is_complete(app):
|
|
54
|
+
return False
|
|
80
55
|
except Exception:
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
step.id,
|
|
88
|
-
exc_info=True,
|
|
89
|
-
)
|
|
90
|
-
return never_migrated
|
|
91
|
-
if not done:
|
|
92
|
-
return True
|
|
93
|
-
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
|
|
94
62
|
|
|
95
63
|
|
|
96
64
|
def build_lifespan(modules: Sequence) -> Callable:
|
|
@@ -105,8 +73,7 @@ def build_lifespan(modules: Sequence) -> Callable:
|
|
|
105
73
|
# running the migrations is one of the things that wizard does, and
|
|
106
74
|
# check_migrations' RuntimeError would make it unreachable. Anywhere
|
|
107
75
|
# else the original behaviour stands: a schema the code does not match
|
|
108
|
-
# fails the boot. See _is_first_run for
|
|
109
|
-
# told apart by "is setup complete".
|
|
76
|
+
# fails the boot. See _is_first_run for how the two are told apart.
|
|
110
77
|
app.state.migration = await migration_status(app.state.sm.db.engine)
|
|
111
78
|
if not app.state.migration["is_current"] and not await _is_first_run(app):
|
|
112
79
|
raise RuntimeError(
|
|
@@ -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,9 +16,9 @@ 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
|
+
from simple_module_hosting._server_timing import ServerTimingMiddleware
|
|
21
22
|
from simple_module_hosting.i18n_middleware import LocaleMiddleware
|
|
22
23
|
from simple_module_hosting.maintenance import MaintenanceMiddleware
|
|
23
24
|
from simple_module_hosting.middleware import (
|
|
@@ -87,44 +88,30 @@ def install_middleware(
|
|
|
87
88
|
|
|
88
89
|
Order matters: last added = first executed. Execution order:
|
|
89
90
|
(ForwardedHost, if trusted_proxy and forwarded_host_allowlist) →
|
|
90
|
-
(ProxyHeaders, if trusted_proxy) → CorrelationId → RequestLogging →
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
→
|
|
91
|
+
(ProxyHeaders, if trusted_proxy) → CorrelationId → RequestLogging →
|
|
92
|
+
(ServerTiming, development only) → CORS → BodyLimit → GZip → Security →
|
|
93
|
+
Session → InertiaMiddleware → [module] →
|
|
94
|
+
(Tenant, if multi_tenant) → Locale → InertiaLayoutData →
|
|
95
|
+
RateLimit → Setup → Maintenance → CommitBeforeResponse.
|
|
94
96
|
"""
|
|
95
97
|
# Added first, so it is innermost and its send-wrapper is the first to see
|
|
96
98
|
# the response: the request's DB work commits before any byte reaches the
|
|
97
99
|
# client, instead of in get_db's post-response exit code (GH #257).
|
|
98
100
|
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.
|
|
101
|
+
# Auth, locale and lazy layout resolution must precede the maintenance page.
|
|
102
|
+
# The outer adapter middleware applies protocol and cache rules to it: the
|
|
103
|
+
# 503 renders through Inertia with this user's auth block and menus, so it
|
|
104
|
+
# must stay non-cacheable like any other payload (GH #272).
|
|
107
105
|
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.
|
|
106
|
+
# An install awaiting setup takes precedence over maintenance mode.
|
|
113
107
|
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.
|
|
108
|
+
# Auth and locale are available when rendering a rate-limit error page.
|
|
117
109
|
app.add_middleware(
|
|
118
110
|
RateLimitMiddleware,
|
|
119
111
|
public_rate=settings.rate_limit_public,
|
|
120
112
|
authenticated_rate=settings.rate_limit_authenticated,
|
|
121
113
|
store=rate_limit_store,
|
|
122
114
|
)
|
|
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
115
|
app.add_middleware(
|
|
129
116
|
InertiaLayoutDataMiddleware,
|
|
130
117
|
menu_registry=menu_registry,
|
|
@@ -144,6 +131,11 @@ def install_middleware(
|
|
|
144
131
|
app.add_middleware(TenantMiddleware, fixed=settings.default_tenant)
|
|
145
132
|
for mod in modules:
|
|
146
133
|
mod.register_middleware(app)
|
|
134
|
+
# Outside every module middleware and the cache guard, so it normalises
|
|
135
|
+
# the final response — including redirects a module middleware issues
|
|
136
|
+
# itself (an expired session's login redirect after a DELETE must still
|
|
137
|
+
# become a 303) — while Session, further out, still sees its result.
|
|
138
|
+
app.add_middleware(InertiaMiddleware)
|
|
147
139
|
app.add_middleware(
|
|
148
140
|
SessionMiddleware,
|
|
149
141
|
secret_key=settings.secret_key,
|
|
@@ -184,6 +176,10 @@ def install_middleware(
|
|
|
184
176
|
if api_policy is not None:
|
|
185
177
|
cors_registry.add_prefix(API_PREFIX, api_policy)
|
|
186
178
|
app.add_middleware(CorsMiddleware, registry=cors_registry)
|
|
179
|
+
if settings.is_development:
|
|
180
|
+
# Inside RequestLogging, outside everything that does work: its ``app``
|
|
181
|
+
# time covers the whole pipeline and every query the request ran.
|
|
182
|
+
app.add_middleware(ServerTimingMiddleware)
|
|
187
183
|
app.add_middleware(RequestLoggingMiddleware)
|
|
188
184
|
app.add_middleware(CorrelationIdMiddleware)
|
|
189
185
|
if sentry.is_enabled():
|