Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User inheritance and roles #627

Merged
merged 38 commits into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
3f6af69
key errors formatted
i-oden Oct 12, 2021
7a18f64
tests and marshmallows
i-oden Oct 12, 2021
f5052b5
removed verify import
i-oden Oct 12, 2021
cc411c0
added marshmallows
i-oden Oct 12, 2021
39e9683
post new file args and json
i-oden Oct 12, 2021
bd5951a
put new file args and json
i-oden Oct 12, 2021
6ffcf20
list files args
i-oden Oct 12, 2021
d6423a9
json not args in update file
i-oden Oct 12, 2021
6d45e35
apis3connector project fixed
i-oden Oct 12, 2021
ef5ffe1
Merge branch 'dev' into user-inheritance-and-roles
i-oden Oct 12, 2021
9c0325a
testing black again
i-oden Oct 12, 2021
1ca4f2c
unit added via relationship
i-oden Oct 12, 2021
8565a15
removed unit public_id
i-oden Oct 12, 2021
86d914d
removed unit public_id
i-oden Oct 12, 2021
003071d
db commit indented
i-oden Oct 12, 2021
1760e36
add flush
i-oden Oct 12, 2021
d784f79
created_by added to projet endpoint
i-oden Oct 12, 2021
e5a99dd
remove flush
i-oden Oct 12, 2021
880098b
users added with relationship
i-oden Oct 12, 2021
c9d2a25
test if test passes without sensitive
i-oden Oct 12, 2021
a27351c
add to db
i-oden Oct 12, 2021
312295b
unit id added
i-oden Oct 12, 2021
8849097
public id added again
i-oden Oct 12, 2021
7494488
relationship
i-oden Oct 12, 2021
abd8d1c
new attempt
i-oden Oct 12, 2021
3072b1e
unit
i-oden Oct 12, 2021
c102d69
added unit again
i-oden Oct 12, 2021
c5f5459
cur user unit added
i-oden Oct 12, 2021
f8168b5
removed created by
i-oden Oct 12, 2021
f8afc77
testing again
i-oden Oct 12, 2021
acabe76
username instead of object?
i-oden Oct 12, 2021
45dd44e
added sensitive test again
i-oden Oct 12, 2021
6314185
removed unused imports
i-oden Oct 12, 2021
01f3b89
clearer comment
i-oden Oct 12, 2021
d3b4eb6
removed commented out role in user table
i-oden Oct 12, 2021
e9cd213
getattr to user.role
i-oden Oct 12, 2021
605bdff
errors changed to keynotfounderror
i-oden Oct 12, 2021
9f273d1
typo fixed
i-oden Oct 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dds_web/api/db_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def delete_multiple(self, files):

not_removed_dict, not_exist_list, error = ({}, [], "")

with ApiS3Connector() as s3conn:
with ApiS3Connector(project=self.project) as s3conn:
# Error if not enough info
if None in [s3conn.url, s3conn.keys, s3conn.bucketname]:
return (
Expand Down
1 change: 1 addition & 0 deletions dds_web/api/dds_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def connect_cloud(func):
@functools.wraps(func)
def init_resource(self, *args, **kwargs):

_, self.keys, self.url, self.bucketname = self.get_s3_info()
if None in [self.keys, self.url]:
self.keys, self.url, self.bucketname, self.message = (
None,
Expand Down
36 changes: 11 additions & 25 deletions dds_web/api/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

# Own modules
from dds_web import actions
from dds_web import auth

####################################################################################################
# LOGGING ################################################################################ LOGGING #
Expand Down Expand Up @@ -50,7 +51,6 @@ class AccessDeniedError(exceptions.HTTPException):

def __init__(
self,
username=None,
project=None,
message="The user does not have the necessary permissions.",
):
Expand All @@ -60,7 +60,7 @@ def __init__(
message,
extra={
**extra_info,
"current_user": username,
"current_user": auth.current_user(),
"action": actions.get(flask.request.endpoint),
"project": project,
},
Expand All @@ -70,9 +70,7 @@ def __init__(
class DatabaseError(exceptions.HTTPException):
"""Baseclass for database related issues."""

def __init__(
self, message="The DDS encountered an Flask-SQLAlchemy issue.", username=None, project=None
):
def __init__(self, message="The DDS encountered an Flask-SQLAlchemy issue.", project=None):
super().__init__(message)

general_logger.warning(message)
Expand All @@ -81,7 +79,7 @@ def __init__(
message,
extra={
**extra_info,
"current_user": username,
"current_user": auth.current_user(),
"action": actions.get(flask.request.endpoint),
"project": project,
},
Expand All @@ -100,7 +98,7 @@ def __init__(self, project, username=None, message="The project is empty."):
message,
extra={
**extra_info,
"current_user": username,
"current_user": auth.current_user(),
"action": actions.get(flask.request.endpoint),
"project": project,
},
Expand All @@ -110,7 +108,7 @@ def __init__(self, project, username=None, message="The project is empty."):
class DeletionError(exceptions.HTTPException):
"""Deletion of item failed."""

def __init__(self, username, project, message="Deletion failed."):
def __init__(self, project, message="Deletion failed."):
super().__init__(message)

general_logger.warning(message)
Expand All @@ -119,7 +117,7 @@ def __init__(self, username, project, message="Deletion failed."):
message,
extra={
**extra_info,
"current_user": username,
"current_user": auth.current_user(),
"action": actions.get(flask.request.endpoint),
"project": project,
},
Expand All @@ -129,7 +127,7 @@ def __init__(self, username, project, message="Deletion failed."):
class NoSuchProjectError(exceptions.HTTPException):
"""The project does not exist in the database"""

def __init__(self, username, project, message="The specified project does not exist."):
def __init__(self, project, message="The specified project does not exist."):
super().__init__(message)

general_logger.warning(message)
Expand All @@ -138,7 +136,7 @@ def __init__(self, username, project, message="The specified project does not ex
message,
extra={
**extra_info,
"current_user": username,
"current_user": auth.current_user(),
"action": actions.get(flask.request.endpoint),
"project": project,
},
Expand Down Expand Up @@ -181,15 +179,6 @@ def __init__(self, message):
general_logger.warning(message)


class KeyNotFoundError(exceptions.HTTPException):
"""S3 keys not found."""

def __init__(self, message):
super().__init__(message)

general_logger.warning(message)


class JwtTokenGenerationError(exceptions.HTTPException):
"""Errors when generating the JWT token during authentication."""

Expand Down Expand Up @@ -226,15 +215,13 @@ def __init__(self, message="No method found in request."):
general_logger.warning(message)


class PublicKeyNotFoundError(exceptions.HTTPException):
"""Public key not found in database"""
class KeyNotFoundError(exceptions.HTTPException):
"""Key not found in database."""

def __init__(self, project, message="No key found for current project"):
self.message = f"{message}: {project}"
super().__init__(self.message)

general_logger.warning(self.message)


####################################################################################################

Expand All @@ -258,6 +245,5 @@ def __init__(self, project, message="No key found for current project"):
"S3ProjectNotFoundError": {"status": http.HTTPStatus.INTERNAL_SERVER_ERROR},
"S3InfoNotFoundError": {"status": http.HTTPStatus.INTERNAL_SERVER_ERROR},
"KeyNotFoundError": {"status": http.HTTPStatus.INTERNAL_SERVER_ERROR},
"PublicKeyNotFoundError": {"status": http.HTTPStatus.INTERNAL_SERVER_ERROR},
"BucketNotFoundError": {"status": http.HTTPStatus.INTERNAL_SERVER_ERROR},
}
Loading