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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-pylib
Commits
6e45ea42
Commit
6e45ea42
authored
3 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
ENH: add function that generates passwords
parent
44c44abc
No related branches found
No related tags found
1 merge request
!37
ENH: add function that generates passwords
Pipeline
#16977
passed
3 years ago
Stage: code_style
Stage: linting
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caosdb/common/administration.py
+16
-0
16 additions, 0 deletions
src/caosdb/common/administration.py
with
16 additions
and
0 deletions
src/caosdb/common/administration.py
+
16
−
0
View file @
6e45ea42
...
...
@@ -26,6 +26,9 @@
"""
missing docstring.
"""
import
re
import
string
import
random
from
caosdb.common.utils
import
xml2str
from
caosdb.connection.connection
import
get_connection
from
caosdb.exceptions
import
(
EntityDoesNotExistError
,
HTTPClientError
,
...
...
@@ -108,6 +111,19 @@ def get_server_property(key):
return
get_server_properties
()[
key
]
def
get_password
(
length
):
"""
creates a random password that fulfills the security requirements
"""
sample_letters
=
string
.
ascii_letters
+
string
.
digits
+
"
!#$%*+-/:;?_
"
password
=
''
.
join
((
random
.
choice
(
sample_letters
)
for
i
in
range
(
length
)))
while
not
re
.
match
(
r
"
(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[\W_]).{8,}
"
,
password
):
password
=
''
.
join
((
random
.
choice
(
sample_letters
)
for
i
in
range
(
length
)))
return
password
def
_retrieve_user
(
name
,
realm
=
None
,
**
kwargs
):
con
=
get_connection
()
try
:
...
...
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