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
5e6a6c72
Commit
5e6a6c72
authored
5 years ago
by
Daniel
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Added a better message for too simple passwords.
Is this enough for
#7
? Also added documentation.
parent
03af96e6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caosdb/common/administration.py
+34
-2
34 additions, 2 deletions
src/caosdb/common/administration.py
src/caosdb/connection/connection.py
+1
-1
1 addition, 1 deletion
src/caosdb/connection/connection.py
with
35 additions
and
3 deletions
src/caosdb/common/administration.py
+
34
−
2
View file @
5e6a6c72
...
...
@@ -164,7 +164,9 @@ def _insert_user(name, password=None, status=None, email=None, entity=None, **kw
raise
e
except
ClientErrorException
as
e
:
if
e
.
status
==
409
:
e
.
msg
=
"
User name is yet in use.
"
e
.
msg
=
"
User name is already in use.
"
if
e
.
status
==
422
:
e
.
msg
=
"
Maybe the password does not match the required standard?
"
raise
e
...
...
@@ -219,7 +221,6 @@ def _delete_role(name, **kwargs):
def
_set_roles
(
username
,
roles
,
realm
=
None
,
**
kwargs
):
xml
=
etree
.
Element
(
"
Roles
"
)
print
(
roles
)
for
r
in
roles
:
xml
.
append
(
etree
.
Element
(
"
Role
"
,
name
=
r
))
...
...
@@ -262,6 +263,24 @@ def _get_roles(username, realm=None, **kwargs):
def
_set_permissions
(
role
,
permission_rules
,
**
kwargs
):
"""
Set permissions for a role.
Parameters
----------
role : str
The role for which the permissions are set.
permission_rules : iterable<PermissionRule>
An iterable with PermissionRule objects.
**kwargs :
Additional arguments which are passed to the HTTP request.
Returns
-------
None
"""
xml
=
etree
.
Element
(
"
PermissionRules
"
)
for
p
in
permission_rules
:
xml
.
append
(
p
.
_to_xml
())
...
...
@@ -291,6 +310,19 @@ def _get_permissions(role, **kwargs):
class
PermissionRule
():
"""
Permission rules.
Parameters
----------
action : str
Either
"
grant
"
or
"
deny
"
permission : str
For example
"
RETRIEVE:*
"
.
priority : bool, optional
Whether the priority shall be set, defaults is False.
"""
@staticmethod
def
_parse_boolean
(
bstr
):
...
...
This diff is collapsed.
Click to expand it.
src/caosdb/connection/connection.py
+
1
−
1
View file @
5e6a6c72
...
...
@@ -382,7 +382,7 @@ def _handle_response_status(http_response):
"
Request failed. The response returned with status
"
"
{}.
"
.
format
(
status
))
elif
399
<
status
<
500
:
raise
ClientErrorException
(
msg
=
(
"
Request failed. The response returned
"
raise
ClientErrorException
(
msg
=
(
"
Request failed. The response returned
"
"
with status {}.
"
).
format
(
status
),
status
=
status
,
body
=
body
)
elif
status
>
499
:
raise
ServerErrorException
(
body
=
body
)
...
...
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