Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
4631d7de
Commit
4631d7de
authored
Aug 15, 2019
by
jym503558564
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改一些问题
parent
b9bb755c
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
21 additions
and
32 deletions
+21
-32
views.py
apps/audits/views.py
+1
-1
permissions.py
apps/common/permissions.py
+2
-6
models.py
apps/orgs/models.py
+11
-18
asset_permission.py
apps/perms/forms/asset_permission.py
+1
-1
remote_app_permission.py
apps/perms/forms/remote_app_permission.py
+1
-1
asset_permission.py
apps/perms/views/asset_permission.py
+1
-1
remote_app_permission.py
apps/perms/views/remote_app_permission.py
+1
-1
forms.py
apps/users/forms.py
+1
-1
user.py
apps/users/models/user.py
+1
-1
group.py
apps/users/views/group.py
+1
-1
No files found.
apps/audits/views.py
View file @
4631d7de
...
...
@@ -234,7 +234,7 @@ class CommandExecutionListView(UserCommandExecutionListView):
return
queryset
def
get_user_list
(
self
):
users
=
current_org
.
get_org_members
_exclude_auditors
(
)
users
=
current_org
.
get_org_members
(
include_auditors
=
False
)
return
users
def
get_context_data
(
self
,
**
kwargs
):
...
...
apps/common/permissions.py
View file @
4631d7de
...
...
@@ -161,15 +161,11 @@ class NeedMFAVerify(permissions.BasePermission):
class
CanUpdateDeleteSuperUser
(
permissions
.
BasePermission
):
def
has_object_permission
(
self
,
request
,
view
,
obj
):
if
request
.
method
in
[
'GET'
,
'OPTIONS'
]:
return
True
elif
request
.
method
==
'DELETE'
and
str
(
request
.
user
.
id
)
==
str
(
obj
.
id
):
if
request
.
method
==
'DELETE'
and
request
.
user
.
id
==
str
(
obj
.
id
):
return
False
elif
request
.
method
in
(
'DELETE'
,
'PATCH'
,
'PUT
'
)
and
\
if
request
.
method
not
in
(
'GET'
,
'OPTIONS
'
)
and
\
not
request
.
user
.
is_superuser
and
obj
.
is_auditor
:
return
False
elif
request
.
user
.
is_superuser
:
return
True
if
hasattr
(
obj
,
'is_superuser'
)
and
obj
.
is_superuser
:
return
False
return
True
apps/orgs/models.py
View file @
4631d7de
...
...
@@ -67,16 +67,6 @@ class Organization(models.Model):
org
=
cls
.
default
()
if
default
else
None
return
org
# def get_org_users(self, include_app=False):
# from users.models import User
# if self.is_real():
# users = self.users.all()
# else:
# users = User.objects.all()
# if not include_app:
# users = users.exclude(role=User.ROLE_APP)
# return users
def
get_org_users
(
self
):
if
self
.
is_real
():
return
self
.
users
.
all
()
...
...
@@ -92,22 +82,18 @@ class Organization(models.Model):
return
self
.
auditors
.
all
()
return
[]
def
get_org_members
(
self
,
include_app
=
False
):
def
get_org_members
(
self
,
include_app
=
False
,
include_auditors
=
True
):
from
users.models
import
User
if
self
.
is_real
():
members
=
self
.
users
.
all
()
|
self
.
auditors
.
all
()
members
=
self
.
get_org_users
()
|
self
.
get_org_auditors
()
else
:
members
=
User
.
objects
.
all
()
if
not
include_app
:
members
=
members
.
exclude
(
role
=
User
.
ROLE_APP
)
if
not
include_auditors
:
members
=
members
.
exclude
(
role
=
User
.
ROLE_AUDITOR
)
return
members
def
get_org_members_exclude_auditors
(
self
,
include_app
=
False
):
from
users.models
import
User
members
=
self
.
get_org_members
(
include_app
=
include_app
)
members_exclude_auditors
=
members
.
exclude
(
role
=
User
.
ROLE_AUDITOR
)
return
members_exclude_auditors
def
can_admin_by
(
self
,
user
):
if
user
.
is_superuser
:
return
True
...
...
@@ -140,6 +126,13 @@ class Organization(models.Model):
admin_orgs
.
append
(
cls
.
default
())
return
admin_orgs
@classmethod
def
get_user_audit_orgs
(
cls
,
user
):
audit_orgs
=
[]
if
user
.
is_auditor
:
audit_orgs
=
user
.
audit_orgs
.
all
()
return
audit_orgs
@classmethod
def
default
(
cls
):
return
cls
(
id
=
cls
.
DEFAULT_ID
,
name
=
cls
.
DEFAULT_NAME
)
...
...
apps/perms/forms/asset_permission.py
View file @
4631d7de
...
...
@@ -39,7 +39,7 @@ class AssetPermissionForm(OrgModelForm):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
users_field
=
self
.
fields
.
get
(
'users'
)
users_field
.
queryset
=
current_org
.
get_org_members
_exclude_auditors
(
)
users_field
.
queryset
=
current_org
.
get_org_members
(
include_auditors
=
False
)
nodes_field
=
self
.
fields
[
'nodes'
]
nodes_field
.
choices
=
((
n
.
id
,
n
.
full_value
)
for
n
in
Node
.
get_queryset
())
...
...
apps/perms/forms/remote_app_permission.py
View file @
4631d7de
...
...
@@ -19,7 +19,7 @@ class RemoteAppPermissionCreateUpdateForm(OrgModelForm):
super
()
.
__init__
(
*
args
,
**
kwargs
)
users_field
=
self
.
fields
.
get
(
'users'
)
if
hasattr
(
users_field
,
'queryset'
):
users_field
.
queryset
=
current_org
.
get_org_members
_exclude_auditors
(
)
users_field
.
queryset
=
current_org
.
get_org_members
(
include_auditors
=
False
)
class
Meta
:
model
=
RemoteAppPermission
...
...
apps/perms/views/asset_permission.py
View file @
4631d7de
...
...
@@ -135,7 +135,7 @@ class AssetPermissionUserView(PermissionsMixin,
context
=
{
'app'
:
_
(
'Perms'
),
'action'
:
_
(
'Asset permission user list'
),
'users_remain'
:
current_org
.
get_org_members
_exclude_auditors
(
)
.
exclude
(
'users_remain'
:
current_org
.
get_org_members
(
include_auditors
=
False
)
.
exclude
(
assetpermission
=
self
.
object
),
'user_groups_remain'
:
UserGroup
.
objects
.
exclude
(
...
...
apps/perms/views/remote_app_permission.py
View file @
4631d7de
...
...
@@ -107,7 +107,7 @@ class RemoteAppPermissionUserView(PermissionsMixin,
context
=
{
'app'
:
_
(
'Perms'
),
'action'
:
_
(
'RemoteApp permission user list'
),
'users_remain'
:
current_org
.
get_org_members
_exclude_auditors
(
)
.
exclude
(
'users_remain'
:
current_org
.
get_org_members
(
include_auditors
=
False
)
.
exclude
(
remoteapppermission
=
self
.
object
),
'user_groups_remain'
:
UserGroup
.
objects
.
exclude
(
...
...
apps/users/forms.py
View file @
4631d7de
...
...
@@ -335,7 +335,7 @@ class UserGroupForm(OrgModelForm):
return
users_field
=
self
.
fields
.
get
(
'users'
)
if
hasattr
(
users_field
,
'queryset'
):
users_field
.
queryset
=
current_org
.
get_org_members
_exclude_auditors
(
)
users_field
.
queryset
=
current_org
.
get_org_members
(
include_auditors
=
False
)
def
save
(
self
,
commit
=
True
):
group
=
super
()
.
save
(
commit
=
commit
)
...
...
apps/users/models/user.py
View file @
4631d7de
...
...
@@ -167,7 +167,7 @@ class RoleMixin:
@property
def
audit_orgs
(
self
):
from
orgs.models
import
Organization
return
Organization
.
get_user_a
dmin
_orgs
(
self
)
return
Organization
.
get_user_a
udit
_orgs
(
self
)
@property
def
is_org_auditor
(
self
):
...
...
apps/users/views/group.py
View file @
4631d7de
...
...
@@ -76,7 +76,7 @@ class UserGroupDetailView(PermissionsMixin, DetailView):
permission_classes
=
[
IsOrgAdmin
]
def
get_context_data
(
self
,
**
kwargs
):
users
=
current_org
.
get_org_members
_exclude_auditors
(
)
.
exclude
(
id__in
=
self
.
object
.
users
.
all
())
users
=
current_org
.
get_org_members
(
include_auditors
=
False
)
.
exclude
(
id__in
=
self
.
object
.
users
.
all
())
context
=
{
'app'
:
_
(
'Users'
),
'action'
:
_
(
'User group detail'
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment