-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Bumped version to 1.0.4 * File access control (#86) * added subproject requirement to uploaded files * Adjusted file saving mechanism * Added comment for clarity * Implemented FileAccessControl based on subproject access * Improved robustness of MySQLStatementBuilder * Fixed static acces_level issue in FileAccessChecker * Mysql statement builder refactor (#88) * Removed mysqlutils and instead imported mysql-statement-builder package * Added mysql-statement-builder to requirements.txt * Reconnected mysqlsb logger with fastapi logger * Enable sorting user listings, and searching for users (#89) * Search for user functionality * Safe generic order-by for user lists * user sorting and search tests Added tests for new functionality * fixed failing cvs simulation test * Projects administration end-points for SED portal (#91) * Updated subprojects and projects data structures * Added min_length constraint to sub-project and project names * Also list project creation date and participant count * Project lists entries are now properly populated * Functionality to avoid accidental project overwrites * Fixed test fail and bumped up desim version (#90) * Fixed test that fails * desim-tool version 0.3.3 * replaced generic exception --------- Co-authored-by: EppChops <erik.00.berg@gmail.com> Co-authored-by: Erik Berg <57296415+EppChops@users.noreply.github.com> * 83 Endpoint for deleting files (#95) * Functionality for deleting files * reset utils to previous state * 83 Update project details (#96) * Partial implementation of necessary methods * Post multiple participants at the same time * Fixed incorrect project access checker instantiation * Tests * Fixed broken test request for project update * Projects can now be updated * Improved log message --------- Co-authored-by: Oscar Bennet <oscar.bennet@hotmail.se> Co-authored-by: EppChops <erik.00.berg@gmail.com> Co-authored-by: Erik Berg <57296415+EppChops@users.noreply.github.com>
- Loading branch information
1 parent
841a7b6
commit cfb5a14
Showing
45 changed files
with
1,045 additions
and
415 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from typing import List | ||
|
||
from fastapi import Request | ||
from fastapi.logger import logger | ||
|
||
from sedbackend.apps.core.projects.dependencies import SubProjectAccessChecker | ||
from sedbackend.apps.core.projects.models import AccessLevel | ||
from sedbackend.apps.core.projects.implementation import impl_get_subproject_by_id | ||
from sedbackend.apps.core.files.implementation import impl_get_file_mapped_subproject_id | ||
|
||
|
||
class FileAccessChecker: | ||
def __init__(self, allowed_levels: List[AccessLevel]): | ||
self.access_levels = allowed_levels | ||
|
||
def __call__(self, file_id: int, request: Request): | ||
logger.debug(f'Is user with id {request.state.user_id} ' | ||
f'allowed to access file with id {file_id}?') | ||
user_id = request.state.user_id | ||
|
||
# Get subproject ID | ||
subproject_id = impl_get_file_mapped_subproject_id(file_id) | ||
|
||
# Run subproject access check | ||
subproject = impl_get_subproject_by_id(subproject_id) | ||
return SubProjectAccessChecker.check_user_subproject_access(subproject, self.access_levels, user_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.