Skip to content
This repository was archived by the owner on Feb 8, 2024. It is now read-only.

Commit 733e210

Browse files
Rohit Kolapkarkupranay
andauthored
CORTX-32290: Added normalize path middleware (#900)
* CORTX-32290: Added normalize path middleware Signed-off-by: Rohit Kolapkar <[email protected]> * Sending resposne as a CSMResponse wherever it is missing Signed-off-by: Rohit Kolapkar <[email protected]> * Reverting unwanted changes Signed-off-by: Rohit Kolapkar <[email protected]> Signed-off-by: Rohit Kolapkar <[email protected]> Co-authored-by: kupranay <[email protected]>
1 parent 23bc824 commit 733e210

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

csm/core/agent/api.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
from asyncio import CancelledError as AsyncioCancelledError
2727
from weakref import WeakSet
2828
from aiohttp import web, web_exceptions
29-
from aiohttp.client_exceptions import ServerDisconnectedError, ClientConnectorError, ClientOSError
29+
from aiohttp.client_exceptions import (ServerDisconnectedError,
30+
ClientConnectorError, ClientOSError)
31+
from aiohttp.web_middlewares import normalize_path_middleware
3032
from abc import ABC
3133
from secure import SecureHeaders
3234
from typing import Dict, Tuple
@@ -116,11 +118,14 @@ def init():
116118
Log.info(f"CSM request quota is set to {CsmRestApi.__request_quota}")
117119

118120
CsmRestApi._app = web.Application(
119-
middlewares=[CsmRestApi.throttler_middleware,
121+
middlewares=[normalize_path_middleware(remove_slash=True,
122+
append_slash = False),
123+
CsmRestApi.throttler_middleware,
120124
CsmRestApi.set_secure_headers,
121125
CsmRestApi.rest_middleware,
122126
CsmRestApi.session_middleware,
123-
CsmRestApi.permission_middleware]
127+
CsmRestApi.permission_middleware
128+
]
124129
)
125130

126131
CsmRoutes.add_routes(CsmRestApi._app)

csm/core/controllers/login.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,3 @@ async def post(self):
6767
# TODO: Stop any websocket connection corresponding to this session
6868
Log.info(f"[{self.request.request_id}] Logout successful. User: {username}")
6969
return CsmResponse()
70-

csm/core/controllers/users.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,3 @@ async def patch(self):
199199
f"[{self.request.request_id}] Processed request: {self.request.method} {self.request.path}"\
200200
f" User: {loggedin_user_id}")
201201
return resp
202-

0 commit comments

Comments
 (0)