From cd61cb38478110e71ecc49af44a82692fe66abdd Mon Sep 17 00:00:00 2001 From: Jens L Date: Fri, 5 Jan 2024 13:13:32 +0100 Subject: [PATCH] rbac: fix error when looking up permissions for now uninstalled apps (#8068) Signed-off-by: Jens Langhammer --- authentik/rbac/api/rbac_roles.py | 5 ++++- authentik/rbac/api/rbac_users.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/authentik/rbac/api/rbac_roles.py b/authentik/rbac/api/rbac_roles.py index 1c48169a2..1ef13c115 100644 --- a/authentik/rbac/api/rbac_roles.py +++ b/authentik/rbac/api/rbac_roles.py @@ -24,7 +24,10 @@ class ExtraRoleObjectPermissionSerializer(RoleObjectPermissionSerializer): def get_app_label_verbose(self, instance: GroupObjectPermission) -> str: """Get app label from permission's model""" - return apps.get_app_config(instance.content_type.app_label).verbose_name + try: + return apps.get_app_config(instance.content_type.app_label).verbose_name + except LookupError: + return instance.content_type.app_label def get_model_verbose(self, instance: GroupObjectPermission) -> str: """Get model label from permission's model""" diff --git a/authentik/rbac/api/rbac_users.py b/authentik/rbac/api/rbac_users.py index 636b327f3..6de2e8bce 100644 --- a/authentik/rbac/api/rbac_users.py +++ b/authentik/rbac/api/rbac_users.py @@ -24,7 +24,10 @@ class ExtraUserObjectPermissionSerializer(UserObjectPermissionSerializer): def get_app_label_verbose(self, instance: UserObjectPermission) -> str: """Get app label from permission's model""" - return apps.get_app_config(instance.content_type.app_label).verbose_name + try: + return apps.get_app_config(instance.content_type.app_label).verbose_name + except LookupError: + return instance.content_type.app_label def get_model_verbose(self, instance: UserObjectPermission) -> str: """Get model label from permission's model"""