From e7f6127dd5295e55ea066d1bc3f4e2cf592dc493 Mon Sep 17 00:00:00 2001 From: zhu327 Date: Fri, 8 Oct 2021 16:52:28 +0800 Subject: [PATCH 1/2] fix(service/template.py): update_template_auth action expired_at emptry --- saas/backend/service/template.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/saas/backend/service/template.py b/saas/backend/service/template.py index 20eb391d0..b557bd448 100644 --- a/saas/backend/service/template.py +++ b/saas/backend/service/template.py @@ -17,6 +17,7 @@ from backend.apps.template.models import PermTemplate, PermTemplatePolicyAuthorized, PermTemplatePreGroupSync from backend.common.error_codes import error_codes +from backend.common.time import PERMANENT_SECONDS from backend.component import iam from .models import Policy, Subject, SystemCounter @@ -117,7 +118,7 @@ def update_template_auth(self, subject: Subject, template_id: int, policies: Lis """ authorized_template = PermTemplatePolicyAuthorized.objects.get_by_subject_template(subject, template_id) system_id = authorized_template.system_id - policy_list = PolicyList(parse_obj_as(List[Policy], authorized_template.data["actions"])) + policy_list = self._convert_template_actions_to_policy_list(authorized_template.data["actions"]) # 查询subject的后端权限信息 backend_policy_list = new_backend_policy_list_by_subject(system_id, subject, template_id) @@ -140,6 +141,15 @@ def update_template_auth(self, subject: Subject, template_id: int, policies: Lis system_id, subject.type, subject.id, template_id, [p.to_backend_dict() for p in policies] ) + def _convert_template_actions_to_policy_list(self, actions: List[Dict]) -> PolicyList: + """转换模板的授权的actions到PolicyList, 兼容过期时间为空的情况""" + policies = [] + for action in actions: + if "expired_at" not in action or not action["expired_at"]: + action["expired_at"] = PERMANENT_SECONDS + policies.append(Policy.parse_obj(action)) + return PolicyList(policies) + def list_system_counter_by_subject(self, subject: Subject) -> List[SystemCounter]: """ 查询subject有权限的系统-模板数量信息 From 641e9d20e43cc92b687181757bd6605dae9acc0e Mon Sep 17 00:00:00 2001 From: zhu327 Date: Fri, 8 Oct 2021 17:02:57 +0800 Subject: [PATCH 2/2] docs: v1.5.5 --- saas/VERSION | 2 +- saas/resources/version_log/V1.5.5_2021-10-08.md | 4 ++++ saas/resources/version_log/V1.5.5_2021-10-08_en.md | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 saas/resources/version_log/V1.5.5_2021-10-08.md create mode 100644 saas/resources/version_log/V1.5.5_2021-10-08_en.md diff --git a/saas/VERSION b/saas/VERSION index 94fe62c27..9075be495 100644 --- a/saas/VERSION +++ b/saas/VERSION @@ -1 +1 @@ -1.5.4 +1.5.5 diff --git a/saas/resources/version_log/V1.5.5_2021-10-08.md b/saas/resources/version_log/V1.5.5_2021-10-08.md new file mode 100644 index 000000000..e179d4578 --- /dev/null +++ b/saas/resources/version_log/V1.5.5_2021-10-08.md @@ -0,0 +1,4 @@ +# V1.5.5 版本更新日志 + +### 缺陷修复 +* 用户组更新模板授权报错 diff --git a/saas/resources/version_log/V1.5.5_2021-10-08_en.md b/saas/resources/version_log/V1.5.5_2021-10-08_en.md new file mode 100644 index 000000000..f1908362b --- /dev/null +++ b/saas/resources/version_log/V1.5.5_2021-10-08_en.md @@ -0,0 +1,4 @@ +# V1.5.5 ChangeLog + +### Bug Fixes +* User group update template authorization error