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
21b17ca4
Commit
21b17ca4
authored
Oct 12, 2019
by
BaiJiangJie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 系统用户 name 限制使用特殊字符
parent
70713af9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
user.py
apps/assets/forms/user.py
+2
-0
system_user.py
apps/assets/serializers/system_user.py
+14
-0
No files found.
apps/assets/forms/user.py
View file @
21b17ca4
...
@@ -6,6 +6,7 @@ from django.utils.translation import gettext_lazy as _
...
@@ -6,6 +6,7 @@ from django.utils.translation import gettext_lazy as _
from
common.utils
import
validate_ssh_private_key
,
ssh_pubkey_gen
,
get_logger
from
common.utils
import
validate_ssh_private_key
,
ssh_pubkey_gen
,
get_logger
from
orgs.mixins.forms
import
OrgModelForm
from
orgs.mixins.forms
import
OrgModelForm
from
..models
import
AdminUser
,
SystemUser
from
..models
import
AdminUser
,
SystemUser
from
..const
import
GENERAL_LIMIT_SPECIAL_CHARACTERS_HELP_TEXT
logger
=
get_logger
(
__file__
)
logger
=
get_logger
(
__file__
)
__all__
=
[
__all__
=
[
...
@@ -98,6 +99,7 @@ class SystemUserForm(OrgModelForm, PasswordAndKeyAuthForm):
...
@@ -98,6 +99,7 @@ class SystemUserForm(OrgModelForm, PasswordAndKeyAuthForm):
}),
}),
}
}
help_texts
=
{
help_texts
=
{
'name'
:
GENERAL_LIMIT_SPECIAL_CHARACTERS_HELP_TEXT
,
'auto_push'
:
_
(
'Auto push system user to asset'
),
'auto_push'
:
_
(
'Auto push system user to asset'
),
'priority'
:
_
(
'1-100, High level will be using login asset as default, '
'priority'
:
_
(
'1-100, High level will be using login asset as default, '
'if user was granted more than 2 system user'
),
'if user was granted more than 2 system user'
),
...
...
apps/assets/serializers/system_user.py
View file @
21b17ca4
import
re
from
rest_framework
import
serializers
from
rest_framework
import
serializers
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
...
@@ -6,6 +7,10 @@ from common.serializers import AdaptedBulkListSerializer
...
@@ -6,6 +7,10 @@ from common.serializers import AdaptedBulkListSerializer
from
common.utils
import
ssh_pubkey_gen
from
common.utils
import
ssh_pubkey_gen
from
orgs.mixins.serializers
import
BulkOrgResourceModelSerializer
from
orgs.mixins.serializers
import
BulkOrgResourceModelSerializer
from
..models
import
SystemUser
from
..models
import
SystemUser
from
..const
import
(
GENERAL_LIMIT_SPECIAL_CHARACTERS_PATTERN
,
GENERAL_LIMIT_SPECIAL_CHARACTERS_ERROR_MSG
)
from
.base
import
AuthSerializer
,
AuthSerializerMixin
from
.base
import
AuthSerializer
,
AuthSerializerMixin
...
@@ -33,6 +38,15 @@ class SystemUserSerializer(AuthSerializerMixin, BulkOrgResourceModelSerializer):
...
@@ -33,6 +38,15 @@ class SystemUserSerializer(AuthSerializerMixin, BulkOrgResourceModelSerializer):
'created_by'
:
{
'read_only'
:
True
},
'created_by'
:
{
'read_only'
:
True
},
}
}
@staticmethod
def
validate_name
(
name
):
pattern
=
GENERAL_LIMIT_SPECIAL_CHARACTERS_PATTERN
res
=
re
.
match
(
pattern
,
name
)
if
res
is
None
:
msg
=
GENERAL_LIMIT_SPECIAL_CHARACTERS_ERROR_MSG
raise
serializers
.
ValidationError
(
msg
)
return
name
def
validate_auto_push
(
self
,
value
):
def
validate_auto_push
(
self
,
value
):
login_mode
=
self
.
initial_data
.
get
(
"login_mode"
)
login_mode
=
self
.
initial_data
.
get
(
"login_mode"
)
protocol
=
self
.
initial_data
.
get
(
"protocol"
)
protocol
=
self
.
initial_data
.
get
(
"protocol"
)
...
...
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