From 94c1d08519e37eac7f01f65f0ba080182fde87e6 Mon Sep 17 00:00:00 2001 From: Albrecht Degering Date: Wed, 29 Jul 2026 19:24:07 +0200 Subject: [PATCH] fix: invalidate auth context after IDM changes --- src/govoplan_idm/backend/api/v1/routes.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/govoplan_idm/backend/api/v1/routes.py b/src/govoplan_idm/backend/api/v1/routes.py index 4b28e3a..fd27872 100644 --- a/src/govoplan_idm/backend/api/v1/routes.py +++ b/src/govoplan_idm/backend/api/v1/routes.py @@ -23,6 +23,7 @@ from govoplan_core.core.events import ( PlatformEvent, emit_platform_event, ) +from govoplan_core.core.principal_cache import invalidate_auth_principals from govoplan_core.core.identity import ( CAPABILITY_IDENTITY_DIRECTORY, CAPABILITY_IDENTITY_SEARCH, @@ -110,6 +111,13 @@ def _get_tenant_row(session: Session, model: type[ModelT], item_id: str, tenant_ def _commit(session: Session, item: ModelT) -> ModelT: + invalidate_auth_principals( + session, + tenant_id=getattr(item, "tenant_id", None), + source_module="idm", + resource_type=item.__class__.__name__, + resource_id=str(getattr(item, "id", getattr(item, "tenant_id", "system"))), + ) try: session.commit() except IntegrityError as exc: @@ -136,6 +144,13 @@ def _commit_assignment_transaction( session: Session, item: IdmOrganizationFunctionAssignment, ) -> None: + invalidate_auth_principals( + session, + tenant_id=item.tenant_id, + source_module="idm", + resource_type="organization_function_assignment", + resource_id=item.id, + ) try: session.commit() except IntegrityError as exc: @@ -513,6 +528,13 @@ def update_idm_settings( before=before, after=result.model_dump(mode="json"), ) + invalidate_auth_principals( + session, + tenant_id=tenant_id, + source_module="idm", + resource_type="tenant_settings", + resource_id=tenant_id, + ) session.commit() session.refresh(item) return result