simple-module-core 0.0.49__tar.gz → 0.0.51__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_core-0.0.49 → simple_module_core-0.0.51}/PKG-INFO +2 -2
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/README.md +1 -1
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/pyproject.toml +1 -1
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/simple_module_core/__init__.py +50 -37
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/simple_module_core/__main__.py +34 -16
- simple_module_core-0.0.51/simple_module_core/access/__init__.py +1 -0
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/access}/_permission_grants.py +1 -1
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/access}/file_access.py +1 -1
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/access}/permissions.py +2 -2
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/access}/principal_permissions.py +3 -3
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/access}/principals.py +2 -2
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/access}/resources.py +2 -2
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/access}/role_directory.py +1 -1
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/access}/tenancy.py +64 -3
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/access}/user_directory.py +22 -1
- simple_module_core-0.0.51/simple_module_core/activity_feed.py +13 -0
- simple_module_core-0.0.51/simple_module_core/app_state.py +11 -0
- simple_module_core-0.0.51/simple_module_core/audit_links.py +11 -0
- simple_module_core-0.0.51/simple_module_core/body_limits.py +11 -0
- simple_module_core-0.0.51/simple_module_core/correlation.py +13 -0
- simple_module_core-0.0.51/simple_module_core/cors.py +9 -0
- simple_module_core-0.0.51/simple_module_core/crypto.py +11 -0
- simple_module_core-0.0.51/simple_module_core/csp.py +9 -0
- simple_module_core-0.0.51/simple_module_core/data_compatibility.py +13 -0
- simple_module_core-0.0.51/simple_module_core/datetimes.py +11 -0
- simple_module_core-0.0.51/simple_module_core/deprecation.py +13 -0
- simple_module_core-0.0.51/simple_module_core/design_packs.py +11 -0
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/simple_module_core/diagnostics/_auth.py +2 -2
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/simple_module_core/diagnostics/_coupling.py +1 -1
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/simple_module_core/diagnostics/_css.py +1 -1
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/diagnostics}/_data_doctor.py +3 -3
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/simple_module_core/diagnostics/_db_extensions.py +1 -1
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/simple_module_core/diagnostics/_dependencies.py +2 -2
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/simple_module_core/diagnostics/_durable_names.py +1 -1
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/simple_module_core/diagnostics/_expression_index.py +2 -2
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/simple_module_core/diagnostics/_heavy_task_imports.py +1 -1
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/simple_module_core/diagnostics/_i18n.py +3 -3
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/simple_module_core/diagnostics/_inertia_api.py +1 -1
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/simple_module_core/diagnostics/_js_workspace.py +1 -1
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/simple_module_core/diagnostics/_migration.py +1 -1
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/diagnostics}/_migration_doctor.py +3 -3
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/simple_module_core/diagnostics/_module.py +10 -8
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/simple_module_core/diagnostics/_pages.py +89 -35
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/simple_module_core/diagnostics/_runner.py +1 -1
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/simple_module_core/diagnostics/_spa_mount.py +1 -1
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/simple_module_core/diagnostics/_tenancy.py +2 -2
- simple_module_core-0.0.51/simple_module_core/discovery.py +11 -0
- simple_module_core-0.0.51/simple_module_core/dotenv.py +11 -0
- simple_module_core-0.0.51/simple_module_core/durable_events.py +13 -0
- simple_module_core-0.0.51/simple_module_core/environments.py +13 -0
- simple_module_core-0.0.51/simple_module_core/eventing/__init__.py +1 -0
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/eventing}/_invalidation_message.py +1 -1
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/eventing}/events.py +32 -6
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/eventing}/invalidation.py +2 -2
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/eventing}/invalidation_refresh.py +1 -1
- simple_module_core-0.0.51/simple_module_core/events.py +11 -0
- simple_module_core-0.0.51/simple_module_core/exceptions.py +11 -0
- simple_module_core-0.0.51/simple_module_core/feature_flags.py +13 -0
- simple_module_core-0.0.51/simple_module_core/file_access.py +13 -0
- simple_module_core-0.0.51/simple_module_core/health.py +11 -0
- simple_module_core-0.0.51/simple_module_core/i18n.py +11 -0
- simple_module_core-0.0.51/simple_module_core/invalidation.py +13 -0
- simple_module_core-0.0.51/simple_module_core/invalidation_refresh.py +13 -0
- simple_module_core-0.0.51/simple_module_core/leases.py +11 -0
- simple_module_core-0.0.51/simple_module_core/localization/__init__.py +1 -0
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/localization}/_i18n_translator.py +3 -3
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/localization}/i18n.py +3 -3
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/localization}/i18n_overrides.py +1 -1
- simple_module_core-0.0.51/simple_module_core/mail.py +11 -0
- simple_module_core-0.0.51/simple_module_core/mailer/__init__.py +1 -0
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/mailer}/_mail_headers.py +21 -0
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/mailer}/mail.py +2 -12
- simple_module_core-0.0.51/simple_module_core/menu.py +9 -0
- simple_module_core-0.0.51/simple_module_core/migration_support/__init__.py +13 -0
- simple_module_core-0.0.51/simple_module_core/migrations/__init__.py +1 -0
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/migrations}/data_compatibility.py +3 -3
- simple_module_core-0.0.49/simple_module_core/migration_support/__init__.py → simple_module_core-0.0.51/simple_module_core/migrations/support.py +4 -1
- simple_module_core-0.0.51/simple_module_core/module.py +11 -0
- simple_module_core-0.0.51/simple_module_core/module_meta.py +13 -0
- simple_module_core-0.0.51/simple_module_core/module_settings.py +13 -0
- simple_module_core-0.0.51/simple_module_core/modules/__init__.py +1 -0
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/modules}/_auth_providers.py +2 -2
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/modules}/_module_conventions.py +1 -1
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/modules}/_module_ordering.py +3 -3
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/modules}/_request_hooks.py +6 -6
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/modules}/app_state.py +27 -11
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/modules}/discovery.py +10 -10
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/modules}/module.py +22 -17
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/modules}/module_meta.py +1 -1
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/modules}/services.py +17 -17
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/modules}/versioning.py +2 -2
- simple_module_core-0.0.51/simple_module_core/permission_denied.py +13 -0
- simple_module_core-0.0.51/simple_module_core/permissions.py +13 -0
- simple_module_core-0.0.51/simple_module_core/principal_permissions.py +13 -0
- simple_module_core-0.0.51/simple_module_core/principals.py +11 -0
- simple_module_core-0.0.51/simple_module_core/public_routes.py +13 -0
- simple_module_core-0.0.51/simple_module_core/rate_limit.py +11 -0
- simple_module_core-0.0.51/simple_module_core/redirect_safety.py +13 -0
- simple_module_core-0.0.51/simple_module_core/resources.py +11 -0
- simple_module_core-0.0.51/simple_module_core/role_directory.py +13 -0
- simple_module_core-0.0.51/simple_module_core/runtime/__init__.py +1 -0
- simple_module_core-0.0.51/simple_module_core/runtime/_lease_memory.py +73 -0
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/runtime}/correlation.py +1 -1
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/runtime}/deprecation.py +1 -1
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/runtime}/leases.py +23 -61
- simple_module_core-0.0.51/simple_module_core/secret_fields.py +13 -0
- simple_module_core-0.0.51/simple_module_core/services.py +11 -0
- simple_module_core-0.0.51/simple_module_core/settings/__init__.py +1 -0
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/settings}/module_settings.py +1 -1
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/settings}/secret_fields.py +38 -1
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/settings}/settings_hydrate.py +2 -2
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/settings}/stored_settings.py +1 -1
- simple_module_core-0.0.51/simple_module_core/settings/url_validation.py +32 -0
- simple_module_core-0.0.51/simple_module_core/settings_base.py +13 -0
- simple_module_core-0.0.51/simple_module_core/settings_hydrate.py +13 -0
- simple_module_core-0.0.51/simple_module_core/setup_steps.py +11 -0
- simple_module_core-0.0.51/simple_module_core/singleflight.py +13 -0
- simple_module_core-0.0.51/simple_module_core/spa_mount.py +11 -0
- simple_module_core-0.0.51/simple_module_core/stored_settings.py +13 -0
- simple_module_core-0.0.51/simple_module_core/tenancy.py +11 -0
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/simple_module_core/tenant_events.py +1 -1
- simple_module_core-0.0.51/simple_module_core/user_directory.py +13 -0
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/simple_module_core/user_events.py +9 -1
- simple_module_core-0.0.51/simple_module_core/versioning.py +11 -0
- simple_module_core-0.0.51/simple_module_core/web/__init__.py +1 -0
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/web}/admin_surface.py +2 -2
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/web}/audit_links.py +15 -1
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/web}/body_limits.py +2 -2
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/web}/cors.py +2 -2
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/web}/csp.py +83 -2
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/web}/design_packs.py +1 -1
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/web}/feature_flags.py +7 -6
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/web}/menu.py +1 -1
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/web}/path_rules.py +1 -1
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/web}/public_routes.py +2 -2
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/web}/rate_limit.py +1 -1
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/web}/setup_steps.py +1 -1
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/web}/spa_mount.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/access}/test_core_role_directory.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/access}/test_core_user_directory.py +27 -2
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/access}/test_permission_catalogue.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/access}/test_permission_sources.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/access}/test_permissions.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/access}/test_permissions_admin_principal.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/access}/test_principal_composition.py +2 -2
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/access}/test_tenant_exists.py +1 -1
- simple_module_core-0.0.51/tests/access/test_tenant_slug.py +21 -0
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/diagnostics}/test_admin_surface_diagnostics.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/diagnostics}/test_core_data_compatibility_doctor.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/diagnostics}/test_diagnostics.py +3 -3
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/diagnostics}/test_expression_index_diagnostics.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/diagnostics}/test_module_diagnostics.py +7 -7
- simple_module_core-0.0.51/tests/diagnostics/test_module_doctor_hook.py +77 -0
- simple_module_core-0.0.51/tests/diagnostics/test_sm003_imported_constants.py +169 -0
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/diagnostics}/test_sm003_page_render.py +22 -16
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/diagnostics}/test_sm009_dynamic_coupling.py +2 -2
- simple_module_core-0.0.51/tests/diagnostics/test_sm012_settings_registration.py +128 -0
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/eventing}/test_core_inline_delivery_context.py +2 -2
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/eventing}/test_core_invalidation_refresh.py +3 -3
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/eventing}/test_durable_events.py +3 -3
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/eventing}/test_events.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/eventing}/test_events_inline.py +2 -2
- simple_module_core-0.0.51/tests/eventing/test_events_sync_handlers.py +139 -0
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/eventing}/test_invalidation.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/eventing}/test_invalidation_dedup.py +2 -2
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/eventing}/test_invalidation_handlers.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/localization}/test_i18n.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/localization}/test_i18n_overrides.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/mailer}/test_core_mail_resolution.py +3 -3
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/mailer}/test_mail_attachments.py +3 -3
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/mailer}/test_mail_headers.py +3 -3
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/mailer}/test_mail_reply_to.py +4 -3
- simple_module_core-0.0.51/tests/migrations/test_resolve_project_root.py +107 -0
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/modules}/test_auth_provider_capability.py +2 -2
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/modules}/test_auth_provider_selection.py +5 -5
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/modules}/test_core_app_state.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/modules}/test_core_discovery_stale_sys_path.py +4 -4
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/modules}/test_core_lifecycle_docs.py +2 -2
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/modules}/test_discovery.py +6 -6
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/modules}/test_discovery_missing_deps.py +5 -5
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/modules}/test_discovery_selection.py +4 -4
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/modules}/test_module_base.py +10 -10
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/modules}/test_module_defaults.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/modules}/test_module_discovery_versions.py +3 -3
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/modules}/test_services.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/modules}/test_versioning.py +7 -7
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/runtime}/test_core_datetimes.py +1 -1
- simple_module_core-0.0.51/tests/runtime/test_core_layout_shims.py +54 -0
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/runtime}/test_core_leases.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/runtime}/test_core_singleflight.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/runtime}/test_deprecation_helper.py +2 -2
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/runtime}/test_key_derivation.py +2 -2
- simple_module_core-0.0.51/tests/runtime/test_lease_listeners.py +131 -0
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/settings}/test_core_module_settings.py +4 -4
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/settings}/test_core_settings_source_cache.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/settings}/test_dotenv.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/settings}/test_environments.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/settings}/test_settings_base.py +37 -2
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/web}/test_admin_surface.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/web}/test_audit_links.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/web}/test_csp_registry.py +56 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/web}/test_design_packs.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/web}/test_feature_flags.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/web}/test_feature_flags_decorator.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/web}/test_health_registry.py +6 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/web}/test_menu.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/web}/test_path_rule_registries.py +2 -2
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/web}/test_public_routes.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/web}/test_public_routes_rate_precedence.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/web}/test_redirect_safety.py +1 -1
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/web}/test_registry_overrides.py +9 -5
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/.gitignore +0 -0
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/LICENSE +0 -0
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/access}/activity_feed.py +0 -0
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/access}/permission_catalogue.py +0 -0
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/access}/permission_denied.py +0 -0
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/simple_module_core/diagnostics/__init__.py +0 -0
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/simple_module_core/diagnostics/_types.py +0 -0
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/eventing}/durable_events.py +0 -0
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/localization}/_i18n_flatten.py +0 -0
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/modules}/_entry_point_errors.py +0 -0
- {simple_module_core-0.0.49 → simple_module_core-0.0.51}/simple_module_core/py.typed +0 -0
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/runtime}/crypto.py +0 -0
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/runtime}/datetimes.py +0 -0
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/runtime}/exceptions.py +0 -0
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/runtime}/singleflight.py +0 -0
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/settings}/dotenv.py +0 -0
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/settings}/environments.py +0 -0
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/settings}/settings_base.py +0 -0
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/web}/health.py +0 -0
- {simple_module_core-0.0.49/simple_module_core → simple_module_core-0.0.51/simple_module_core/web}/redirect_safety.py +0 -0
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/access}/test_tenant_roles.py +0 -0
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/diagnostics}/test_css_diagnostics.py +0 -0
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/diagnostics}/test_css_scanner.py +0 -0
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/diagnostics}/test_db_extensions_diagnostics.py +0 -0
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/diagnostics}/test_diagnostics_encoding.py +0 -0
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/diagnostics}/test_diagnostics_fd_output.py +0 -0
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/diagnostics}/test_diagnostics_output.py +0 -0
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/diagnostics}/test_diagnostics_tenancy.py +0 -0
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/diagnostics}/test_doctor_cli_overrides.py +0 -0
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/diagnostics}/test_heavy_task_imports_diagnostics.py +0 -0
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/diagnostics}/test_i18n_diagnostics.py +0 -0
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/diagnostics}/test_sm034_durable_names.py +0 -0
- {simple_module_core-0.0.49/tests → simple_module_core-0.0.51/tests/modules}/test_module_package_conventions.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: simple_module_core
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.51
|
|
4
4
|
Summary: Module-system primitives for the simple_module framework — ModuleBase, discovery, diagnostics, events
|
|
5
5
|
Project-URL: Homepage, https://github.com/antosubash/simple_module_python
|
|
6
6
|
Project-URL: Repository, https://github.com/antosubash/simple_module_python
|
|
@@ -51,7 +51,7 @@ You usually don't install this directly — it's pulled in by `simple_module_hos
|
|
|
51
51
|
- `ModuleMeta` — required `meta = ModuleMeta(name=..., depends_on=...)` attribute on each module.
|
|
52
52
|
- `discover_modules()` — loads all `[project.entry-points.simple_module]` modules, topologically sorts by `depends_on`.
|
|
53
53
|
- Diagnostic registry — `SM001` missing meta, `SM003` orphan page, `SM008` duplicate name, `SM009` framework→plugin coupling violation, and the rest of the `SM0xx` set through `SM025`.
|
|
54
|
-
- Tenant-role vocabulary (`simple_module_core.tenancy`) — `TenantRole`, `TENANT_ROLE_PREFIX`, `tenant_role()`, so any module can map `tenant:<role>` onto its permissions without depending on `tenants`.
|
|
54
|
+
- Tenant-role vocabulary (`simple_module_core.access.tenancy`) — `TenantRole`, `TENANT_ROLE_PREFIX`, `tenant_role()`, so any module can map `tenant:<role>` onto its permissions without depending on `tenants`.
|
|
55
55
|
- Tiny event-bus (`pyee`) for decoupled module-to-module communication.
|
|
56
56
|
|
|
57
57
|
## Usage
|
|
@@ -18,7 +18,7 @@ You usually don't install this directly — it's pulled in by `simple_module_hos
|
|
|
18
18
|
- `ModuleMeta` — required `meta = ModuleMeta(name=..., depends_on=...)` attribute on each module.
|
|
19
19
|
- `discover_modules()` — loads all `[project.entry-points.simple_module]` modules, topologically sorts by `depends_on`.
|
|
20
20
|
- Diagnostic registry — `SM001` missing meta, `SM003` orphan page, `SM008` duplicate name, `SM009` framework→plugin coupling violation, and the rest of the `SM0xx` set through `SM025`.
|
|
21
|
-
- Tenant-role vocabulary (`simple_module_core.tenancy`) — `TenantRole`, `TENANT_ROLE_PREFIX`, `tenant_role()`, so any module can map `tenant:<role>` onto its permissions without depending on `tenants`.
|
|
21
|
+
- Tenant-role vocabulary (`simple_module_core.access.tenancy`) — `TenantRole`, `TENANT_ROLE_PREFIX`, `tenant_role()`, so any module can map `tenant:<role>` onto its permissions without depending on `tenants`.
|
|
22
22
|
- Tiny event-bus (`pyee`) for decoupled module-to-module communication.
|
|
23
23
|
|
|
24
24
|
## Usage
|
|
@@ -1,19 +1,39 @@
|
|
|
1
1
|
"""SimpleModule Core - Module system, menu, permissions, events, and diagnostics."""
|
|
2
2
|
|
|
3
|
-
from simple_module_core.
|
|
4
|
-
from simple_module_core.
|
|
5
|
-
from simple_module_core.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
from simple_module_core.access.permissions import PermissionCatalogue, PermissionRegistry
|
|
4
|
+
from simple_module_core.access.principals import PrincipalRegistry
|
|
5
|
+
from simple_module_core.access.resources import (
|
|
6
|
+
ResourcePolicy,
|
|
7
|
+
ResourcePrincipal,
|
|
8
|
+
ResourceType,
|
|
9
|
+
ResourceTypeRegistry,
|
|
10
|
+
)
|
|
11
|
+
from simple_module_core.access.tenancy import (
|
|
12
|
+
TENANT_ROLE_PREFIX,
|
|
13
|
+
TenantRole,
|
|
14
|
+
is_tenant_role,
|
|
15
|
+
tenant_role,
|
|
16
|
+
)
|
|
10
17
|
from simple_module_core.diagnostics import (
|
|
11
18
|
DiagnosticLevel,
|
|
12
19
|
MigrationDiagnostics,
|
|
13
20
|
print_diagnostics,
|
|
14
21
|
run_diagnostics,
|
|
15
22
|
)
|
|
16
|
-
from simple_module_core.
|
|
23
|
+
from simple_module_core.eventing.durable_events import (
|
|
24
|
+
DurableContext,
|
|
25
|
+
DurableDeliveryUnavailable,
|
|
26
|
+
DurableTransport,
|
|
27
|
+
)
|
|
28
|
+
from simple_module_core.eventing.events import Event, EventBus
|
|
29
|
+
from simple_module_core.eventing.invalidation import (
|
|
30
|
+
Invalidation,
|
|
31
|
+
InvalidationBus,
|
|
32
|
+
InvalidationTransport,
|
|
33
|
+
)
|
|
34
|
+
from simple_module_core.localization.i18n import I18nRegistry, Translator
|
|
35
|
+
from simple_module_core.migrations.data_compatibility import DataCompatibilityIssue
|
|
36
|
+
from simple_module_core.modules.discovery import (
|
|
17
37
|
DEFAULT_AUTH_PROVIDER,
|
|
18
38
|
discover_modules,
|
|
19
39
|
get_module_package_name,
|
|
@@ -22,13 +42,13 @@ from simple_module_core.discovery import (
|
|
|
22
42
|
select_auth_provider,
|
|
23
43
|
topological_sort,
|
|
24
44
|
)
|
|
25
|
-
from simple_module_core.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
45
|
+
from simple_module_core.modules.module import ModuleBase, ModuleMeta
|
|
46
|
+
from simple_module_core.modules.services import Services
|
|
47
|
+
from simple_module_core.modules.versioning import (
|
|
48
|
+
FRAMEWORK_API_VERSION,
|
|
49
|
+
check_framework_compatibility,
|
|
29
50
|
)
|
|
30
|
-
from simple_module_core.
|
|
31
|
-
from simple_module_core.exceptions import (
|
|
51
|
+
from simple_module_core.runtime.exceptions import (
|
|
32
52
|
CircularDependencyError,
|
|
33
53
|
FrameworkVersionError,
|
|
34
54
|
InvalidModuleError,
|
|
@@ -37,7 +57,13 @@ from simple_module_core.exceptions import (
|
|
|
37
57
|
NotFoundError,
|
|
38
58
|
ValidationError,
|
|
39
59
|
)
|
|
40
|
-
from simple_module_core.
|
|
60
|
+
from simple_module_core.web.admin_surface import AdminSurface
|
|
61
|
+
from simple_module_core.web.audit_links import AuditLink, AuditLinkRegistry, LabelResolver
|
|
62
|
+
from simple_module_core.web.body_limits import BodyLimitRegistry
|
|
63
|
+
from simple_module_core.web.cors import CorsPolicy, CorsPolicyRegistry
|
|
64
|
+
from simple_module_core.web.csp import CspSourceError, CspSourceRegistry
|
|
65
|
+
from simple_module_core.web.design_packs import DesignPack, DesignPackRegistry
|
|
66
|
+
from simple_module_core.web.feature_flags import (
|
|
41
67
|
FeatureFlagDefinition,
|
|
42
68
|
FeatureFlagRegistry,
|
|
43
69
|
feature_flag,
|
|
@@ -45,29 +71,16 @@ from simple_module_core.feature_flags import (
|
|
|
45
71
|
is_flag_enabled,
|
|
46
72
|
require_flag,
|
|
47
73
|
)
|
|
48
|
-
from simple_module_core.health import
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
InvalidationTransport,
|
|
54
|
-
)
|
|
55
|
-
from simple_module_core.menu import MenuItem, MenuRegistry, MenuSection
|
|
56
|
-
from simple_module_core.module import ModuleBase, ModuleMeta
|
|
57
|
-
from simple_module_core.permissions import PermissionCatalogue, PermissionRegistry
|
|
58
|
-
from simple_module_core.principals import PrincipalRegistry
|
|
59
|
-
from simple_module_core.public_routes import PublicRoute, PublicRouteRegistry
|
|
60
|
-
from simple_module_core.resources import (
|
|
61
|
-
ResourcePolicy,
|
|
62
|
-
ResourcePrincipal,
|
|
63
|
-
ResourceType,
|
|
64
|
-
ResourceTypeRegistry,
|
|
74
|
+
from simple_module_core.web.health import (
|
|
75
|
+
HealthCheck,
|
|
76
|
+
HealthCheckResult,
|
|
77
|
+
HealthRegistry,
|
|
78
|
+
HealthStatus,
|
|
65
79
|
)
|
|
66
|
-
from simple_module_core.
|
|
67
|
-
from simple_module_core.
|
|
68
|
-
from simple_module_core.
|
|
69
|
-
from simple_module_core.
|
|
70
|
-
from simple_module_core.versioning import FRAMEWORK_API_VERSION, check_framework_compatibility
|
|
80
|
+
from simple_module_core.web.menu import MenuItem, MenuRegistry, MenuSection
|
|
81
|
+
from simple_module_core.web.public_routes import PublicRoute, PublicRouteRegistry
|
|
82
|
+
from simple_module_core.web.setup_steps import SetupAction, SetupField, SetupRegistry, SetupStep
|
|
83
|
+
from simple_module_core.web.spa_mount import SpaMount
|
|
71
84
|
|
|
72
85
|
__all__ = [
|
|
73
86
|
"DEFAULT_AUTH_PROVIDER",
|
|
@@ -24,25 +24,25 @@ import os
|
|
|
24
24
|
import sys
|
|
25
25
|
from pathlib import Path
|
|
26
26
|
|
|
27
|
-
from simple_module_core._data_doctor import data_compatibility_diagnostics
|
|
28
|
-
from simple_module_core._migration_doctor import migration_diagnostics
|
|
29
27
|
from simple_module_core.diagnostics import (
|
|
30
28
|
Diagnostic,
|
|
31
29
|
DiagnosticLevel,
|
|
32
30
|
print_diagnostics,
|
|
33
31
|
run_diagnostics,
|
|
34
32
|
)
|
|
33
|
+
from simple_module_core.diagnostics._data_doctor import data_compatibility_diagnostics
|
|
35
34
|
from simple_module_core.diagnostics._dependencies import CODE as MISSING_DEPENDENCY_CODE
|
|
36
35
|
from simple_module_core.diagnostics._expression_index import sqlite_file_index_names
|
|
37
36
|
from simple_module_core.diagnostics._i18n import unknown_overrides_for
|
|
38
|
-
from simple_module_core.
|
|
37
|
+
from simple_module_core.diagnostics._migration_doctor import migration_diagnostics
|
|
38
|
+
from simple_module_core.modules.discovery import (
|
|
39
39
|
discover_modules,
|
|
40
40
|
resolve_auth_provider,
|
|
41
41
|
select_auth_provider,
|
|
42
42
|
topological_sort,
|
|
43
43
|
)
|
|
44
|
-
from simple_module_core.
|
|
45
|
-
from simple_module_core.
|
|
44
|
+
from simple_module_core.runtime.exceptions import InvalidModuleError
|
|
45
|
+
from simple_module_core.settings.dotenv import absolutize_sqlite_url, find_env_file, parse_dotenv
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
def _load_i18n_settings_from_env() -> tuple[list[str] | None, str]:
|
|
@@ -88,13 +88,8 @@ def _database_url() -> str:
|
|
|
88
88
|
return absolutize_sqlite_url(url, anchor=find_env_file().parent)
|
|
89
89
|
|
|
90
90
|
|
|
91
|
-
def _database_dialect() -> str:
|
|
92
|
-
"""
|
|
93
|
-
|
|
94
|
-
Defaults to ``sqlite`` like ``Settings.database_url``. Reads the env var
|
|
95
|
-
directly for the same reason the i18n settings do: no hosting import.
|
|
96
|
-
"""
|
|
97
|
-
url = _database_url()
|
|
91
|
+
def _database_dialect(url: str) -> str:
|
|
92
|
+
"""Extract the dialect without importing the hosting settings."""
|
|
98
93
|
return url.split(":", 1)[0].split("+", 1)[0]
|
|
99
94
|
|
|
100
95
|
|
|
@@ -188,18 +183,41 @@ def main() -> int:
|
|
|
188
183
|
|
|
189
184
|
unknown_overrides, override_findings = unknown_overrides_for(modules, extra, supported, default)
|
|
190
185
|
|
|
186
|
+
database_url = _database_url()
|
|
191
187
|
diagnostics = run_diagnostics(
|
|
192
188
|
modules,
|
|
193
189
|
i18n_supported_locales=supported,
|
|
194
190
|
i18n_default_locale=default,
|
|
195
191
|
i18n_extra_sources=extra,
|
|
196
192
|
i18n_unknown_overrides=unknown_overrides,
|
|
197
|
-
database_dialect=_database_dialect(),
|
|
198
|
-
existing_index_names=sqlite_file_index_names(
|
|
193
|
+
database_dialect=_database_dialect(database_url),
|
|
194
|
+
existing_index_names=sqlite_file_index_names(database_url),
|
|
199
195
|
)
|
|
200
196
|
diagnostics.extend(override_findings)
|
|
201
|
-
diagnostics.extend(migration_diagnostics(modules,
|
|
202
|
-
diagnostics.extend(data_compatibility_diagnostics(modules,
|
|
197
|
+
diagnostics.extend(migration_diagnostics(modules, database_url))
|
|
198
|
+
diagnostics.extend(data_compatibility_diagnostics(modules, database_url))
|
|
199
|
+
for module in modules:
|
|
200
|
+
try:
|
|
201
|
+
findings = tuple(module.doctor_diagnostics(database_url))
|
|
202
|
+
if any(
|
|
203
|
+
not isinstance(finding, Diagnostic)
|
|
204
|
+
or not isinstance(finding.level, DiagnosticLevel)
|
|
205
|
+
or not isinstance(finding.code, str)
|
|
206
|
+
for finding in findings
|
|
207
|
+
):
|
|
208
|
+
raise TypeError("Invalid module doctor diagnostic")
|
|
209
|
+
diagnostics.extend(findings)
|
|
210
|
+
except Exception:
|
|
211
|
+
# Diagnostic hooks may touch credentials; do not print exception text.
|
|
212
|
+
diagnostics.append(
|
|
213
|
+
Diagnostic(
|
|
214
|
+
level=DiagnosticLevel.ERROR,
|
|
215
|
+
code="SM036",
|
|
216
|
+
module_name=module.meta.name,
|
|
217
|
+
message="The module's doctor_diagnostics hook failed.",
|
|
218
|
+
suggestion="Check the module's diagnostic hook and deployment configuration.",
|
|
219
|
+
)
|
|
220
|
+
)
|
|
203
221
|
# A missing dependency only warns at a dev boot, but production refuses
|
|
204
222
|
# to start with it (GH #501), so doctor reports it as what it will be.
|
|
205
223
|
for finding in diagnostics:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Core access area."""
|
|
@@ -68,7 +68,7 @@ GrantSource = Callable[[Any, Any], Awaitable[Collection[str]]]
|
|
|
68
68
|
How a module that stores grants of its own (``permissions``' per-user grants)
|
|
69
69
|
gets them into the one set every check reads, without the framework importing
|
|
70
70
|
it (SM009). Called once per authenticated request by
|
|
71
|
-
``simple_module_hosting.permissions.resolve_principal_permissions``, so a
|
|
71
|
+
``simple_module_hosting.auth.permissions.resolve_principal_permissions``, so a
|
|
72
72
|
source that reads the database must cache: it sits on the hot path of every
|
|
73
73
|
page load.
|
|
74
74
|
"""
|
|
@@ -6,7 +6,7 @@ import re
|
|
|
6
6
|
from dataclasses import dataclass
|
|
7
7
|
from typing import Any
|
|
8
8
|
|
|
9
|
-
from simple_module_core.resources import ResourcePolicy
|
|
9
|
+
from simple_module_core.access.resources import ResourcePolicy
|
|
10
10
|
|
|
11
11
|
ACTION_PUBLISH = "publish"
|
|
12
12
|
_STATE_KEY = "file_access_policies"
|
|
@@ -7,7 +7,7 @@ import time
|
|
|
7
7
|
from collections.abc import Callable, Collection
|
|
8
8
|
from dataclasses import dataclass, field
|
|
9
9
|
|
|
10
|
-
from simple_module_core._permission_grants import ( # noqa: F401 (re-exported)
|
|
10
|
+
from simple_module_core.access._permission_grants import ( # noqa: F401 (re-exported)
|
|
11
11
|
ADMIN_ROLE,
|
|
12
12
|
DEFAULT_ROLE_PERMISSIONS,
|
|
13
13
|
WILDCARD,
|
|
@@ -17,7 +17,7 @@ from simple_module_core._permission_grants import ( # noqa: F401 (re-exported)
|
|
|
17
17
|
is_admin,
|
|
18
18
|
is_admin_principal,
|
|
19
19
|
)
|
|
20
|
-
from simple_module_core.permission_catalogue import PermissionCatalogue
|
|
20
|
+
from simple_module_core.access.permission_catalogue import PermissionCatalogue
|
|
21
21
|
|
|
22
22
|
logger = logging.getLogger(__name__)
|
|
23
23
|
|
|
@@ -6,14 +6,14 @@ import logging
|
|
|
6
6
|
from collections.abc import Iterable
|
|
7
7
|
from typing import Any
|
|
8
8
|
|
|
9
|
-
from simple_module_core.permissions import (
|
|
9
|
+
from simple_module_core.access.permissions import (
|
|
10
10
|
DEFAULT_ROLE_PERMISSIONS,
|
|
11
11
|
WILDCARD,
|
|
12
12
|
PermissionRegistry,
|
|
13
13
|
grants,
|
|
14
14
|
)
|
|
15
|
-
from simple_module_core.resources import ResourcePrincipal
|
|
16
|
-
from simple_module_core.tenancy import is_tenant_role
|
|
15
|
+
from simple_module_core.access.resources import ResourcePrincipal
|
|
16
|
+
from simple_module_core.access.tenancy import is_tenant_role
|
|
17
17
|
|
|
18
18
|
logger = logging.getLogger(__name__)
|
|
19
19
|
|
|
@@ -6,8 +6,8 @@ from collections.abc import Awaitable, Callable, Sequence
|
|
|
6
6
|
from dataclasses import dataclass, field
|
|
7
7
|
from typing import Any
|
|
8
8
|
|
|
9
|
-
from simple_module_core.permissions import PermissionRegistry
|
|
10
|
-
from simple_module_core.user_directory import NullUserDirectory, UserDirectory
|
|
9
|
+
from simple_module_core.access.permissions import PermissionRegistry
|
|
10
|
+
from simple_module_core.access.user_directory import NullUserDirectory, UserDirectory
|
|
11
11
|
|
|
12
12
|
PRINCIPALS_KEY = "sm_principals"
|
|
13
13
|
|
|
@@ -19,7 +19,7 @@ view but not *action* is a 403.
|
|
|
19
19
|
Modules declare their types in ``register_resource_types`` so cross-cutting
|
|
20
20
|
code (the optional ``sharing`` module) can find a type's policy and load a row
|
|
21
21
|
by its string id. ``simple_module_core`` stays SQLAlchemy-free: statements are
|
|
22
|
-
typed ``Any``; the stock policy lives in ``simple_module_db.resource_policy``.
|
|
22
|
+
typed ``Any``; the stock policy lives in ``simple_module_db.queries.resource_policy``.
|
|
23
23
|
"""
|
|
24
24
|
|
|
25
25
|
from __future__ import annotations
|
|
@@ -29,7 +29,7 @@ from collections.abc import Callable, Mapping
|
|
|
29
29
|
from dataclasses import dataclass, field
|
|
30
30
|
from typing import Any, Protocol, runtime_checkable
|
|
31
31
|
|
|
32
|
-
from simple_module_core.permissions import grants
|
|
32
|
+
from simple_module_core.access.permissions import grants
|
|
33
33
|
|
|
34
34
|
ACTION_VIEW = "view"
|
|
35
35
|
"""Seeing the row at all; what decides 404 versus 403."""
|
|
@@ -10,7 +10,7 @@ from dataclasses import dataclass
|
|
|
10
10
|
from typing import Any, Protocol, runtime_checkable
|
|
11
11
|
from uuid import UUID
|
|
12
12
|
|
|
13
|
-
from simple_module_core.tenancy import is_tenant_role
|
|
13
|
+
from simple_module_core.access.tenancy import is_tenant_role
|
|
14
14
|
|
|
15
15
|
ROLE_DIRECTORY_STATE_ATTR = "role_directory"
|
|
16
16
|
|
|
@@ -6,7 +6,7 @@ tenant ``admin`` can never be mistaken for the platform ``admin`` role. The
|
|
|
6
6
|
``tenants`` module assigns these; any other module maps them onto its own
|
|
7
7
|
permissions without depending on ``tenants``::
|
|
8
8
|
|
|
9
|
-
from simple_module_core.tenancy import TenantRole, tenant_role
|
|
9
|
+
from simple_module_core.access.tenancy import TenantRole, tenant_role
|
|
10
10
|
|
|
11
11
|
registry.map_role(tenant_role(TenantRole.MEMBER), ["files.view"])
|
|
12
12
|
"""
|
|
@@ -15,9 +15,15 @@ from __future__ import annotations
|
|
|
15
15
|
|
|
16
16
|
from collections.abc import Awaitable, Callable, Collection
|
|
17
17
|
from enum import StrEnum
|
|
18
|
-
from typing import Any
|
|
18
|
+
from typing import Any, NamedTuple
|
|
19
19
|
|
|
20
|
-
from simple_module_core.app_state import
|
|
20
|
+
from simple_module_core.modules.app_state import (
|
|
21
|
+
get_services,
|
|
22
|
+
get_tenant_exists,
|
|
23
|
+
get_tenant_members,
|
|
24
|
+
get_tenant_slug,
|
|
25
|
+
get_user_tenants,
|
|
26
|
+
)
|
|
21
27
|
|
|
22
28
|
TENANT_ROLE_PREFIX = "tenant:"
|
|
23
29
|
|
|
@@ -42,6 +48,21 @@ class TenancyMode(StrEnum):
|
|
|
42
48
|
MULTI = "multi"
|
|
43
49
|
|
|
44
50
|
|
|
51
|
+
def request_tenant_id(request: Any) -> str | None:
|
|
52
|
+
"""The effective tenant for authorization and flags, without binding DB scope.
|
|
53
|
+
|
|
54
|
+
Single-tenant hosts publish their install ID on the database state, even
|
|
55
|
+
when requests stay unbound so reads can see every row. Bare apps without
|
|
56
|
+
that state retain their request's tenant; multi-tenant hosts never fall back.
|
|
57
|
+
"""
|
|
58
|
+
sm = get_services(request.app)
|
|
59
|
+
if getattr(sm, "tenancy", TenancyMode.SINGLE) is TenancyMode.SINGLE:
|
|
60
|
+
default = getattr(getattr(sm, "db", None), "default_tenant_id", None)
|
|
61
|
+
if default:
|
|
62
|
+
return default
|
|
63
|
+
return getattr(request.state, "tenant_id", None)
|
|
64
|
+
|
|
65
|
+
|
|
45
66
|
def tenant_role(name: str) -> str:
|
|
46
67
|
"""The effective principal role for membership role ``name``: ``tenant:<name>``.
|
|
47
68
|
|
|
@@ -80,6 +101,21 @@ async def tenant_exists(app: Any, tenant_id: str) -> bool | None:
|
|
|
80
101
|
return bool(await check(tenant_id))
|
|
81
102
|
|
|
82
103
|
|
|
104
|
+
TenantSlug = Callable[[str], Awaitable[str | None]]
|
|
105
|
+
"""``async (tenant_id) -> slug | None``: the human-readable slug of a tenant."""
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
async def tenant_slug(app: Any, tenant_id: str) -> str | None:
|
|
109
|
+
"""The slug of ``tenant_id``, or ``None`` when unknown or no module owns tenants.
|
|
110
|
+
|
|
111
|
+
The ``tenants`` module publishes ``app.state.tenant_slug`` (a :data:`TenantSlug`);
|
|
112
|
+
clients that show or accept a slug (``/api/_meta/whoami``, the CLI's ``--tenant``)
|
|
113
|
+
ask through this without importing that module.
|
|
114
|
+
"""
|
|
115
|
+
lookup: TenantSlug | None = get_tenant_slug(app)
|
|
116
|
+
return None if lookup is None else await lookup(tenant_id)
|
|
117
|
+
|
|
118
|
+
|
|
83
119
|
TenantMembers = Callable[[Any, str, Collection[str] | None], Awaitable[Collection[str]]]
|
|
84
120
|
"""``async (db, tenant_id, user_ids) -> the subset of user_ids that are members``.
|
|
85
121
|
|
|
@@ -108,14 +144,39 @@ async def tenant_member_ids(
|
|
|
108
144
|
return set(await check(db, tenant_id, user_ids))
|
|
109
145
|
|
|
110
146
|
|
|
147
|
+
class UserTenant(NamedTuple):
|
|
148
|
+
"""One active tenant membership belonging to a user."""
|
|
149
|
+
|
|
150
|
+
id: str
|
|
151
|
+
slug: str
|
|
152
|
+
name: str
|
|
153
|
+
role: str
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
UserTenants = Callable[[str], Awaitable[list[UserTenant]]]
|
|
157
|
+
"""``async (user_id) -> list[UserTenant]``: active tenant memberships of a user."""
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
async def user_tenants(app: Any, user_id: str) -> list[UserTenant] | None:
|
|
161
|
+
"""Active tenant memberships for *user_id*, or ``None`` when no tenants module is installed."""
|
|
162
|
+
lookup: UserTenants | None = get_user_tenants(app)
|
|
163
|
+
return None if lookup is None else list(await lookup(user_id))
|
|
164
|
+
|
|
165
|
+
|
|
111
166
|
__all__ = [
|
|
112
167
|
"TENANT_ROLE_PREFIX",
|
|
113
168
|
"TenancyMode",
|
|
114
169
|
"TenantExists",
|
|
115
170
|
"TenantMembers",
|
|
116
171
|
"TenantRole",
|
|
172
|
+
"TenantSlug",
|
|
173
|
+
"UserTenant",
|
|
174
|
+
"UserTenants",
|
|
117
175
|
"is_tenant_role",
|
|
176
|
+
"request_tenant_id",
|
|
118
177
|
"tenant_exists",
|
|
119
178
|
"tenant_member_ids",
|
|
120
179
|
"tenant_role",
|
|
180
|
+
"tenant_slug",
|
|
181
|
+
"user_tenants",
|
|
121
182
|
]
|
|
@@ -96,12 +96,15 @@ class UserDirectory(Protocol):
|
|
|
96
96
|
exclude_ids: Collection[str] = (),
|
|
97
97
|
active_only: bool = False,
|
|
98
98
|
exact_email: bool = False,
|
|
99
|
+
match_email: bool = True,
|
|
99
100
|
) -> list[DirectoryUser]:
|
|
100
101
|
"""Users matching *term*, with every filter applied before *limit*.
|
|
101
102
|
|
|
102
103
|
``include_ids=None`` is unrestricted; an empty collection matches nobody.
|
|
103
104
|
``active_only`` excludes disabled accounts too. ``exact_email`` matches
|
|
104
105
|
only the complete email (case insensitive), never a name or substring.
|
|
106
|
+
``match_email=False`` restricts substring matching to full names, without
|
|
107
|
+
falling back to email for nameless users. ``exact_email`` takes precedence.
|
|
105
108
|
Defaults preserve the unrestricted name/email search.
|
|
106
109
|
"""
|
|
107
110
|
...
|
|
@@ -120,7 +123,23 @@ class UserDirectory(Protocol):
|
|
|
120
123
|
...
|
|
121
124
|
|
|
122
125
|
|
|
123
|
-
|
|
126
|
+
@runtime_checkable
|
|
127
|
+
class EmailLookupUserDirectory(UserDirectory, Protocol):
|
|
128
|
+
"""Optional exact-email lookup; legacy structural directories stay valid.
|
|
129
|
+
|
|
130
|
+
Providers can inherit this default, or implement the method themselves.
|
|
131
|
+
"""
|
|
132
|
+
|
|
133
|
+
async def find_by_email(self, db: Any, email: str) -> DirectoryUser | None:
|
|
134
|
+
"""Find one case-insensitive exact email in the directory's usual scope."""
|
|
135
|
+
email = email.strip()
|
|
136
|
+
if not email:
|
|
137
|
+
return None
|
|
138
|
+
found = await self.search(db, email, limit=1, exact_email=True)
|
|
139
|
+
return found[0] if found else None
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
class NullUserDirectory(EmailLookupUserDirectory):
|
|
124
143
|
"""The directory when no auth provider registered one: it knows nobody."""
|
|
125
144
|
|
|
126
145
|
entity_type: str | None = None
|
|
@@ -140,6 +159,7 @@ class NullUserDirectory:
|
|
|
140
159
|
exclude_ids: Collection[str] = (),
|
|
141
160
|
active_only: bool = False,
|
|
142
161
|
exact_email: bool = False,
|
|
162
|
+
match_email: bool = True,
|
|
143
163
|
) -> list[DirectoryUser]:
|
|
144
164
|
return []
|
|
145
165
|
|
|
@@ -211,6 +231,7 @@ __all__ = [
|
|
|
211
231
|
"USER_DIRECTORY_STATE_ATTR",
|
|
212
232
|
"DirectoryStats",
|
|
213
233
|
"DirectoryUser",
|
|
234
|
+
"EmailLookupUserDirectory",
|
|
214
235
|
"NullUserDirectory",
|
|
215
236
|
"UserDirectory",
|
|
216
237
|
"chunked",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Deprecated alias for simple_module_core.access.activity_feed."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from importlib import import_module
|
|
5
|
+
|
|
6
|
+
from simple_module_core.runtime.deprecation import deprecated_module
|
|
7
|
+
|
|
8
|
+
deprecated_module(
|
|
9
|
+
"simple_module_core.activity_feed",
|
|
10
|
+
remove_in="0.0.55",
|
|
11
|
+
use="simple_module_core.access.activity_feed",
|
|
12
|
+
)
|
|
13
|
+
sys.modules[__name__] = import_module("simple_module_core.access.activity_feed")
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Deprecated alias for simple_module_core.modules.app_state."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from importlib import import_module
|
|
5
|
+
|
|
6
|
+
from simple_module_core.runtime.deprecation import deprecated_module
|
|
7
|
+
|
|
8
|
+
deprecated_module(
|
|
9
|
+
"simple_module_core.app_state", remove_in="0.0.55", use="simple_module_core.modules.app_state"
|
|
10
|
+
)
|
|
11
|
+
sys.modules[__name__] = import_module("simple_module_core.modules.app_state")
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Deprecated alias for simple_module_core.web.audit_links."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from importlib import import_module
|
|
5
|
+
|
|
6
|
+
from simple_module_core.runtime.deprecation import deprecated_module
|
|
7
|
+
|
|
8
|
+
deprecated_module(
|
|
9
|
+
"simple_module_core.audit_links", remove_in="0.0.55", use="simple_module_core.web.audit_links"
|
|
10
|
+
)
|
|
11
|
+
sys.modules[__name__] = import_module("simple_module_core.web.audit_links")
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Deprecated alias for simple_module_core.web.body_limits."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from importlib import import_module
|
|
5
|
+
|
|
6
|
+
from simple_module_core.runtime.deprecation import deprecated_module
|
|
7
|
+
|
|
8
|
+
deprecated_module(
|
|
9
|
+
"simple_module_core.body_limits", remove_in="0.0.55", use="simple_module_core.web.body_limits"
|
|
10
|
+
)
|
|
11
|
+
sys.modules[__name__] = import_module("simple_module_core.web.body_limits")
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Deprecated alias for simple_module_core.runtime.correlation."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from importlib import import_module
|
|
5
|
+
|
|
6
|
+
from simple_module_core.runtime.deprecation import deprecated_module
|
|
7
|
+
|
|
8
|
+
deprecated_module(
|
|
9
|
+
"simple_module_core.correlation",
|
|
10
|
+
remove_in="0.0.55",
|
|
11
|
+
use="simple_module_core.runtime.correlation",
|
|
12
|
+
)
|
|
13
|
+
sys.modules[__name__] = import_module("simple_module_core.runtime.correlation")
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"""Deprecated alias for simple_module_core.web.cors."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from importlib import import_module
|
|
5
|
+
|
|
6
|
+
from simple_module_core.runtime.deprecation import deprecated_module
|
|
7
|
+
|
|
8
|
+
deprecated_module("simple_module_core.cors", remove_in="0.0.55", use="simple_module_core.web.cors")
|
|
9
|
+
sys.modules[__name__] = import_module("simple_module_core.web.cors")
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Deprecated alias for simple_module_core.runtime.crypto."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from importlib import import_module
|
|
5
|
+
|
|
6
|
+
from simple_module_core.runtime.deprecation import deprecated_module
|
|
7
|
+
|
|
8
|
+
deprecated_module(
|
|
9
|
+
"simple_module_core.crypto", remove_in="0.0.55", use="simple_module_core.runtime.crypto"
|
|
10
|
+
)
|
|
11
|
+
sys.modules[__name__] = import_module("simple_module_core.runtime.crypto")
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"""Deprecated alias for simple_module_core.web.csp."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from importlib import import_module
|
|
5
|
+
|
|
6
|
+
from simple_module_core.runtime.deprecation import deprecated_module
|
|
7
|
+
|
|
8
|
+
deprecated_module("simple_module_core.csp", remove_in="0.0.55", use="simple_module_core.web.csp")
|
|
9
|
+
sys.modules[__name__] = import_module("simple_module_core.web.csp")
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Deprecated alias for simple_module_core.migrations.data_compatibility."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from importlib import import_module
|
|
5
|
+
|
|
6
|
+
from simple_module_core.runtime.deprecation import deprecated_module
|
|
7
|
+
|
|
8
|
+
deprecated_module(
|
|
9
|
+
"simple_module_core.data_compatibility",
|
|
10
|
+
remove_in="0.0.55",
|
|
11
|
+
use="simple_module_core.migrations.data_compatibility",
|
|
12
|
+
)
|
|
13
|
+
sys.modules[__name__] = import_module("simple_module_core.migrations.data_compatibility")
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Deprecated alias for simple_module_core.runtime.datetimes."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from importlib import import_module
|
|
5
|
+
|
|
6
|
+
from simple_module_core.runtime.deprecation import deprecated_module
|
|
7
|
+
|
|
8
|
+
deprecated_module(
|
|
9
|
+
"simple_module_core.datetimes", remove_in="0.0.55", use="simple_module_core.runtime.datetimes"
|
|
10
|
+
)
|
|
11
|
+
sys.modules[__name__] = import_module("simple_module_core.runtime.datetimes")
|