Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.5.4 #229

Merged
merged 54 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
ce13251
feat: custom apply support instance approver
zhu327 Sep 14, 2021
e0bd756
fix: fix code
zhu327 Sep 15, 2021
e3e04a5
Merge remote-tracking branch 'upstream/develop' into feat_instance_ap…
zhu327 Sep 15, 2021
75ef254
style: add some comment
zhu327 Sep 15, 2021
8556d94
style: update processor node type constants
zhu327 Sep 15, 2021
d8c6ad6
Merge remote-tracking branch 'upstream/develop' into feat_instance_ap…
zhu327 Sep 15, 2021
5c53733
fix: 续期邮件企业微信链接显示问题 #158
Sep 15, 2021
adf4f74
fix: 修复续期邮件企业微信链接显示
Sep 16, 2021
766b10a
fix: itsm support has_instance_approver
zhu327 Sep 16, 2021
5ae84de
fix: fix has_instance_approver
zhu327 Sep 16, 2021
aa039f4
Merge branch 'develop' of https://github.com/huangpeng0428/bk-iam-saa…
Sep 16, 2021
92c73b2
fix(backend/plugins/application_ticket/itsm/itsm.py): has_instance_ap…
zhu327 Sep 17, 2021
199c1d1
fix: fix
zhu327 Sep 17, 2021
b2977e9
fix: isChanged status should add user.timestamp
Sep 18, 2021
3b4b329
fix: 我的权限用户组权限查看态提示删除bug #155
Sep 22, 2021
8313d82
fix: 资源实例无限制的权限,申请权限时不应该能修改 #92654581
Sep 23, 2021
84868f3
feat(backend/biz/application.py): support all node
zhu327 Sep 24, 2021
43c3935
style: rename
zhu327 Sep 24, 2021
a910825
fix: 业务跳转权限中心申请权限,申请期限不能修改 #92209761
Sep 24, 2021
e17e61e
fix(backend/biz/application.py): new method _copy_policy_by_instance_…
zhu327 Sep 26, 2021
2b8e5f9
test(tests/biz/policy_tests.py): add biz policy test
zhu327 Sep 26, 2021
f85bc88
fix: add BK_COMPONENT_API_URL
Sep 27, 2021
ea6e88b
Merge pull request #193 from huangpeng0428/develop
zhu327 Sep 27, 2021
d1e5f08
fix: delete console
Sep 27, 2021
750c1bc
Merge remote-tracking branch 'upstream/develop' into feat_instance_ap…
zhu327 Sep 27, 2021
f00824b
Ft grant open api add limit (#196)
nannan00 Sep 27, 2021
a0af309
refactor(backend/biz/application.py): refact approver process
zhu327 Sep 27, 2021
c030ae2
refactor: fix discussion
zhu327 Sep 27, 2021
6d8adb1
refactor: remove ApplicationBiz resource_biz
zhu327 Sep 27, 2021
da7e827
refactor: move policy process to process.py
zhu327 Sep 27, 2021
6fe1b7b
refactor: renmae process.py to application_process.py
zhu327 Sep 27, 2021
aeb17d4
Merge remote-tracking branch 'upstream/develop' into feat_apply_policy
zhu327 Sep 27, 2021
7ba4929
feat: cached apply policy return
zhu327 Sep 27, 2021
33077d6
fix: fix
zhu327 Sep 27, 2021
9143173
fix: fix
zhu327 Sep 27, 2021
6e63050
Merge pull request #160 from zhu327/feat_instance_approver
zhu327 Sep 28, 2021
8c2a15e
Merge pull request #198 from zhu327/feat_apply_policy
zhu327 Sep 28, 2021
40b7d6b
Merge remote-tracking branch 'upstream/develop' into develop
Sep 28, 2021
fe91995
fix: Super admin commonActions are empty #91071575
Sep 28, 2021
e999b32
Merge pull request #207 from huangpeng0428/develop
zhu327 Sep 28, 2021
5374a33
fix: bugfix
zhu327 Sep 28, 2021
7799bd1
Merge pull request #215 from zhu327/feat_instance_approver
zhu327 Sep 28, 2021
c1c6400
fix: 取消勾选对应权限的实例报错 #92356085 (#217)
huangpeng0428 Sep 28, 2021
2f73947
optimize the code (#219)
huangpeng0428 Sep 29, 2021
1402765
feat(backend/plugins/application_ticket/itsm/itsm.py): mod applicatio…
zhu327 Sep 29, 2021
ec82b4b
fix: fix style
zhu327 Sep 29, 2021
4011c85
style: fix style
zhu327 Sep 29, 2021
aed8ec0
feat(auth api): all api return policy with statistics
nannan00 Sep 29, 2021
755e337
Merge pull request #221 from nannan00/ft_auth_api_return_statistics
nannan00 Sep 29, 2021
8a2704e
Merge pull request #220 from zhu327/develop
nannan00 Sep 29, 2021
6494462
feat: related_policy add update tag
zhu327 Sep 29, 2021
7a4d328
docs: v1.5.4
zhu327 Sep 29, 2021
f8a3a04
修复后台关联数据时tag返回值bug (#226)
huangpeng0428 Sep 29, 2021
1e0e12b
Merge pull request #225 from zhu327/develop
zhu327 Sep 29, 2021
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
3 changes: 2 additions & 1 deletion frontend/build/paas-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ const GLOBAL_VAR = {
CSRF_COOKIE_NAME: process.env.CSRF_COOKIE_NAME || '',
SESSION_COOKIE_DOMAIN: process.env.SESSION_COOKIE_DOMAIN || '',
BK_ITSM_APP_URL: process.env.BK_ITSM_APP_URL || '',
ENABLE_MODEL_BUILD: process.env.ENABLE_MODEL_BUILD || ''
ENABLE_MODEL_BUILD: process.env.ENABLE_MODEL_BUILD || '',
BK_COMPONENT_API_URL: process.env.BK_COMPONENT_API_URL || ''
}

// APA 重定向回首页,由首页Route响应处理
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,8 @@
window.changeDialog = true
const conditionData = this.$refs.renderResourceRef.handleGetValue()
const { isEmpty, data } = conditionData
if (isEmpty) {
if (isEmpty || data[0] === 'none') {
this.isShowResourceInstanceSideslider = false
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
</template>
<template v-else>
<!-- 22 -->
<template v-if="!row.isNew && !row.isExpired && !row.isChanged">
<template v-if="!row.isNew && !row.isExpired">
<!-- 33 -->
<div class="mock-disabled-select">{{row.expired_display}}</div>
</template>
Expand Down Expand Up @@ -144,7 +144,7 @@
<bk-button
class="cancel-renewal-action"
outline
v-if="!row.isNew && !row.isShowRenewal && !row.isChanged"
v-if="!row.isNew && !row.isShowRenewal"
@click="handleCancelRenewal(row)">
{{ $t(`m.permApply['取消续期']`) }}
</bk-button>
Expand Down Expand Up @@ -344,7 +344,6 @@
list: {
handler (value) {
this.tableList = value
console.log('this.tableList', this.tableList)
},
immediate: true
},
Expand Down Expand Up @@ -601,14 +600,20 @@
},

async handleMainActionSubmit (payload, relatedActions) {
const curPayload = _.cloneDeep(payload)
let curPayload = _.cloneDeep(payload)
this.sliderLoading = true
curPayload.forEach(item => {
item.instances = item.instance || []
item.attributes = item.attribute || []
delete item.instance
delete item.attribute
})
curPayload = curPayload.filter(e => {
if ((e.instance && e.instance.length > 0) || (e.attribute && e.attribute.length > 0)) {
e.instances = e.instance || []
e.attributes = e.attribute || []
delete e.instance
delete e.attribute
return true
}
return false
}

)
const curData = _.cloneDeep(this.tableList[this.curIndex])
curData.related_resource_types = [curData.related_resource_types[this.curResIndex]]
curData.related_resource_types[0].condition = curPayload
Expand Down Expand Up @@ -660,10 +665,11 @@
if (payload.length < 1) {
return
}

payload.forEach(item => {
const curIndex = this.tableList.findIndex(sub => sub.id === item.id)
if (curIndex > -1) {
const curData = this.tableList[curIndex]
this.needEmitFlag = true
const inOriginalList = !!this.originalList.filter(
original => String(original.id) === String(item.id)
Expand All @@ -672,7 +678,7 @@
this.tableList.splice(
curIndex,
1,
new Policy({ ...item, tag: item.tag || 'add', isShowRelatedText: true, inOriginalList }, '', false)
new Policy({ ...item, tag: curData.tag === 'add' ? 'add' : item.tag, isShowRelatedText: true, inOriginalList }, '', false)
)
}
})
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/views/perm-template/components/render-content.vue
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@
this.description = res.data.description
this.systemName = res.data.system.name
this.originalCustomTmplList = _.cloneDeep(res.data.actions)
this.handleActionLinearData()
this.fetchCommonActions(this.systemValue)
await this.handleActionLinearData()
await this.fetchCommonActions(this.systemValue)
this.initialTempName = this.tempName
this.initialDescription = this.description
} catch (e) {
Expand Down Expand Up @@ -570,14 +570,14 @@
}
},

handleSysSelected (value, option) {
async handleSysSelected (value, option) {
window.changeDialog = true
this.commonActions = []
this.linearAction = []
this.curSelectActions = []
this.requestQueue = ['actions', 'commonActions']
this.fetchActions(value)
this.fetchCommonActions(value)
await this.fetchActions(value)
await this.fetchCommonActions(value)
},

handleSelect (payload) {
Expand Down
13 changes: 13 additions & 0 deletions release.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# V1.5.4

### 功能优化
* 自定义权限申请支持实例审批人
* 跳转申请不合并用户的已有权限
* 授权api返回策略的实例数量

### 缺陷修复
* 修复企业微信邮件中续期邮件链接显示问题
* 我的权限用户组权限查看态提示删除bug
* 业务跳转权限中心申请权限,申请期限不能修改
* 修复通用操作显示问题

# V1.5.3

### 缺陷修复
Expand Down
2 changes: 1 addition & 1 deletion saas/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.3
1.5.4
27 changes: 26 additions & 1 deletion saas/backend/api/authorization/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
from typing import List

from rest_framework import exceptions
from rest_framework.response import Response

from backend.biz.org_sync.syncer import Syncer
from backend.biz.policy import PolicyBean, PolicyBeanList, PolicyOperationBiz, PolicyQueryBiz
from backend.biz.role import RoleAuthorizationScopeChecker, RoleBiz
from backend.common.error_codes import APIException, error_codes
from backend.service.constants import SubjectType
from backend.service.constants import ADMIN_USER, SubjectType
from backend.service.models import Subject

from .constants import AuthorizationAPIEnum, OperateEnum
Expand Down Expand Up @@ -59,6 +60,11 @@ def grant_or_revoke(self, operate: OperateEnum, subject: Subject, policy_list: P
"""授权或回收权限"""
system_id = policy_list.system_id

# 对于授权Admin,自动忽略
if subject.type == SubjectType.USER.value and subject.id.lower() == ADMIN_USER:
# 原样返回,PolicyID=0,默认没有执行实际授权
return policy_list.policies

# 检测被授权的用户是否存在,不存在则尝试同步
if subject.type == SubjectType.USER.value:
self._check_or_sync_user(subject.id)
Expand Down Expand Up @@ -104,3 +110,22 @@ def _check_scope(self, subject: Subject, policy_list: PolicyBeanList):
# 临时方案:校验不通过,则修改分级管理员的权限范围,使其通过
need_added_policies = scope_checker.list_not_match_policy(system_id, policy_list.policies)
self.role_biz.inc_update_auth_scope(role.id, system_id, need_added_policies)

def policy_response(self, policy: PolicyBean):
"""所有返回单一策略的接口都统一返回的结构"""
return Response(
{"policy_id": policy.policy_id, "statistics": {"instance_count": policy.count_all_type_instance()}}
)

def batch_policy_response(self, policies: List[PolicyBean]):
"""所有返回批量策略的接口都统一返回的结构"""
return Response(
[
{
"action": {"id": p.action_id},
"policy_id": p.policy_id,
"statistics": {"instance_count": p.count_all_type_instance()},
}
for p in policies
]
)
9 changes: 4 additions & 5 deletions saas/backend/api/authorization/views/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"""
from drf_yasg.utils import swagger_auto_schema
from rest_framework import serializers, status
from rest_framework.response import Response
from rest_framework.views import APIView

from backend.api.authentication import ESBAuthentication
Expand Down Expand Up @@ -69,7 +68,7 @@ def post(self, request, *args, **kwargs):

audit_context_setter(operate=operate, subject=subject, system_id=system_id, policies=policies)

return Response({"policy_id": policies[0].policy_id})
return self.policy_response(policies[0])


class AuthPathView(AuthViewMixin, ExceptionHandlerMixin, APIView):
Expand Down Expand Up @@ -114,7 +113,7 @@ def post(self, request, *args, **kwargs):

audit_context_setter(operate=operate, subject=subject, system_id=system_id, policies=policies)

return Response({"policy_id": policies[0].policy_id})
return self.policy_response(policies[0])


class AuthBatchInstanceView(AuthViewMixin, ExceptionHandlerMixin, APIView):
Expand Down Expand Up @@ -159,7 +158,7 @@ def post(self, request, *args, **kwargs):

audit_context_setter(operate=operate, subject=subject, system_id=system_id, policies=policies)

return Response([{"action": {"id": p.action_id}, "policy_id": p.policy_id} for p in policies])
return self.batch_policy_response(policies)


class AuthBatchPathView(AuthViewMixin, ExceptionHandlerMixin, APIView):
Expand Down Expand Up @@ -204,4 +203,4 @@ def post(self, request, *args, **kwargs):

audit_context_setter(operate=operate, subject=subject, system_id=system_id, policies=policies)

return Response([{"action": {"id": p.action_id}, "policy_id": p.policy_id} for p in policies])
return self.batch_policy_response(policies)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"""
from drf_yasg.utils import swagger_auto_schema
from rest_framework import serializers, status
from rest_framework.response import Response
from rest_framework.views import APIView

from backend.api.authentication import ESBAuthentication
Expand Down Expand Up @@ -78,7 +77,7 @@ def post(self, request, *args, **kwargs):

audit_context_setter(operate=OperateEnum.GRANT.value, subject=subject, system_id=system_id, policies=policies)

return Response([{"action": {"id": p.action_id}, "policy_id": p.policy_id} for p in policies])
return self.batch_policy_response(policies)


class BatchResourceCreatorActionView(AuthViewMixin, ExceptionHandlerMixin, APIView):
Expand Down Expand Up @@ -130,7 +129,7 @@ def post(self, request, *args, **kwargs):

audit_context_setter(operate=OperateEnum.GRANT.value, subject=subject, system_id=system_id, policies=policies)

return Response([{"action": {"id": p.action_id}, "policy_id": p.policy_id} for p in policies])
return self.batch_policy_response(policies)


class ResourceCreatorActionAttributeView(AuthViewMixin, ExceptionHandlerMixin, APIView):
Expand Down Expand Up @@ -182,4 +181,4 @@ def post(self, request, *args, **kwargs):

audit_context_setter(operate=OperateEnum.GRANT.value, subject=subject, system_id=system_id, policies=policies)

return Response([{"action": {"id": p.action_id}, "policy_id": p.policy_id} for p in policies])
return self.batch_policy_response(policies)
22 changes: 14 additions & 8 deletions saas/backend/apps/policy/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,20 @@ def list(self, request, *args, **kwargs):
system_id = slz.validated_data["system_id"]
cache_id = slz.validated_data["cache_id"]

subject = SvcSubject(type=SubjectType.USER.value, id=request.user.username)

policies = self.policy_query_biz.list_by_subject(system_id, subject)

if cache_id != "":
cached_policy_list = self.application_policy_list_cache.get(cache_id)
if cached_policy_list.system_id != system_id:
raise error_codes.INVALID_ARGS.format(_("请求的system与缓存策略数据的system不一致"))

# 合并申请数据
policy_list = PolicyTagBeanList(system_id, parse_obj_as(List[PolicyTagBean], policies))
apply_policy_list = PolicyTagBeanList(
system_id, parse_obj_as(List[PolicyTagBean], cached_policy_list.policies)
)
apply_policy_list.set_tag(PolicyTag.ADD.value)
policy_list.merge(apply_policy_list)

return Response([p.dict() for p in policy_list.policies])
return Response([p.dict() for p in apply_policy_list.policies])

subject = SvcSubject(type=SubjectType.USER.value, id=request.user.username)
policies = self.policy_query_biz.list_by_subject(system_id, subject)
return Response([p.dict() for p in policies])

@swagger_auto_schema(
Expand Down Expand Up @@ -239,6 +234,17 @@ def create(self, request, *args, **kwargs):
system_id, parse_obj_as(List[PolicyTagBean], add_policy_list.policies)
)
tag_add_policy_list.set_tag(PolicyTag.ADD.value) # 对于新增的部分打tag, 方便前端处理

# 对已有策略中会增加部分实例的策略打update标签
for p in target_policy_list.policies:
add_policy = add_policy_list.get(p.action_id)
if (
add_policy
and not p.has_related_resource_types(add_policy.related_resource_types)
and p.tag != PolicyTag.ADD.value
):
p.tag = PolicyTag.UPDATE.value

target_policy_list.add(tag_add_policy_list) # 合并

target_policy_list.fill_empty_fields()
Expand Down
Loading