amsdal 0.5.34__cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
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.
- amsdal/Third-Party Materials - AMSDAL Dependencies - License Notices.md +1362 -0
- amsdal/__about__.py +4 -0
- amsdal/__about__.pyi +1 -0
- amsdal/__init__.py +23 -0
- amsdal/__init__.pyi +9 -0
- amsdal/__migrations__/0000_initial.py +36 -0
- amsdal/__migrations__/0001_create_class_file.py +61 -0
- amsdal/__migrations__/0002_create_class_file.py +109 -0
- amsdal/__migrations__/0003_update_class_file.py +91 -0
- amsdal/__migrations__/0004_update_class_file.py +45 -0
- amsdal/cloud/__init__.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/__init__.pyi +0 -0
- amsdal/cloud/client.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/client.pyi +57 -0
- amsdal/cloud/constants.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/constants.pyi +13 -0
- amsdal/cloud/enums.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/enums.pyi +68 -0
- amsdal/cloud/models/__init__.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/models/__init__.pyi +0 -0
- amsdal/cloud/models/base.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/models/base.pyi +247 -0
- amsdal/cloud/services/__init__.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/__init__.pyi +0 -0
- amsdal/cloud/services/actions/__init__.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/__init__.pyi +0 -0
- amsdal/cloud/services/actions/add_allowlist_ip.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/add_allowlist_ip.pyi +19 -0
- amsdal/cloud/services/actions/add_basic_auth.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/add_basic_auth.pyi +21 -0
- amsdal/cloud/services/actions/add_dependency.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/add_dependency.pyi +19 -0
- amsdal/cloud/services/actions/add_secret.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/add_secret.pyi +20 -0
- amsdal/cloud/services/actions/base.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/base.pyi +122 -0
- amsdal/cloud/services/actions/create_deploy.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/create_deploy.pyi +41 -0
- amsdal/cloud/services/actions/create_env.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/create_env.pyi +19 -0
- amsdal/cloud/services/actions/create_session.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/create_session.pyi +17 -0
- amsdal/cloud/services/actions/delete_allowlist_ip.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/delete_allowlist_ip.pyi +19 -0
- amsdal/cloud/services/actions/delete_basic_auth.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/delete_basic_auth.pyi +20 -0
- amsdal/cloud/services/actions/delete_dependency.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/delete_dependency.pyi +21 -0
- amsdal/cloud/services/actions/delete_env.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/delete_env.pyi +21 -0
- amsdal/cloud/services/actions/delete_secret.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/delete_secret.pyi +21 -0
- amsdal/cloud/services/actions/destroy_deploy.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/destroy_deploy.pyi +18 -0
- amsdal/cloud/services/actions/expose_db.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/expose_db.pyi +22 -0
- amsdal/cloud/services/actions/get_basic_auth_credentials.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/get_basic_auth_credentials.pyi +21 -0
- amsdal/cloud/services/actions/get_monitoring_info.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/get_monitoring_info.pyi +21 -0
- amsdal/cloud/services/actions/list_dependencies.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/list_dependencies.pyi +21 -0
- amsdal/cloud/services/actions/list_deploys.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/list_deploys.pyi +19 -0
- amsdal/cloud/services/actions/list_envs.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/list_envs.pyi +20 -0
- amsdal/cloud/services/actions/list_secrets.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/list_secrets.pyi +22 -0
- amsdal/cloud/services/actions/manager.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/manager.pyi +278 -0
- amsdal/cloud/services/actions/signup_action.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/signup_action.pyi +20 -0
- amsdal/cloud/services/actions/update_deploy.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/actions/update_deploy.pyi +19 -0
- amsdal/cloud/services/auth/__init__.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/auth/__init__.pyi +0 -0
- amsdal/cloud/services/auth/base.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/auth/base.pyi +6 -0
- amsdal/cloud/services/auth/credentials.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/auth/credentials.pyi +30 -0
- amsdal/cloud/services/auth/manager.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/auth/manager.pyi +26 -0
- amsdal/cloud/services/auth/signup_service.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/auth/signup_service.pyi +32 -0
- amsdal/cloud/services/auth/token.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/cloud/services/auth/token.pyi +27 -0
- amsdal/configs/__init__.py +0 -0
- amsdal/configs/__init__.pyi +0 -0
- amsdal/configs/constants.py +33 -0
- amsdal/configs/constants.pyi +22 -0
- amsdal/configs/main.py +274 -0
- amsdal/configs/main.pyi +178 -0
- amsdal/context/__init__.py +0 -0
- amsdal/context/__init__.pyi +0 -0
- amsdal/context/manager.py +69 -0
- amsdal/context/manager.pyi +50 -0
- amsdal/contrib/__init__.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/contrib/__init__.pyi +0 -0
- amsdal/contrib/app_config.py +7 -0
- amsdal/contrib/app_config.pyi +6 -0
- amsdal/contrib/auth/__init__.py +0 -0
- amsdal/contrib/auth/__init__.pyi +0 -0
- amsdal/contrib/auth/app.py +27 -0
- amsdal/contrib/auth/app.pyi +15 -0
- amsdal/contrib/auth/decorators/__init__.py +35 -0
- amsdal/contrib/auth/decorators/__init__.pyi +6 -0
- amsdal/contrib/auth/errors.py +43 -0
- amsdal/contrib/auth/errors.pyi +16 -0
- amsdal/contrib/auth/fixtures/basic_permissions.json +64 -0
- amsdal/contrib/auth/lifecycle/__init__.py +0 -0
- amsdal/contrib/auth/lifecycle/__init__.pyi +0 -0
- amsdal/contrib/auth/lifecycle/consumer.py +394 -0
- amsdal/contrib/auth/lifecycle/consumer.pyi +108 -0
- amsdal/contrib/auth/migrations/0000_initial.py +87 -0
- amsdal/contrib/auth/migrations/0001_add_mfa_support.py +188 -0
- amsdal/contrib/auth/models/__init__.py +1 -0
- amsdal/contrib/auth/models/backup_code.py +85 -0
- amsdal/contrib/auth/models/email_mfa_device.py +108 -0
- amsdal/contrib/auth/models/login_session.py +235 -0
- amsdal/contrib/auth/models/mfa_device.py +86 -0
- amsdal/contrib/auth/models/permission.py +23 -0
- amsdal/contrib/auth/models/sms_device.py +113 -0
- amsdal/contrib/auth/models/totp_device.py +58 -0
- amsdal/contrib/auth/models/user.py +156 -0
- amsdal/contrib/auth/services/__init__.py +1 -0
- amsdal/contrib/auth/services/__init__.pyi +0 -0
- amsdal/contrib/auth/services/mfa_device_service.py +544 -0
- amsdal/contrib/auth/services/mfa_device_service.pyi +216 -0
- amsdal/contrib/auth/services/totp_service.py +358 -0
- amsdal/contrib/auth/services/totp_service.pyi +158 -0
- amsdal/contrib/auth/settings.py +44 -0
- amsdal/contrib/auth/settings.pyi +34 -0
- amsdal/contrib/auth/transactions/__init__.py +1 -0
- amsdal/contrib/auth/transactions/__init__.pyi +0 -0
- amsdal/contrib/auth/transactions/mfa_device_transactions.py +458 -0
- amsdal/contrib/auth/transactions/mfa_device_transactions.pyi +226 -0
- amsdal/contrib/auth/transactions/totp_transactions.py +203 -0
- amsdal/contrib/auth/transactions/totp_transactions.pyi +113 -0
- amsdal/contrib/auth/utils/__init__.py +0 -0
- amsdal/contrib/auth/utils/__init__.pyi +0 -0
- amsdal/contrib/auth/utils/mfa.py +257 -0
- amsdal/contrib/auth/utils/mfa.pyi +119 -0
- amsdal/contrib/frontend_configs/__init__.py +0 -0
- amsdal/contrib/frontend_configs/__init__.pyi +0 -0
- amsdal/contrib/frontend_configs/app.py +24 -0
- amsdal/contrib/frontend_configs/app.pyi +19 -0
- amsdal/contrib/frontend_configs/constants.py +1 -0
- amsdal/contrib/frontend_configs/constants.pyi +1 -0
- amsdal/contrib/frontend_configs/conversion/__init__.py +5 -0
- amsdal/contrib/frontend_configs/conversion/__init__.pyi +3 -0
- amsdal/contrib/frontend_configs/conversion/convert.py +310 -0
- amsdal/contrib/frontend_configs/conversion/convert.pyi +22 -0
- amsdal/contrib/frontend_configs/lifecycle/__init__.py +0 -0
- amsdal/contrib/frontend_configs/lifecycle/__init__.pyi +0 -0
- amsdal/contrib/frontend_configs/lifecycle/consumer.py +306 -0
- amsdal/contrib/frontend_configs/lifecycle/consumer.pyi +98 -0
- amsdal/contrib/frontend_configs/migrations/0000_initial.py +227 -0
- amsdal/contrib/frontend_configs/migrations/0001_update_frontend_control_config.py +245 -0
- amsdal/contrib/frontend_configs/migrations/0002_add_button_and_invoke_actions.py +352 -0
- amsdal/contrib/frontend_configs/migrations/0003_create_class_frontendconfigdashboardelement.py +145 -0
- amsdal/contrib/frontend_configs/models/__init__.py +0 -0
- amsdal/contrib/frontend_configs/models/frontend_activator_config.py +22 -0
- amsdal/contrib/frontend_configs/models/frontend_config_async_validator.py +11 -0
- amsdal/contrib/frontend_configs/models/frontend_config_control_action.py +110 -0
- amsdal/contrib/frontend_configs/models/frontend_config_dashboard.py +51 -0
- amsdal/contrib/frontend_configs/models/frontend_config_group_validator.py +21 -0
- amsdal/contrib/frontend_configs/models/frontend_config_option.py +12 -0
- amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base.py +17 -0
- amsdal/contrib/frontend_configs/models/frontend_config_slider_option.py +13 -0
- amsdal/contrib/frontend_configs/models/frontend_config_text_mask.py +14 -0
- amsdal/contrib/frontend_configs/models/frontend_config_validator.py +28 -0
- amsdal/contrib/frontend_configs/models/frontend_control_config.py +110 -0
- amsdal/contrib/frontend_configs/models/frontend_model_config.py +14 -0
- amsdal/contrib/frontend_configs/utils.py +29 -0
- amsdal/contrib/frontend_configs/utils.pyi +17 -0
- amsdal/errors.py +31 -0
- amsdal/errors.pyi +12 -0
- amsdal/fixtures/__init__.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/fixtures/__init__.pyi +0 -0
- amsdal/fixtures/manager.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/fixtures/manager.pyi +170 -0
- amsdal/fixtures/utils.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/fixtures/utils.pyi +9 -0
- amsdal/manager.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/manager.pyi +265 -0
- amsdal/mixins/__init__.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/mixins/__init__.pyi +0 -0
- amsdal/mixins/class_versions_mixin.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/mixins/class_versions_mixin.pyi +12 -0
- amsdal/models/__init__.py +19 -0
- amsdal/models/core/__init__.py +0 -0
- amsdal/models/core/class_object.py +38 -0
- amsdal/models/core/class_property.py +26 -0
- amsdal/models/core/file.py +243 -0
- amsdal/models/core/fixture.py +25 -0
- amsdal/models/core/option.py +11 -0
- amsdal/models/core/storage_metadata.py +15 -0
- amsdal/models/core/validator.py +12 -0
- amsdal/models/mixins.py +31 -0
- amsdal/models/types/__init__.py +0 -0
- amsdal/models/types/object.py +26 -0
- amsdal/py.typed +0 -0
- amsdal/queryset/__init__.py +21 -0
- amsdal/queryset/__init__.pyi +6 -0
- amsdal/schemas/__init__.py +0 -0
- amsdal/schemas/__init__.pyi +0 -0
- amsdal/schemas/core/class_object/model.json +51 -0
- amsdal/schemas/core/class_object/properties/display_name.py +9 -0
- amsdal/schemas/core/class_property/model.json +41 -0
- amsdal/schemas/core/file/hooks/pre_create.py +24 -0
- amsdal/schemas/core/file/hooks/pre_update.py +24 -0
- amsdal/schemas/core/file/model.json +23 -0
- amsdal/schemas/core/file/properties/from_file.py +34 -0
- amsdal/schemas/core/file/properties/mimetype.py +13 -0
- amsdal/schemas/core/file/properties/str.py +6 -0
- amsdal/schemas/core/file/properties/to_file.py +24 -0
- amsdal/schemas/core/file/properties/validate_data.py +31 -0
- amsdal/schemas/core/fixture/model.json +35 -0
- amsdal/schemas/core/option/model.json +19 -0
- amsdal/schemas/core/storage_metadata/model.json +52 -0
- amsdal/schemas/core/validator/model.json +19 -0
- amsdal/schemas/interfaces.py +25 -0
- amsdal/schemas/interfaces.pyi +20 -0
- amsdal/schemas/manager.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/schemas/manager.py +0 -0
- amsdal/schemas/manager.pyi +0 -0
- amsdal/schemas/mixins/__init__.py +0 -0
- amsdal/schemas/mixins/__init__.pyi +0 -0
- amsdal/schemas/mixins/check_dependencies_mixin.py +130 -0
- amsdal/schemas/mixins/check_dependencies_mixin.pyi +45 -0
- amsdal/schemas/mixins/verify_schemas_mixin.py +96 -0
- amsdal/schemas/mixins/verify_schemas_mixin.pyi +33 -0
- amsdal/schemas/repository.py +84 -0
- amsdal/schemas/repository.pyi +22 -0
- amsdal/schemas/types/anything/model.json +7 -0
- amsdal/schemas/types/array/model.json +7 -0
- amsdal/schemas/types/binary/model.json +7 -0
- amsdal/schemas/types/boolean/model.json +17 -0
- amsdal/schemas/types/date/model.json +7 -0
- amsdal/schemas/types/datetime/model.json +7 -0
- amsdal/schemas/types/dictionary/model.json +8 -0
- amsdal/schemas/types/number/model.json +8 -0
- amsdal/schemas/types/object/model.json +53 -0
- amsdal/schemas/types/string/model.json +8 -0
- amsdal/schemas/utils.py +16 -0
- amsdal/schemas/utils.pyi +10 -0
- amsdal/services/__init__.py +11 -0
- amsdal/services/__init__.pyi +4 -0
- amsdal/services/external_connections.py +262 -0
- amsdal/services/external_connections.pyi +190 -0
- amsdal/services/external_model_generator.py +350 -0
- amsdal/services/external_model_generator.pyi +134 -0
- amsdal/services/transaction_execution.cpython-313-x86_64-linux-gnu.so +0 -0
- amsdal/services/transaction_execution.pyi +93 -0
- amsdal/storages/__init__.py +20 -0
- amsdal/storages/__init__.pyi +8 -0
- amsdal/storages/file_system.py +214 -0
- amsdal/storages/file_system.pyi +36 -0
- amsdal/transactions/__init__.py +13 -0
- amsdal/transactions/__init__.pyi +4 -0
- amsdal/utils/__init__.py +0 -0
- amsdal/utils/__init__.pyi +0 -0
- amsdal/utils/contrib_paths.py +23 -0
- amsdal/utils/contrib_paths.pyi +14 -0
- amsdal/utils/rollback/__init__.py +440 -0
- amsdal/utils/rollback/__init__.pyi +38 -0
- amsdal/utils/tests/__init__.py +0 -0
- amsdal/utils/tests/enums.py +16 -0
- amsdal/utils/tests/factories.py +49 -0
- amsdal/utils/tests/helpers.py +331 -0
- amsdal/utils/tests/migrations.py +157 -0
- amsdal-0.5.34.dist-info/METADATA +375 -0
- amsdal-0.5.34.dist-info/RECORD +276 -0
- amsdal-0.5.34.dist-info/WHEEL +6 -0
- amsdal-0.5.34.dist-info/licenses/LICENSE.txt +107 -0
- amsdal-0.5.34.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from contextvars import ContextVar
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
_CONTEXT: ContextVar[dict[str, Any] | None]
|
|
5
|
+
|
|
6
|
+
class AmsdalContextManager:
|
|
7
|
+
"""
|
|
8
|
+
Manages a context for storing and retrieving data.
|
|
9
|
+
|
|
10
|
+
This class provides methods to get, set, and add to a context stored in a
|
|
11
|
+
`ContextVar`. The context is a dictionary that can hold any key-value pairs.
|
|
12
|
+
"""
|
|
13
|
+
@classmethod
|
|
14
|
+
def get_context(cls) -> dict[str, Any]:
|
|
15
|
+
"""
|
|
16
|
+
Retrieves the current context or creates a new one if none exists.
|
|
17
|
+
|
|
18
|
+
This method gets the current context from the `_CONTEXT` variable. If no
|
|
19
|
+
context exists, it creates a new empty context and sets it.
|
|
20
|
+
|
|
21
|
+
Returns:
|
|
22
|
+
dict[str, Any]: The current context.
|
|
23
|
+
"""
|
|
24
|
+
@classmethod
|
|
25
|
+
def set_context(cls, context: dict[str, Any]) -> None:
|
|
26
|
+
"""
|
|
27
|
+
Sets the context to the provided dictionary.
|
|
28
|
+
|
|
29
|
+
This method sets the `_CONTEXT` variable to the provided context.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
context (dict[str, Any]): The context to set.
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
None
|
|
36
|
+
"""
|
|
37
|
+
@classmethod
|
|
38
|
+
def add_to_context(cls, key: str, value: Any) -> None:
|
|
39
|
+
"""
|
|
40
|
+
Adds a key-value pair to the current context.
|
|
41
|
+
|
|
42
|
+
This method adds the provided key-value pair to the current context.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
key (str): The key to add to the context.
|
|
46
|
+
value (Any): The value to associate with the key.
|
|
47
|
+
|
|
48
|
+
Returns:
|
|
49
|
+
None
|
|
50
|
+
"""
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from amsdal_utils.lifecycle.enum import LifecycleEvent
|
|
2
|
+
from amsdal_utils.lifecycle.producer import LifecycleProducer
|
|
3
|
+
|
|
4
|
+
from amsdal.contrib.app_config import AppConfig
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class AuthAppConfig(AppConfig):
|
|
8
|
+
"""
|
|
9
|
+
Configuration class for the authentication application.
|
|
10
|
+
|
|
11
|
+
This class sets up the necessary listeners for various lifecycle events
|
|
12
|
+
related to authentication and permission checks.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
def on_ready(self) -> None:
|
|
16
|
+
"""
|
|
17
|
+
Sets up listeners for various lifecycle events.
|
|
18
|
+
|
|
19
|
+
This method adds listeners for server startup, user authentication, and permission checks.
|
|
20
|
+
"""
|
|
21
|
+
from amsdal.contrib.auth.lifecycle.consumer import AuthenticateUserConsumer
|
|
22
|
+
from amsdal.contrib.auth.lifecycle.consumer import CheckAndCreateSuperUserConsumer
|
|
23
|
+
from amsdal.contrib.auth.lifecycle.consumer import CheckPermissionConsumer
|
|
24
|
+
|
|
25
|
+
LifecycleProducer.add_listener(LifecycleEvent.ON_SERVER_STARTUP, CheckAndCreateSuperUserConsumer)
|
|
26
|
+
LifecycleProducer.add_listener(LifecycleEvent.ON_AUTHENTICATE, AuthenticateUserConsumer)
|
|
27
|
+
LifecycleProducer.add_listener(LifecycleEvent.ON_PERMISSION_CHECK, CheckPermissionConsumer)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from amsdal.contrib.app_config import AppConfig as AppConfig
|
|
2
|
+
|
|
3
|
+
class AuthAppConfig(AppConfig):
|
|
4
|
+
"""
|
|
5
|
+
Configuration class for the authentication application.
|
|
6
|
+
|
|
7
|
+
This class sets up the necessary listeners for various lifecycle events
|
|
8
|
+
related to authentication and permission checks.
|
|
9
|
+
"""
|
|
10
|
+
def on_ready(self) -> None:
|
|
11
|
+
"""
|
|
12
|
+
Sets up listeners for various lifecycle events.
|
|
13
|
+
|
|
14
|
+
This method adds listeners for server startup, user authentication, and permission checks.
|
|
15
|
+
"""
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
from collections.abc import Callable
|
|
3
|
+
from functools import wraps
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
from amsdal.context.manager import AmsdalContextManager
|
|
7
|
+
from amsdal.contrib.auth.errors import AuthenticationError
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def require_auth(func: Callable[..., Any]) -> Callable[..., Any]:
|
|
11
|
+
if asyncio.iscoroutinefunction(func):
|
|
12
|
+
|
|
13
|
+
@wraps(func)
|
|
14
|
+
async def wrapper(*args: Any, **kwargs: Any) -> Callable[..., Any]:
|
|
15
|
+
request = AmsdalContextManager().get_context().get('request', None)
|
|
16
|
+
|
|
17
|
+
if not request or not request.user:
|
|
18
|
+
msg = 'Authentication required'
|
|
19
|
+
raise AuthenticationError(msg)
|
|
20
|
+
|
|
21
|
+
return await func(*args, **kwargs)
|
|
22
|
+
|
|
23
|
+
else:
|
|
24
|
+
|
|
25
|
+
@wraps(func)
|
|
26
|
+
def wrapper(*args: Any, **kwargs: Any) -> Callable[..., Any]:
|
|
27
|
+
request = AmsdalContextManager().get_context().get('request', None)
|
|
28
|
+
|
|
29
|
+
if not request or not request.user:
|
|
30
|
+
msg = 'Authentication required'
|
|
31
|
+
raise AuthenticationError(msg)
|
|
32
|
+
|
|
33
|
+
return func(*args, **kwargs)
|
|
34
|
+
|
|
35
|
+
return wrapper
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
from amsdal.context.manager import AmsdalContextManager as AmsdalContextManager
|
|
2
|
+
from amsdal.contrib.auth.errors import AuthenticationError as AuthenticationError
|
|
3
|
+
from collections.abc import Callable as Callable
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
def require_auth(func: Callable[..., Any]) -> Callable[..., Any]: ...
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from amsdal_utils.errors import AmsdalError
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class UserCreationError(AmsdalError): ...
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class AuthenticationError(AmsdalError): ...
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class MFARequiredError(AuthenticationError):
|
|
11
|
+
"""Raised when MFA verification is required but not provided."""
|
|
12
|
+
|
|
13
|
+
...
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class InvalidMFACodeError(AuthenticationError):
|
|
17
|
+
"""Raised when the provided MFA code is invalid."""
|
|
18
|
+
|
|
19
|
+
...
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class MFADeviceNotFoundError(AmsdalError):
|
|
23
|
+
"""Raised when no valid MFA device is found for the user."""
|
|
24
|
+
|
|
25
|
+
...
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class MFASetupError(AmsdalError):
|
|
29
|
+
"""Raised when there's an error during MFA device setup."""
|
|
30
|
+
|
|
31
|
+
...
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class PermissionDeniedError(AmsdalError):
|
|
35
|
+
"""Raised when a user lacks permission for an operation."""
|
|
36
|
+
|
|
37
|
+
...
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class UserNotFoundError(AmsdalError):
|
|
41
|
+
"""Raised when a target user cannot be found."""
|
|
42
|
+
|
|
43
|
+
...
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from amsdal_utils.errors import AmsdalError
|
|
2
|
+
|
|
3
|
+
class UserCreationError(AmsdalError): ...
|
|
4
|
+
class AuthenticationError(AmsdalError): ...
|
|
5
|
+
class MFARequiredError(AuthenticationError):
|
|
6
|
+
"""Raised when MFA verification is required but not provided."""
|
|
7
|
+
class InvalidMFACodeError(AuthenticationError):
|
|
8
|
+
"""Raised when the provided MFA code is invalid."""
|
|
9
|
+
class MFADeviceNotFoundError(AmsdalError):
|
|
10
|
+
"""Raised when no valid MFA device is found for the user."""
|
|
11
|
+
class MFASetupError(AmsdalError):
|
|
12
|
+
"""Raised when there's an error during MFA device setup."""
|
|
13
|
+
class PermissionDeniedError(AmsdalError):
|
|
14
|
+
"""Raised when a user lacks permission for an operation."""
|
|
15
|
+
class UserNotFoundError(AmsdalError):
|
|
16
|
+
"""Raised when a target user cannot be found."""
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Permission": [
|
|
3
|
+
{
|
|
4
|
+
"_external_id": "user_delete",
|
|
5
|
+
"model": "User",
|
|
6
|
+
"action": "delete"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"_external_id": "user_read",
|
|
10
|
+
"model": "User",
|
|
11
|
+
"action": "read"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"_external_id": "user_update",
|
|
15
|
+
"model": "User",
|
|
16
|
+
"action": "update"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"_external_id": "user_all_actions",
|
|
20
|
+
"model": "User",
|
|
21
|
+
"action": "*"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"_external_id": "all_models_all_actions",
|
|
25
|
+
"model": "*",
|
|
26
|
+
"action": "*"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"_external_id": "login_session_delete",
|
|
30
|
+
"model": "LoginSession",
|
|
31
|
+
"action": "delete"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"_external_id": "login_session_read",
|
|
35
|
+
"model": "LoginSession",
|
|
36
|
+
"action": "read"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"_external_id": "login_session_update",
|
|
40
|
+
"model": "LoginSession",
|
|
41
|
+
"action": "update"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"_external_id": "permission_delete",
|
|
45
|
+
"model": "Permission",
|
|
46
|
+
"action": "delete"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"_external_id": "permission_read",
|
|
50
|
+
"model": "Permission",
|
|
51
|
+
"action": "read"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"_external_id": "permission_update",
|
|
55
|
+
"model": "Permission",
|
|
56
|
+
"action": "update"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"_external_id": "permission_create",
|
|
60
|
+
"model": "Permission",
|
|
61
|
+
"action": "create"
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
File without changes
|
|
File without changes
|