fix: invalidate auth context after IDM changes
This commit is contained in:
@@ -23,6 +23,7 @@ from govoplan_core.core.events import (
|
|||||||
PlatformEvent,
|
PlatformEvent,
|
||||||
emit_platform_event,
|
emit_platform_event,
|
||||||
)
|
)
|
||||||
|
from govoplan_core.core.principal_cache import invalidate_auth_principals
|
||||||
from govoplan_core.core.identity import (
|
from govoplan_core.core.identity import (
|
||||||
CAPABILITY_IDENTITY_DIRECTORY,
|
CAPABILITY_IDENTITY_DIRECTORY,
|
||||||
CAPABILITY_IDENTITY_SEARCH,
|
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:
|
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:
|
try:
|
||||||
session.commit()
|
session.commit()
|
||||||
except IntegrityError as exc:
|
except IntegrityError as exc:
|
||||||
@@ -136,6 +144,13 @@ def _commit_assignment_transaction(
|
|||||||
session: Session,
|
session: Session,
|
||||||
item: IdmOrganizationFunctionAssignment,
|
item: IdmOrganizationFunctionAssignment,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
invalidate_auth_principals(
|
||||||
|
session,
|
||||||
|
tenant_id=item.tenant_id,
|
||||||
|
source_module="idm",
|
||||||
|
resource_type="organization_function_assignment",
|
||||||
|
resource_id=item.id,
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
session.commit()
|
session.commit()
|
||||||
except IntegrityError as exc:
|
except IntegrityError as exc:
|
||||||
@@ -513,6 +528,13 @@ def update_idm_settings(
|
|||||||
before=before,
|
before=before,
|
||||||
after=result.model_dump(mode="json"),
|
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.commit()
|
||||||
session.refresh(item)
|
session.refresh(item)
|
||||||
return result
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user