Skip to content

Commit 3e0046e

Browse files
Panaetiusolevski
authored andcommitted
refactor: add validation to project, storage, repo and session blueprints (#347)
1 parent 3b1313c commit 3e0046e

File tree

2 files changed

+0
-25
lines changed

2 files changed

+0
-25
lines changed

components/renku_data_services/base_api/auth.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -71,30 +71,6 @@ async def decorated_function(request: Request, *args: _P.args, **kwargs: _P.kwar
7171
return decorator
7272

7373

74-
def validate_path_project_id(
75-
f: Callable[Concatenate[Request, _P], Coroutine[Any, Any, _T]],
76-
) -> Callable[Concatenate[Request, _P], Coroutine[Any, Any, _T]]:
77-
"""Decorator for a Sanic handler that validates the project_id path parameter."""
78-
_path_project_id_regex = re.compile(r"^[A-Za-z0-9]{26}$")
79-
80-
@wraps(f)
81-
async def decorated_function(request: Request, *args: _P.args, **kwargs: _P.kwargs) -> _T:
82-
project_id = cast(str | None, kwargs.get("project_id"))
83-
if not project_id:
84-
raise errors.ProgrammingError(
85-
message="Could not find 'project_id' in the keyword arguments for the handler in order to validate it."
86-
)
87-
if not _path_project_id_regex.match(project_id):
88-
raise errors.ValidationError(
89-
message=f"The 'project_id' path parameter {project_id} does not match the required "
90-
f"regex {_path_project_id_regex}"
91-
)
92-
93-
return await f(request, *args, **kwargs)
94-
95-
return decorated_function
96-
97-
9874
def validate_path_user_id(
9975
f: Callable[Concatenate[Request, _P], Coroutine[Any, Any, _T]],
10076
) -> Callable[Concatenate[Request, _P], Coroutine[Any, Any, _T]]:

components/renku_data_services/project/blueprints.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from renku_data_services.base_api.auth import (
1414
authenticate,
1515
only_authenticated,
16-
validate_path_project_id,
1716
validate_path_user_id,
1817
)
1918
from renku_data_services.base_api.blueprint import BlueprintFactoryResponse, CustomBlueprint

0 commit comments

Comments
 (0)