mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-10-18 22:38:44 +00:00
perf: Pam rbac
This commit is contained in:
@@ -215,6 +215,10 @@ class RoleMixin:
|
||||
def workbench_orgs(self):
|
||||
return self.cached_orgs.get("workbench_orgs", [])
|
||||
|
||||
@lazyproperty
|
||||
def pam_orgs(self):
|
||||
return self.cached_orgs.get("pam_orgs", [])
|
||||
|
||||
@lazyproperty
|
||||
def joined_orgs(self):
|
||||
from rbac.models import RoleBinding
|
||||
@@ -229,6 +233,7 @@ class RoleMixin:
|
||||
data = cache.get(key)
|
||||
if data:
|
||||
return data
|
||||
pam_orgs = RoleBinding.get_user_has_the_perm_orgs("rbac.view_pam", self)
|
||||
console_orgs = RoleBinding.get_user_has_the_perm_orgs("rbac.view_console", self)
|
||||
audit_orgs = RoleBinding.get_user_has_the_perm_orgs("rbac.view_audit", self)
|
||||
workbench_orgs = RoleBinding.get_user_has_the_perm_orgs(
|
||||
@@ -239,6 +244,7 @@ class RoleMixin:
|
||||
audit_orgs = list(set(audit_orgs) - set(console_orgs))
|
||||
|
||||
data = {
|
||||
"pam_orgs": pam_orgs,
|
||||
"console_orgs": console_orgs,
|
||||
"audit_orgs": audit_orgs,
|
||||
"workbench_orgs": workbench_orgs,
|
||||
|
@@ -188,6 +188,7 @@ class UserOrgSerializer(serializers.Serializer):
|
||||
class UserPermsSerializer(serializers.Serializer):
|
||||
id = serializers.CharField(label=_("User ID"), read_only=True)
|
||||
username = serializers.CharField(label=_("Username"), read_only=True)
|
||||
pam_orgs = UserOrgSerializer(many=True, read_only=True)
|
||||
console_orgs = UserOrgSerializer(many=True, read_only=True)
|
||||
audit_orgs = UserOrgSerializer(many=True, read_only=True)
|
||||
workbench_orgs = UserOrgSerializer(many=True, read_only=True)
|
||||
|
Reference in New Issue
Block a user