Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
0d176b4
add: rw database routing
Naksen Jan 27, 2026
446d4ed
add: define RESPONSE_TYPE for various LDAP request classes
Naksen Jan 27, 2026
b277eff
add: handle OperationalError when setting user logon attributes
Naksen Jan 27, 2026
6aaa89f
add: implement master database check utility and apply it across vari…
Naksen Jan 27, 2026
8210872
test: update get_engine method to use master database engine
Naksen Jan 27, 2026
80472eb
fix: exclude ABANDON protocol from master DB availability checks
Naksen Jan 28, 2026
a591907
fix: remove unnecessary dependency on check_master_db for audit desti…
Naksen Jan 28, 2026
b53d1fd
fix: handle OperationalError specifically in master DB check
Naksen Jan 28, 2026
26a6101
refactor: format
Naksen Jan 28, 2026
c5eb4b0
fix: update POSTGRES_RW_MODE to use 'replication' instead of 'master_…
Naksen Jan 28, 2026
032f2ab
refactor: implement async engine management with EngineRegistry and u…
Naksen Jan 28, 2026
db35ba2
refactor: database module name
Naksen Jan 28, 2026
fa58052
refactor: rename check_master_db to require_master_db and update depe…
Naksen Jan 28, 2026
d04426a
fix: handle OperationalError by initializing responses to an empty list
Naksen Jan 28, 2026
9a9010c
refactor: update _add_app_sqlalchemy_debugger to accept settings para…
Naksen Jan 28, 2026
f55376d
refactor: format
Naksen Jan 28, 2026
e2fb0b2
fix: add _force_master flag to execute ops
Naksen Jan 28, 2026
6ea2c37
refactor: replace string literals with PostgresRWModeType enum for be…
Naksen Feb 6, 2026
676b0b6
fix: update dependencies for rename endpoint to require_master_db
Naksen Feb 6, 2026
514802f
refactor: implement master database check and gateway for PostgreSQL …
Naksen Feb 6, 2026
3f6e9da
test: add MasterCheckUseCase and PGMasterGateway to conftest for enha…
Naksen Feb 6, 2026
d6a86a4
fix: update replica_engine condition to check for SINGLE mode in Post…
Naksen Feb 6, 2026
a2f29d3
fix: enhance MasterCheckUseCase by adding PERMISSIONS attribute and o…
Naksen Feb 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions app/api/audit/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
DishkaErrorAwareRoute,
DomainErrorTranslator,
)
from api.utils import require_master_db
from enums import DomainCodes
from ldap_protocol.policies.audit.exception import (
AuditAlreadyExistsError,
Expand Down Expand Up @@ -59,7 +60,11 @@ async def get_audit_policies(
return await audit_adapter.get_policies()


@audit_router.put("/policy/{policy_id}", error_map=error_map)
@audit_router.put(
"/policy/{policy_id}",
error_map=error_map,
dependencies=[Depends(require_master_db)],
)
async def update_audit_policy(
policy_id: int,
policy_data: AuditPolicySchemaRequest,
Expand All @@ -81,6 +86,7 @@ async def get_audit_destinations(
"/destination",
status_code=status.HTTP_201_CREATED,
error_map=error_map,
dependencies=[Depends(require_master_db)],
)
async def create_audit_destination(
destination_data: AuditDestinationSchemaRequest,
Expand All @@ -90,7 +96,11 @@ async def create_audit_destination(
return await audit_adapter.create_destination(destination_data)


@audit_router.delete("/destination/{destination_id}", error_map=error_map)
@audit_router.delete(
"/destination/{destination_id}",
error_map=error_map,
dependencies=[Depends(require_master_db)],
)
async def delete_audit_destination(
destination_id: int,
audit_adapter: FromDishka[AuditPoliciesAdapter],
Expand All @@ -99,7 +109,11 @@ async def delete_audit_destination(
await audit_adapter.delete_destination(destination_id)


@audit_router.put("/destination/{destination_id}", error_map=error_map)
@audit_router.put(
"/destination/{destination_id}",
error_map=error_map,
dependencies=[Depends(require_master_db)],
)
async def update_audit_destination(
destination_id: int,
destination_data: AuditDestinationSchemaRequest,
Expand Down
4 changes: 3 additions & 1 deletion app/api/auth/router_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
DishkaErrorAwareRoute,
DomainErrorTranslator,
)
from api.utils import require_master_db
from enums import DomainCodes
from ldap_protocol.auth.exceptions.mfa import (
MFAAPIError,
Expand Down Expand Up @@ -186,7 +187,7 @@ async def logout(
@auth_router.patch(
"/user/password",
status_code=200,
dependencies=[Depends(verify_auth)],
dependencies=[Depends(verify_auth), Depends(require_master_db)],
error_map=error_map,
)
async def password_reset(
Expand Down Expand Up @@ -229,6 +230,7 @@ async def check_setup(
status_code=status.HTTP_200_OK,
responses={423: {"detail": "Locked"}},
error_map=error_map,
dependencies=[Depends(require_master_db)],
)
async def first_setup(
request: SetupRequest,
Expand Down
7 changes: 4 additions & 3 deletions app/api/auth/router_mfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
DishkaErrorAwareRoute,
DomainErrorTranslator,
)
from api.utils import require_master_db
from enums import DomainCodes
from ldap_protocol.auth.exceptions.mfa import (
ForbiddenError,
Expand Down Expand Up @@ -81,7 +82,7 @@
@mfa_router.post(
"/setup",
status_code=status.HTTP_201_CREATED,
dependencies=[Depends(verify_auth)],
dependencies=[Depends(verify_auth), Depends(require_master_db)],
error_map=error_map,
)
async def setup_mfa(
Expand All @@ -100,7 +101,7 @@ async def setup_mfa(

@mfa_router.delete(
"/keys",
dependencies=[Depends(verify_auth)],
dependencies=[Depends(verify_auth), Depends(require_master_db)],
error_map=error_map,
)
async def remove_mfa(
Expand All @@ -113,7 +114,7 @@ async def remove_mfa(

@mfa_router.post(
"/get",
dependencies=[Depends(verify_auth)],
dependencies=[Depends(verify_auth), Depends(require_master_db)],
error_map=error_map,
)
async def get_mfa(
Expand Down
6 changes: 5 additions & 1 deletion app/api/ldap_schema/attribute_type_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import Annotated

from dishka.integrations.fastapi import FromDishka
from fastapi import Query, status
from fastapi import Depends, Query, status

from api.ldap_schema import LimitedListType, error_map, ldap_schema_router
from api.ldap_schema.adapters.attribute_type import AttributeTypeFastAPIAdapter
Expand All @@ -16,13 +16,15 @@
AttributeTypeSchema,
AttributeTypeUpdateSchema,
)
from api.utils import require_master_db
from ldap_protocol.utils.pagination import PaginationParams


@ldap_schema_router.post(
"/attribute_type",
status_code=status.HTTP_201_CREATED,
error_map=error_map,
dependencies=[Depends(require_master_db)],
)
async def create_one_attribute_type(
request_data: AttributeTypeSchema[None],
Expand Down Expand Up @@ -59,6 +61,7 @@ async def get_list_attribute_types_with_pagination(
@ldap_schema_router.patch(
"/attribute_type/{attribute_type_name}",
error_map=error_map,
dependencies=[Depends(require_master_db)],
)
async def modify_one_attribute_type(
attribute_type_name: str,
Expand All @@ -72,6 +75,7 @@ async def modify_one_attribute_type(
@ldap_schema_router.post(
"/attribute_types/delete",
error_map=error_map,
dependencies=[Depends(require_master_db)],
)
async def delete_bulk_attribute_types(
attribute_types_names: LimitedListType,
Expand Down
11 changes: 9 additions & 2 deletions app/api/ldap_schema/entity_type_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import Annotated

from dishka.integrations.fastapi import FromDishka
from fastapi import Query, status
from fastapi import Depends, Query, status

from api.ldap_schema import LimitedListType, error_map
from api.ldap_schema.adapters.entity_type import LDAPEntityTypeFastAPIAdapter
Expand All @@ -17,13 +17,15 @@
EntityTypeSchema,
EntityTypeUpdateSchema,
)
from api.utils import require_master_db
from ldap_protocol.utils.pagination import PaginationParams


@ldap_schema_router.post(
"/entity_type",
status_code=status.HTTP_201_CREATED,
error_map=error_map,
dependencies=[Depends(require_master_db)],
)
async def create_one_entity_type(
request_data: EntityTypeSchema[None],
Expand Down Expand Up @@ -66,6 +68,7 @@ async def get_entity_type_attributes(
@ldap_schema_router.patch(
"/entity_type/{entity_type_name}",
error_map=error_map,
dependencies=[Depends(require_master_db)],
)
async def modify_one_entity_type(
entity_type_name: str,
Expand All @@ -76,7 +79,11 @@ async def modify_one_entity_type(
await adapter.update(name=entity_type_name, data=request_data)


@ldap_schema_router.post("/entity_type/delete", error_map=error_map)
@ldap_schema_router.post(
"/entity_type/delete",
error_map=error_map,
dependencies=[Depends(require_master_db)],
)
async def delete_bulk_entity_types(
entity_type_names: LimitedListType,
adapter: FromDishka[LDAPEntityTypeFastAPIAdapter],
Expand Down
11 changes: 9 additions & 2 deletions app/api/ldap_schema/object_class_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import Annotated

from dishka.integrations.fastapi import FromDishka
from fastapi import Query, status
from fastapi import Depends, Query, status

from api.ldap_schema import LimitedListType, error_map
from api.ldap_schema.adapters.object_class import ObjectClassFastAPIAdapter
Expand All @@ -17,13 +17,15 @@
ObjectClassSchema,
ObjectClassUpdateSchema,
)
from api.utils import require_master_db
from ldap_protocol.utils.pagination import PaginationParams


@ldap_schema_router.post(
"/object_class",
status_code=status.HTTP_201_CREATED,
error_map=error_map,
dependencies=[Depends(require_master_db)],
)
async def create_one_object_class(
request_data: ObjectClassSchema[None],
Expand Down Expand Up @@ -57,6 +59,7 @@ async def get_list_object_classes_with_pagination(
@ldap_schema_router.patch(
"/object_class/{object_class_name}",
error_map=error_map,
dependencies=[Depends(require_master_db)],
)
async def modify_one_object_class(
object_class_name: str,
Expand All @@ -67,7 +70,11 @@ async def modify_one_object_class(
await adapter.update(object_class_name, request_data)


@ldap_schema_router.post("/object_class/delete", error_map=error_map)
@ldap_schema_router.post(
"/object_class/delete",
error_map=error_map,
dependencies=[Depends(require_master_db)],
)
async def delete_bulk_object_classes(
object_classes_names: LimitedListType,
adapter: FromDishka[ObjectClassFastAPIAdapter],
Expand Down
7 changes: 6 additions & 1 deletion app/api/main/dns_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
DNSServiceZoneDeleteRequest,
DNSServiceZoneUpdateRequest,
)
from api.utils import require_master_db
from enums import DomainCodes
from ldap_protocol.dns import (
DNSForwardServerStatus,
Expand Down Expand Up @@ -139,7 +140,11 @@ async def get_dns_status(
return await adapter.get_dns_status()


@dns_router.post("/setup", error_map=error_map)
@dns_router.post(
"/setup",
error_map=error_map,
dependencies=[Depends(require_master_db)],
)
async def setup_dns(
data: DNSServiceSetupRequest,
adapter: FromDishka[DNSFastAPIAdapter],
Expand Down
18 changes: 12 additions & 6 deletions app/api/main/krb5_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
)
from api.main.adapters.kerberos import KerberosFastAPIAdapter
from api.main.schema import KerberosSetupRequest
from api.utils import require_master_db
from enums import DomainCodes
from ldap_protocol.dialogue import LDAPSession
from ldap_protocol.kerberos import KerberosState
Expand Down Expand Up @@ -82,7 +83,7 @@
"/setup/tree",
response_class=Response,
error_map=error_map,
dependencies=[Depends(verify_auth)],
dependencies=[Depends(verify_auth), Depends(require_master_db)],
)
async def setup_krb_catalogue(
mail: Annotated[EmailStr, Body()],
Expand All @@ -106,7 +107,12 @@ async def setup_krb_catalogue(
)


@krb5_router.post("/setup", response_class=Response, error_map=error_map)
@krb5_router.post(
"/setup",
response_class=Response,
error_map=error_map,
dependencies=[Depends(require_master_db)],
)
async def setup_kdc(
data: KerberosSetupRequest,
identity_adapter: FromDishka[AuthFastAPIAdapter],
Expand Down Expand Up @@ -173,7 +179,7 @@ async def get_krb_status(

@krb5_router.post(
"/principal/add",
dependencies=[Depends(verify_auth)],
dependencies=[Depends(verify_auth), Depends(require_master_db)],
error_map=error_map,
)
async def add_principal(
Expand All @@ -193,7 +199,7 @@ async def add_principal(

@krb5_router.patch(
"/principal/rename",
dependencies=[Depends(verify_auth)],
dependencies=[Depends(verify_auth), Depends(require_master_db)],
error_map=error_map,
)
async def rename_principal(
Expand All @@ -217,7 +223,7 @@ async def rename_principal(

@krb5_router.patch(
"/principal/reset",
dependencies=[Depends(verify_auth)],
dependencies=[Depends(verify_auth), Depends(require_master_db)],
error_map=error_map,
)
async def reset_principal_pw(
Expand All @@ -238,7 +244,7 @@ async def reset_principal_pw(

@krb5_router.delete(
"/principal/delete",
dependencies=[Depends(verify_auth)],
dependencies=[Depends(verify_auth), Depends(require_master_db)],
error_map=error_map,
)
async def delete_principal(
Expand Down
Loading