Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-pylib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-pylib
Commits
d6a8a0ee
Commit
d6a8a0ee
authored
3 years ago
by
Florian Spreckelsen
Browse files
Options
Downloads
Patches
Plain Diff
FIX: Add check for minimum password length
parent
cc49e32b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!37
ENH: add function that generates passwords
Pipeline
#17249
passed
3 years ago
Stage: code_style
Stage: linting
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caosdb/common/administration.py
+27
-4
27 additions, 4 deletions
src/caosdb/common/administration.py
with
27 additions
and
4 deletions
src/caosdb/common/administration.py
+
27
−
4
View file @
d6a8a0ee
...
@@ -59,7 +59,8 @@ def set_server_property(key, value):
...
@@ -59,7 +59,8 @@ def set_server_property(key, value):
con
.
_form_data_request
(
method
=
"
POST
"
,
path
=
"
_server_properties
"
,
con
.
_form_data_request
(
method
=
"
POST
"
,
path
=
"
_server_properties
"
,
params
=
{
key
:
value
}).
read
()
params
=
{
key
:
value
}).
read
()
except
EntityDoesNotExistError
:
except
EntityDoesNotExistError
:
raise
ServerConfigurationException
(
"
Debug mode in server is probably disabled.
"
)
from
None
raise
ServerConfigurationException
(
"
Debug mode in server is probably disabled.
"
)
from
None
def
get_server_properties
():
def
get_server_properties
():
...
@@ -74,9 +75,11 @@ def get_server_properties():
...
@@ -74,9 +75,11 @@ def get_server_properties():
"""
"""
con
=
get_connection
()
con
=
get_connection
()
try
:
try
:
body
=
con
.
_http_request
(
method
=
"
GET
"
,
path
=
"
_server_properties
"
).
response
body
=
con
.
_http_request
(
method
=
"
GET
"
,
path
=
"
_server_properties
"
).
response
except
EntityDoesNotExistError
:
except
EntityDoesNotExistError
:
raise
ServerConfigurationException
(
"
Debug mode in server is probably disabled.
"
)
from
None
raise
ServerConfigurationException
(
"
Debug mode in server is probably disabled.
"
)
from
None
xml
=
etree
.
parse
(
body
)
xml
=
etree
.
parse
(
body
)
props
=
dict
()
props
=
dict
()
...
@@ -112,7 +115,27 @@ def get_server_property(key):
...
@@ -112,7 +115,27 @@ def get_server_property(key):
def
generate_password
(
length
:
int
):
def
generate_password
(
length
:
int
):
"""
creates a random password that fulfills the security requirements
"""
"""
Create a random password that fulfills the security requirements
Parameters
----------
length : int
Length of the generated password. Has to be greater than 7.
Returns
-------
password : string
Generated random password of the given length
Raises
------
ValueError:
If the length is less than 8.
"""
minimum_password_length
=
8
if
length
<
minimum_password_length
:
raise
ValueError
(
"
CaosDB passwords have to be at least {} characters.
"
.
format
(
minimum_password_length
))
sample_letters
=
string
.
ascii_letters
+
string
.
digits
+
"
!#$%*+-/:;?_
"
sample_letters
=
string
.
ascii_letters
+
string
.
digits
+
"
!#$%*+-/:;?_
"
password
=
''
.
join
((
random
.
choice
(
sample_letters
)
for
i
in
range
(
length
)))
password
=
''
.
join
((
random
.
choice
(
sample_letters
)
for
i
in
range
(
length
)))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment