mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-16 15:28:38 +00:00
merge v3
This commit is contained in:
@@ -60,11 +60,11 @@ class Permission(DjangoPermission):
|
||||
if actions == '*' and resource == '*':
|
||||
pass
|
||||
elif actions == '*' and resource != '*':
|
||||
kwargs['codename__iregex'] = r'[a-z]+_{}'.format(resource)
|
||||
kwargs['codename__iregex'] = r'[a-z]+_{}$'.format(resource)
|
||||
elif actions != '*' and resource == '*':
|
||||
kwargs['codename__iregex'] = r'({})_[a-z]+'.format(actions_regex)
|
||||
else:
|
||||
kwargs['codename__iregex'] = r'({})_{}'.format(actions_regex, resource)
|
||||
kwargs['codename__iregex'] = r'({})_{}$'.format(actions_regex, resource)
|
||||
q |= Q(**kwargs)
|
||||
return q
|
||||
|
||||
|
@@ -126,9 +126,16 @@ class RoleBinding(JMSBaseModel):
|
||||
org_ids = [b.org.id for b in bindings if b.org]
|
||||
orgs = all_orgs.filter(id__in=org_ids)
|
||||
|
||||
workbench_perm = 'rbac.view_workbench'
|
||||
# 全局组织
|
||||
if orgs and perm != 'rbac.view_workbench' and user.has_perm('orgs.view_rootorg'):
|
||||
orgs = [Organization.root(), *list(orgs)]
|
||||
if orgs and perm != workbench_perm and user.has_perm('orgs.view_rootorg'):
|
||||
root_org = Organization.root()
|
||||
orgs = [root_org, *list(orgs)]
|
||||
elif orgs and perm == workbench_perm and user.has_perm('orgs.view_alljoinedorg'):
|
||||
# Todo: 先复用组织
|
||||
root_org = Organization.root()
|
||||
root_org.name = _("All organizations")
|
||||
orgs = [root_org, *list(orgs)]
|
||||
return orgs
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user