zrb 0.23.4__py3-none-any.whl → 0.24.0__py3-none-any.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.
- zrb/__init__.py +2 -0
- zrb/builtin/devtool/install/_input.py +2 -2
- zrb/builtin/project/add/app/generator/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/snake_zrb_generator_name/template/_automate/snake_zrb_app_name/container/start.py +5 -6
- zrb/builtin/project/add/app/python/template/_automate/snake_zrb_app_name/container/start.py +5 -6
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/_helper.py +1 -52
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/microservices/start.py +5 -6
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/monolith/start.py +5 -6
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/support/start.py +4 -6
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/loadtest/locustfile.py +1 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/loadtest/template.env +1 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/config.py +59 -61
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/app/app.py +28 -28
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/app/app_lifespan.py +15 -15
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/app/app_state.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/db_connection.py +14 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/frontend_index.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/log.py +6 -6
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/messagebus.py +33 -33
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/rpc.py +9 -9
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/integration/access_token_scheme.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/integration/access_token_util.py +7 -7
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/integration/model/user_model.py +6 -6
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/integration/refresh_token_util.py +7 -7
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/integration/user.py +18 -18
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/migrate.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/register_module.py +8 -8
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/log/migrate.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/log/register_module.py +8 -8
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/template.env +5 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_group_crud.py +7 -7
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_permission_crud.py +7 -7
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_user_crud.py +7 -7
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_user_login.py +14 -14
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/test_liveness_and_readiness.py +3 -3
- zrb/builtin/project/add/fastapp/crud/_helper/__init__.py +7 -0
- zrb/builtin/project/add/fastapp/crud/_helper/_common.py +8 -0
- zrb/builtin/project/add/fastapp/crud/_helper/register_api.py +45 -0
- zrb/builtin/project/add/fastapp/crud/_helper/register_permission.py +40 -0
- zrb/builtin/project/add/fastapp/crud/_helper/register_rpc.py +45 -0
- zrb/builtin/project/add/fastapp/crud/crud.py +3 -24
- zrb/builtin/project/add/fastapp/crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/entity/snake_zrb_entity_name/repo.py +12 -1
- zrb/builtin/project/add/fastapp/crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/schema/snake_zrb_entity_name.py +1 -0
- zrb/builtin/project/add/fastapp/crud/template/src/kebab-zrb-app-name/test/snake_zrb_module_name/test_snake_zrb_entity_name.py +8 -7
- zrb/builtin/project/add/fastapp/field/_helper/__init__.py +17 -0
- zrb/builtin/project/add/fastapp/field/_helper/_common.py +102 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_delete_page.py +49 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_detail_page.py +49 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_insert_page.py +62 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_list_page.py +47 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_repo.py +47 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_schema.py +45 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_test.py +49 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_update_page.py +50 -0
- zrb/builtin/project/add/fastapp/field/_input.py +14 -2
- zrb/builtin/project/add/fastapp/field/field.py +51 -69
- zrb/builtin/project/add/fastapp/module/_helper/__init__.py +17 -0
- zrb/builtin/project/add/fastapp/module/_helper/append_all_disabled_env.py +22 -0
- zrb/builtin/project/add/fastapp/module/_helper/append_all_enabled_env.py +22 -0
- zrb/builtin/project/add/fastapp/module/_helper/append_deployment_template_env.py +25 -0
- zrb/builtin/project/add/fastapp/module/_helper/append_src_template_env.py +25 -0
- zrb/builtin/project/add/fastapp/module/_helper/create_app_config.py +29 -0
- zrb/builtin/project/add/fastapp/module/_helper/create_microservice_config.py +158 -0
- zrb/builtin/project/add/fastapp/module/_helper/register_migration.py +35 -0
- zrb/builtin/project/add/fastapp/module/_helper/register_module.py +33 -0
- zrb/builtin/project/add/fastapp/module/module.py +8 -37
- zrb/builtin/project/add/fastapp/module/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/migrate.py +2 -2
- zrb/builtin/project/add/fastapp/module/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/register_module.py +8 -8
- zrb/builtin/project/add/plugin/plugin.py +2 -2
- zrb/builtin/project/create/create.py +2 -2
- zrb/builtin/version.py +3 -3
- zrb/config/config.py +14 -14
- zrb/helper/callable.py +3 -1
- zrb/helper/cli.py +4 -4
- zrb/helper/log.py +3 -3
- zrb/helper/typecheck.py +2 -2
- zrb/helper/typing.py +2 -2
- zrb/helper/util.py +12 -0
- zrb/runner.py +2 -2
- zrb/task/base_task/base_task.py +3 -3
- zrb/task/base_task/component/base_task_model.py +9 -9
- zrb/task/cmd_task.py +4 -4
- zrb/task/docker_compose_start_task.py +151 -0
- zrb/task/docker_compose_task.py +32 -15
- zrb/task_input/base_input.py +2 -2
- zrb/task_input/multiline_input.py +2 -2
- {zrb-0.23.4.dist-info → zrb-0.24.0.dist-info}/METADATA +2 -2
- {zrb-0.23.4.dist-info → zrb-0.24.0.dist-info}/RECORD +90 -73
- zrb/builtin/project/add/app/generator/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/snake_zrb_generator_name/template/_automate/snake_zrb_app_name/container/init.py +0 -34
- zrb/builtin/project/add/app/python/template/_automate/snake_zrb_app_name/container/init.py +0 -34
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/microservices/init.py +0 -36
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/monolith/init.py +0 -36
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/support/init.py +0 -26
- zrb/builtin/project/add/fastapp/crud/_helper.py +0 -118
- zrb/builtin/project/add/fastapp/field/_helper.py +0 -328
- zrb/builtin/project/add/fastapp/module/_helper.py +0 -313
- {zrb-0.23.4.dist-info → zrb-0.24.0.dist-info}/LICENSE +0 -0
- {zrb-0.23.4.dist-info → zrb-0.24.0.dist-info}/WHEEL +0 -0
- {zrb-0.23.4.dist-info → zrb-0.24.0.dist-info}/entry_points.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
import logging
|
2
2
|
|
3
|
-
from config import
|
3
|
+
from config import APP_ENABLE_OTEL, APP_LOGGING_LEVEL, APP_OTEL_EXPORTER_OTLP_ENDPOINT
|
4
4
|
from opentelemetry._logs import set_logger_provider
|
5
5
|
from opentelemetry.exporter.otlp.proto.grpc._log_exporter import OTLPLogExporter
|
6
6
|
from opentelemetry.sdk._logs import LoggerProvider, LoggingHandler
|
@@ -10,14 +10,14 @@ from opentelemetry.sdk._logs.export import BatchLogRecordProcessor
|
|
10
10
|
# Create logger
|
11
11
|
##############################################################################
|
12
12
|
logger = logging.getLogger("src")
|
13
|
-
logger.setLevel(
|
13
|
+
logger.setLevel(APP_LOGGING_LEVEL)
|
14
14
|
|
15
15
|
##############################################################################
|
16
16
|
# Formatter log handler
|
17
17
|
##############################################################################
|
18
18
|
|
19
19
|
stream_handler = logging.StreamHandler()
|
20
|
-
stream_handler.setLevel(
|
20
|
+
stream_handler.setLevel(APP_LOGGING_LEVEL)
|
21
21
|
# create formatter
|
22
22
|
formatter = logging.Formatter("%(levelname)s:\t%(message)s")
|
23
23
|
# set stream handler's formatter
|
@@ -29,17 +29,17 @@ logger.addHandler(stream_handler)
|
|
29
29
|
# Open telemetry log handler
|
30
30
|
##############################################################################
|
31
31
|
|
32
|
-
if
|
32
|
+
if APP_ENABLE_OTEL:
|
33
33
|
# create logger providers
|
34
34
|
otlp_logger_provider = LoggerProvider()
|
35
35
|
# set the providers
|
36
36
|
set_logger_provider(otlp_logger_provider)
|
37
|
-
otlp_log_exporter = OTLPLogExporter(endpoint=
|
37
|
+
otlp_log_exporter = OTLPLogExporter(endpoint=APP_OTEL_EXPORTER_OTLP_ENDPOINT)
|
38
38
|
# add the batch processors to the trace provider
|
39
39
|
otlp_logger_provider.add_log_record_processor(
|
40
40
|
BatchLogRecordProcessor(otlp_log_exporter)
|
41
41
|
)
|
42
42
|
otlp_log_handler = LoggingHandler(
|
43
|
-
level=
|
43
|
+
level=APP_LOGGING_LEVEL, logger_provider=otlp_logger_provider
|
44
44
|
)
|
45
45
|
logger.addHandler(otlp_log_handler)
|
zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/messagebus.py
CHANGED
@@ -14,31 +14,31 @@ from component.messagebus import (
|
|
14
14
|
RMQPublisher,
|
15
15
|
)
|
16
16
|
from config import (
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
APP_BROKER_TYPE,
|
18
|
+
APP_KAFKA_BOOTSTRAP_SERVERS,
|
19
|
+
APP_KAFKA_SASL_MECHANISM,
|
20
|
+
APP_KAFKA_SASL_PASS,
|
21
|
+
APP_KAFKA_SASL_USER,
|
22
|
+
APP_KAFKA_SECURITY_PROTOCOL,
|
23
|
+
APP_NAME,
|
24
|
+
APP_RMQ_CONNECTION_STRING,
|
25
25
|
)
|
26
26
|
from integration.log import logger
|
27
27
|
|
28
28
|
|
29
29
|
def init_admin(default_admin: Admin) -> Admin:
|
30
|
-
if
|
30
|
+
if APP_BROKER_TYPE == "rabbitmq":
|
31
31
|
return RMQAdmin(
|
32
|
-
logger=logger, connection_string=
|
32
|
+
logger=logger, connection_string=APP_RMQ_CONNECTION_STRING, configs={}
|
33
33
|
)
|
34
|
-
if
|
34
|
+
if APP_BROKER_TYPE == "kafka":
|
35
35
|
return KafkaAdmin(
|
36
36
|
logger=logger,
|
37
|
-
bootstrap_servers=
|
38
|
-
security_protocol=
|
39
|
-
sasl_mechanism=
|
40
|
-
sasl_plain_username=
|
41
|
-
sasl_plain_password=
|
37
|
+
bootstrap_servers=APP_KAFKA_BOOTSTRAP_SERVERS,
|
38
|
+
security_protocol=APP_KAFKA_SECURITY_PROTOCOL,
|
39
|
+
sasl_mechanism=APP_KAFKA_SASL_MECHANISM,
|
40
|
+
sasl_plain_username=APP_KAFKA_SASL_USER,
|
41
|
+
sasl_plain_password=APP_KAFKA_SASL_PASS,
|
42
42
|
configs={},
|
43
43
|
)
|
44
44
|
return default_admin
|
@@ -47,21 +47,21 @@ def init_admin(default_admin: Admin) -> Admin:
|
|
47
47
|
def init_publisher(
|
48
48
|
serializer: MessageSerializer, admin: Admin, default_publisher: Publisher
|
49
49
|
) -> Publisher:
|
50
|
-
if
|
50
|
+
if APP_BROKER_TYPE == "rabbitmq":
|
51
51
|
return RMQPublisher(
|
52
52
|
logger=logger,
|
53
|
-
connection_string=
|
53
|
+
connection_string=APP_RMQ_CONNECTION_STRING,
|
54
54
|
serializer=serializer,
|
55
55
|
rmq_admin=admin,
|
56
56
|
)
|
57
|
-
if
|
57
|
+
if APP_BROKER_TYPE == "kafka":
|
58
58
|
return KafkaPublisher(
|
59
59
|
logger=logger,
|
60
|
-
bootstrap_servers=
|
61
|
-
security_protocol=
|
62
|
-
sasl_mechanism=
|
63
|
-
sasl_plain_username=
|
64
|
-
sasl_plain_password=
|
60
|
+
bootstrap_servers=APP_KAFKA_BOOTSTRAP_SERVERS,
|
61
|
+
security_protocol=APP_KAFKA_SECURITY_PROTOCOL,
|
62
|
+
sasl_mechanism=APP_KAFKA_SASL_MECHANISM,
|
63
|
+
sasl_plain_username=APP_KAFKA_SASL_USER,
|
64
|
+
sasl_plain_password=APP_KAFKA_SASL_PASS,
|
65
65
|
serializer=serializer,
|
66
66
|
kafka_admin=admin,
|
67
67
|
)
|
@@ -71,22 +71,22 @@ def init_publisher(
|
|
71
71
|
def init_consumer(
|
72
72
|
serializer: MessageSerializer, admin: Admin, default_consumer: Consumer
|
73
73
|
) -> Consumer:
|
74
|
-
if
|
74
|
+
if APP_BROKER_TYPE == "rabbitmq":
|
75
75
|
return RMQConsumer(
|
76
76
|
logger=logger,
|
77
|
-
connection_string=
|
77
|
+
connection_string=APP_RMQ_CONNECTION_STRING,
|
78
78
|
serializer=serializer,
|
79
79
|
rmq_admin=admin,
|
80
80
|
)
|
81
|
-
if
|
81
|
+
if APP_BROKER_TYPE == "kafka":
|
82
82
|
return KafkaConsumer(
|
83
83
|
logger=logger,
|
84
|
-
bootstrap_servers=
|
85
|
-
security_protocol=
|
86
|
-
sasl_mechanism=
|
87
|
-
sasl_plain_username=
|
88
|
-
sasl_plain_password=
|
89
|
-
group_id=
|
84
|
+
bootstrap_servers=APP_KAFKA_BOOTSTRAP_SERVERS,
|
85
|
+
security_protocol=APP_KAFKA_SECURITY_PROTOCOL,
|
86
|
+
sasl_mechanism=APP_KAFKA_SASL_MECHANISM,
|
87
|
+
sasl_plain_username=APP_KAFKA_SASL_USER,
|
88
|
+
sasl_plain_password=APP_KAFKA_SASL_PASS,
|
89
|
+
group_id=APP_NAME,
|
90
90
|
serializer=serializer,
|
91
91
|
kafka_admin=admin,
|
92
92
|
)
|
@@ -1,10 +1,10 @@
|
|
1
1
|
from component.messagebus import KafkaConsumer, RMQConsumer
|
2
2
|
from component.rpc import Caller, MessagebusCaller, MessagebusServer, Server
|
3
3
|
from config import (
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
APP_BROKER_TYPE,
|
5
|
+
APP_KAFKA_BOOTSTRAP_SERVERS,
|
6
|
+
APP_NAME,
|
7
|
+
APP_RMQ_CONNECTION_STRING,
|
8
8
|
)
|
9
9
|
from integration.log import logger
|
10
10
|
from integration.messagebus import (
|
@@ -18,20 +18,20 @@ from ulid import ULID
|
|
18
18
|
|
19
19
|
|
20
20
|
def create_consumer():
|
21
|
-
if
|
21
|
+
if APP_BROKER_TYPE == "rabbitmq":
|
22
22
|
return RMQConsumer(
|
23
23
|
logger=logger,
|
24
|
-
connection_string=
|
24
|
+
connection_string=APP_RMQ_CONNECTION_STRING,
|
25
25
|
serializer=message_serializer,
|
26
26
|
rmq_admin=admin,
|
27
27
|
identifier="rmq-rpc-reply-consumer",
|
28
28
|
)
|
29
|
-
if
|
29
|
+
if APP_BROKER_TYPE == "kafka":
|
30
30
|
random_uuid = str(ULID())
|
31
|
-
group_id = f"{
|
31
|
+
group_id = f"{APP_NAME}-reply-{random_uuid}"
|
32
32
|
return KafkaConsumer(
|
33
33
|
logger=logger,
|
34
|
-
bootstrap_servers=
|
34
|
+
bootstrap_servers=APP_KAFKA_BOOTSTRAP_SERVERS,
|
35
35
|
group_id=group_id,
|
36
36
|
serializer=message_serializer,
|
37
37
|
kafka_admin=admin,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from config import
|
1
|
+
from config import APP_AUTH_ACCESS_TOKEN_COOKIE_KEY
|
2
2
|
from module.auth.component import (
|
3
3
|
AccessTokenScheme,
|
4
4
|
create_oauth2_bearer_access_token_scheme,
|
@@ -11,6 +11,6 @@ access_token_scheme: AccessTokenScheme = (
|
|
11
11
|
guest_user=guest_user,
|
12
12
|
access_token_util=access_token_util,
|
13
13
|
token_url="/api/v1/auth/login-oauth",
|
14
|
-
token_cookie_key=
|
14
|
+
token_cookie_key=APP_AUTH_ACCESS_TOKEN_COOKIE_KEY,
|
15
15
|
)
|
16
16
|
)
|
@@ -1,18 +1,18 @@
|
|
1
1
|
from config import (
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
APP_AUTH_ACCESS_TOKEN_TYPE,
|
3
|
+
APP_AUTH_JWT_TOKEN_ALGORITHM,
|
4
|
+
APP_AUTH_JWT_TOKEN_SECRET_KEY,
|
5
5
|
)
|
6
6
|
from module.auth.component import AccessTokenUtil, JWTAccessTokenUtil
|
7
7
|
|
8
8
|
|
9
9
|
def init_token_util() -> AccessTokenUtil:
|
10
|
-
if
|
10
|
+
if APP_AUTH_ACCESS_TOKEN_TYPE.lower() == "jwt":
|
11
11
|
return JWTAccessTokenUtil(
|
12
|
-
secret_key=
|
13
|
-
algorithm=
|
12
|
+
secret_key=APP_AUTH_JWT_TOKEN_SECRET_KEY,
|
13
|
+
algorithm=APP_AUTH_JWT_TOKEN_ALGORITHM,
|
14
14
|
)
|
15
|
-
raise ValueError(f"Invalid auth token type: {
|
15
|
+
raise ValueError(f"Invalid auth token type: {APP_AUTH_ACCESS_TOKEN_TYPE}")
|
16
16
|
|
17
17
|
|
18
18
|
access_token_util = init_token_util()
|
@@ -1,7 +1,7 @@
|
|
1
1
|
from config import (
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
APP_AUTH_ACCESS_TOKEN_EXPIRE_SECONDS,
|
3
|
+
APP_AUTH_ADMIN_ACTIVE,
|
4
|
+
APP_AUTH_REFRESH_TOKEN_EXPIRE_SECONDS,
|
5
5
|
)
|
6
6
|
from integration.messagebus import publisher
|
7
7
|
from module.auth.entity.user.model import UserModel
|
@@ -15,10 +15,10 @@ user_model: UserModel = UserModel(
|
|
15
15
|
publisher=publisher,
|
16
16
|
permission_model=permission_model,
|
17
17
|
access_token_util=access_token_util,
|
18
|
-
access_token_expire_seconds=
|
18
|
+
access_token_expire_seconds=APP_AUTH_ACCESS_TOKEN_EXPIRE_SECONDS,
|
19
19
|
refresh_token_util=refresh_token_util,
|
20
|
-
refresh_token_expire_seconds=
|
20
|
+
refresh_token_expire_seconds=APP_AUTH_REFRESH_TOKEN_EXPIRE_SECONDS,
|
21
21
|
guest_user=guest_user,
|
22
|
-
admin_user=admin_user if
|
22
|
+
admin_user=admin_user if APP_AUTH_ADMIN_ACTIVE else None,
|
23
23
|
admin_user_password=admin_user_password,
|
24
24
|
)
|
@@ -1,18 +1,18 @@
|
|
1
1
|
from config import (
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
APP_AUTH_JWT_TOKEN_ALGORITHM,
|
3
|
+
APP_AUTH_JWT_TOKEN_SECRET_KEY,
|
4
|
+
APP_AUTH_REFRESH_TOKEN_TYPE,
|
5
5
|
)
|
6
6
|
from module.auth.component import JWTRefreshTokenUtil, RefreshTokenUtil
|
7
7
|
|
8
8
|
|
9
9
|
def init_token_util() -> RefreshTokenUtil:
|
10
|
-
if
|
10
|
+
if APP_AUTH_REFRESH_TOKEN_TYPE.lower() == "jwt":
|
11
11
|
return JWTRefreshTokenUtil(
|
12
|
-
secret_key=
|
13
|
-
algorithm=
|
12
|
+
secret_key=APP_AUTH_JWT_TOKEN_SECRET_KEY,
|
13
|
+
algorithm=APP_AUTH_JWT_TOKEN_ALGORITHM,
|
14
14
|
)
|
15
|
-
raise ValueError(f"Invalid auth token type: {
|
15
|
+
raise ValueError(f"Invalid auth token type: {APP_AUTH_REFRESH_TOKEN_TYPE}")
|
16
16
|
|
17
17
|
|
18
18
|
refresh_token_util = init_token_util()
|
@@ -1,33 +1,33 @@
|
|
1
1
|
from config import (
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
APP_AUTH_ADMIN_EMAIL,
|
3
|
+
APP_AUTH_ADMIN_PASSWORD,
|
4
|
+
APP_AUTH_ADMIN_PHONE,
|
5
|
+
APP_AUTH_ADMIN_USER_ID,
|
6
|
+
APP_AUTH_ADMIN_USERNAME,
|
7
|
+
APP_AUTH_GUEST_EMAIL,
|
8
|
+
APP_AUTH_GUEST_PHONE,
|
9
|
+
APP_AUTH_GUEST_USER_ID,
|
10
|
+
APP_AUTH_GUEST_USERNAME,
|
11
11
|
)
|
12
12
|
from module.auth.schema.user import User
|
13
13
|
|
14
|
-
admin_user_password =
|
14
|
+
admin_user_password = APP_AUTH_ADMIN_PASSWORD
|
15
15
|
|
16
16
|
admin_user = User(
|
17
|
-
id=
|
18
|
-
username=
|
19
|
-
email=
|
20
|
-
phone=
|
17
|
+
id=APP_AUTH_ADMIN_USER_ID,
|
18
|
+
username=APP_AUTH_ADMIN_USERNAME,
|
19
|
+
email=APP_AUTH_ADMIN_EMAIL,
|
20
|
+
phone=APP_AUTH_ADMIN_PHONE,
|
21
21
|
groups=[],
|
22
22
|
permissions=[],
|
23
23
|
description="System administrator",
|
24
24
|
)
|
25
25
|
|
26
26
|
guest_user = User(
|
27
|
-
id=
|
28
|
-
username=
|
29
|
-
email=
|
30
|
-
phone=
|
27
|
+
id=APP_AUTH_GUEST_USER_ID,
|
28
|
+
username=APP_AUTH_GUEST_USERNAME,
|
29
|
+
email=APP_AUTH_GUEST_EMAIL,
|
30
|
+
phone=APP_AUTH_GUEST_PHONE,
|
31
31
|
groups=[],
|
32
32
|
permissions=[],
|
33
33
|
description="Visitor",
|
zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/migrate.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
from config import
|
1
|
+
from config import APP_ENABLE_AUTH_MODULE
|
2
2
|
from helper.migration import migrate
|
3
3
|
from integration.db_connection import engine
|
4
4
|
from integration.log import logger
|
@@ -7,7 +7,7 @@ from module.auth.register_permission import register_permission
|
|
7
7
|
|
8
8
|
|
9
9
|
async def migrate_auth():
|
10
|
-
if not
|
10
|
+
if not APP_ENABLE_AUTH_MODULE:
|
11
11
|
logger.info('🥪 Skip DB migration for "auth"')
|
12
12
|
return
|
13
13
|
logger.info('🥪 Perform DB migration for "auth"')
|
@@ -1,8 +1,8 @@
|
|
1
1
|
from config import (
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
APP_ENABLE_API,
|
3
|
+
APP_ENABLE_AUTH_MODULE,
|
4
|
+
APP_ENABLE_EVENT_HANDLER,
|
5
|
+
APP_ENABLE_RPC_SERVER,
|
6
6
|
)
|
7
7
|
from integration.app.app import app
|
8
8
|
from integration.log import logger
|
@@ -15,10 +15,10 @@ from module.auth.rpc import register_rpc
|
|
15
15
|
|
16
16
|
|
17
17
|
def register_auth():
|
18
|
-
if not
|
18
|
+
if not APP_ENABLE_AUTH_MODULE:
|
19
19
|
logger.info('🥪 Skip registering "auth"')
|
20
20
|
return
|
21
|
-
if
|
21
|
+
if APP_ENABLE_API:
|
22
22
|
register_api(
|
23
23
|
logger=logger,
|
24
24
|
app=app,
|
@@ -26,11 +26,11 @@ def register_auth():
|
|
26
26
|
rpc_caller=rpc_caller,
|
27
27
|
publisher=publisher,
|
28
28
|
)
|
29
|
-
if
|
29
|
+
if APP_ENABLE_EVENT_HANDLER:
|
30
30
|
register_event(
|
31
31
|
logger=logger, consumer=consumer, rpc_caller=rpc_caller, publisher=publisher
|
32
32
|
)
|
33
|
-
if
|
33
|
+
if APP_ENABLE_RPC_SERVER:
|
34
34
|
register_rpc(
|
35
35
|
logger=logger,
|
36
36
|
rpc_server=rpc_server,
|
zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/log/migrate.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
from config import
|
1
|
+
from config import APP_ENABLE_LOG_MODULE
|
2
2
|
from helper.migration import migrate
|
3
3
|
from integration.db_connection import engine
|
4
4
|
from integration.log import logger
|
@@ -6,7 +6,7 @@ from module.log.integration import Base
|
|
6
6
|
|
7
7
|
|
8
8
|
async def migrate_log():
|
9
|
-
if not
|
9
|
+
if not APP_ENABLE_LOG_MODULE:
|
10
10
|
logger.info('🥪 Skip DB migration for "log"')
|
11
11
|
return
|
12
12
|
logger.info('🥪 Perform DB migration for "log"')
|
@@ -1,8 +1,8 @@
|
|
1
1
|
from config import (
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
APP_ENABLE_API,
|
3
|
+
APP_ENABLE_EVENT_HANDLER,
|
4
|
+
APP_ENABLE_LOG_MODULE,
|
5
|
+
APP_ENABLE_RPC_SERVER,
|
6
6
|
)
|
7
7
|
from integration.app.app import app
|
8
8
|
from integration.log import logger
|
@@ -15,10 +15,10 @@ from module.log.rpc import register_rpc
|
|
15
15
|
|
16
16
|
|
17
17
|
def register_log():
|
18
|
-
if not
|
18
|
+
if not APP_ENABLE_LOG_MODULE:
|
19
19
|
logger.info('🥪 Skip registering "log"')
|
20
20
|
return
|
21
|
-
if
|
21
|
+
if APP_ENABLE_API:
|
22
22
|
register_api(
|
23
23
|
logger=logger,
|
24
24
|
app=app,
|
@@ -26,11 +26,11 @@ def register_log():
|
|
26
26
|
rpc_caller=rpc_caller,
|
27
27
|
publisher=publisher,
|
28
28
|
)
|
29
|
-
if
|
29
|
+
if APP_ENABLE_EVENT_HANDLER:
|
30
30
|
register_event(
|
31
31
|
logger=logger, consumer=consumer, rpc_caller=rpc_caller, publisher=publisher
|
32
32
|
)
|
33
|
-
if
|
33
|
+
if APP_ENABLE_RPC_SERVER:
|
34
34
|
register_rpc(
|
35
35
|
logger=logger,
|
36
36
|
rpc_server=rpc_server,
|
@@ -10,8 +10,8 @@ APP_OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
|
|
10
10
|
|
11
11
|
PUBLIC_BRAND=PascalZrbAppName
|
12
12
|
PUBLIC_TITLE=PascalZrbAppName
|
13
|
-
|
14
|
-
|
13
|
+
APP_AUTH_ACCESS_TOKEN_COOKIE_KEY=access_token
|
14
|
+
APP_AUTH_REFRESH_TOKEN_COOKIE_KEY=refresh_token
|
15
15
|
|
16
16
|
APP_AUTH_ACCESS_TOKEN_EXPIRE_SECONDS=300
|
17
17
|
APP_AUTH_ACCESS_TOKEN_TYPE=jwt
|
@@ -36,6 +36,9 @@ APP_AUTH_GUEST_PHONE=
|
|
36
36
|
APP_DB_CONNECTION=postgresql+psycopg2://postgres:admin@localhost:5432/snake_zrb_app_name
|
37
37
|
APP_DB_ENGINE_SHOW_LOG=false
|
38
38
|
APP_DB_AUTO_MIGRATE=true
|
39
|
+
APP_DB_POOL_PRE_PING=true
|
40
|
+
APP_DB_POOL_SIZE=20
|
41
|
+
APP_DB_POOL_MAX_OVERFLOW=0
|
39
42
|
|
40
43
|
APP_BROKER_TYPE=rabbitmq
|
41
44
|
|
zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_group_crud.py
CHANGED
@@ -2,7 +2,7 @@ from typing import AsyncIterator
|
|
2
2
|
|
3
3
|
import pytest
|
4
4
|
from httpx import AsyncClient
|
5
|
-
from src.config import
|
5
|
+
from src.config import APP_AUTH_ADMIN_PASSWORD, APP_AUTH_ADMIN_USERNAME
|
6
6
|
|
7
7
|
inserted_success_data = {
|
8
8
|
"name": "test-create-group-success",
|
@@ -35,8 +35,8 @@ async def test_insert_group_and_get_success(
|
|
35
35
|
login_admin_response = await client.post(
|
36
36
|
"/api/v1/auth/login",
|
37
37
|
json={
|
38
|
-
"identity":
|
39
|
-
"password":
|
38
|
+
"identity": APP_AUTH_ADMIN_USERNAME,
|
39
|
+
"password": APP_AUTH_ADMIN_PASSWORD,
|
40
40
|
},
|
41
41
|
)
|
42
42
|
assert login_admin_response.status_code == 200
|
@@ -88,8 +88,8 @@ async def test_update_group_and_get_success(
|
|
88
88
|
login_admin_response = await client.post(
|
89
89
|
"/api/v1/auth/login",
|
90
90
|
json={
|
91
|
-
"identity":
|
92
|
-
"password":
|
91
|
+
"identity": APP_AUTH_ADMIN_USERNAME,
|
92
|
+
"password": APP_AUTH_ADMIN_PASSWORD,
|
93
93
|
},
|
94
94
|
)
|
95
95
|
assert login_admin_response.status_code == 200
|
@@ -155,8 +155,8 @@ async def test_delete_group_and_get_success(
|
|
155
155
|
login_admin_response = await client.post(
|
156
156
|
"/api/v1/auth/login",
|
157
157
|
json={
|
158
|
-
"identity":
|
159
|
-
"password":
|
158
|
+
"identity": APP_AUTH_ADMIN_USERNAME,
|
159
|
+
"password": APP_AUTH_ADMIN_PASSWORD,
|
160
160
|
},
|
161
161
|
)
|
162
162
|
assert login_admin_response.status_code == 200
|
@@ -2,7 +2,7 @@ from typing import AsyncIterator
|
|
2
2
|
|
3
3
|
import pytest
|
4
4
|
from httpx import AsyncClient
|
5
|
-
from src.config import
|
5
|
+
from src.config import APP_AUTH_ADMIN_PASSWORD, APP_AUTH_ADMIN_USERNAME
|
6
6
|
|
7
7
|
inserted_success_data = {
|
8
8
|
"name": "test-create-permission-success",
|
@@ -31,8 +31,8 @@ async def test_insert_permission_and_get_success(
|
|
31
31
|
login_admin_response = await client.post(
|
32
32
|
"/api/v1/auth/login",
|
33
33
|
json={
|
34
|
-
"identity":
|
35
|
-
"password":
|
34
|
+
"identity": APP_AUTH_ADMIN_USERNAME,
|
35
|
+
"password": APP_AUTH_ADMIN_PASSWORD,
|
36
36
|
},
|
37
37
|
)
|
38
38
|
assert login_admin_response.status_code == 200
|
@@ -84,8 +84,8 @@ async def test_update_permission_and_get_success(
|
|
84
84
|
login_admin_response = await client.post(
|
85
85
|
"/api/v1/auth/login",
|
86
86
|
json={
|
87
|
-
"identity":
|
88
|
-
"password":
|
87
|
+
"identity": APP_AUTH_ADMIN_USERNAME,
|
88
|
+
"password": APP_AUTH_ADMIN_PASSWORD,
|
89
89
|
"permissions": [],
|
90
90
|
},
|
91
91
|
)
|
@@ -152,8 +152,8 @@ async def test_delete_permission_and_get_success(
|
|
152
152
|
login_admin_response = await client.post(
|
153
153
|
"/api/v1/auth/login",
|
154
154
|
json={
|
155
|
-
"identity":
|
156
|
-
"password":
|
155
|
+
"identity": APP_AUTH_ADMIN_USERNAME,
|
156
|
+
"password": APP_AUTH_ADMIN_PASSWORD,
|
157
157
|
},
|
158
158
|
)
|
159
159
|
assert login_admin_response.status_code == 200
|
zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_user_crud.py
CHANGED
@@ -2,7 +2,7 @@ from typing import AsyncIterator
|
|
2
2
|
|
3
3
|
import pytest
|
4
4
|
from httpx import AsyncClient
|
5
|
-
from src.config import
|
5
|
+
from src.config import APP_AUTH_ADMIN_PASSWORD, APP_AUTH_ADMIN_USERNAME
|
6
6
|
|
7
7
|
inserted_success_data = {
|
8
8
|
"username": "test-create-user-success",
|
@@ -51,8 +51,8 @@ async def test_insert_user_and_get_success(
|
|
51
51
|
login_admin_response = await client.post(
|
52
52
|
"/api/v1/auth/login",
|
53
53
|
json={
|
54
|
-
"identity":
|
55
|
-
"password":
|
54
|
+
"identity": APP_AUTH_ADMIN_USERNAME,
|
55
|
+
"password": APP_AUTH_ADMIN_PASSWORD,
|
56
56
|
},
|
57
57
|
)
|
58
58
|
assert login_admin_response.status_code == 200
|
@@ -104,8 +104,8 @@ async def test_update_user_and_get_success(
|
|
104
104
|
login_admin_response = await client.post(
|
105
105
|
"/api/v1/auth/login",
|
106
106
|
json={
|
107
|
-
"identity":
|
108
|
-
"password":
|
107
|
+
"identity": APP_AUTH_ADMIN_USERNAME,
|
108
|
+
"password": APP_AUTH_ADMIN_PASSWORD,
|
109
109
|
},
|
110
110
|
)
|
111
111
|
assert login_admin_response.status_code == 200
|
@@ -171,8 +171,8 @@ async def test_delete_user_and_get_success(
|
|
171
171
|
login_admin_response = await client.post(
|
172
172
|
"/api/v1/auth/login",
|
173
173
|
json={
|
174
|
-
"identity":
|
175
|
-
"password":
|
174
|
+
"identity": APP_AUTH_ADMIN_USERNAME,
|
175
|
+
"password": APP_AUTH_ADMIN_PASSWORD,
|
176
176
|
},
|
177
177
|
)
|
178
178
|
assert login_admin_response.status_code == 200
|