Skip to content

Commit

Permalink
increment neon_mq_connector to 0.7.2a7 (#112)
Browse files Browse the repository at this point in the history
* Incremented neon mq connector dependency and small fix on client

* Improved expired session verification by introducing a separate exception for invalid token
  • Loading branch information
NeonKirill authored Dec 5, 2024
1 parent c358195 commit 83bf100
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion chat_client/static/js/http_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const fetchServer = async (urlSuffix, method=REQUEST_METHODS.GET, body=null, jso
return fetch(`${configData["CHAT_SERVER_URL_BASE"]}/${urlSuffix}`, options).then(async response => {
if (response.status === 401){
const responseJson = await response.json();
if (responseJson['msg'] === 'Requested user is not authorized to perform this action'){
if (responseJson['msg'] === 'Session token is invalid or expired'){
localStorage.removeItem('session');
location.reload();
}
Expand Down
9 changes: 6 additions & 3 deletions chat_server/server_utils/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
from fastapi import Request

from chat_server.server_utils.enums import UserRoles
from chat_server.server_utils.http_exceptions import UserUnauthorizedException
from chat_server.server_utils.http_exceptions import (
UserUnauthorizedException,
InvalidSessionTokenException,
)
from utils.database_utils.mongo_utils import MongoFilter, MongoLogicalOperators
from utils.database_utils.mongo_utils.queries.wrapper import MongoDocumentsAPI
from utils.logging_utils import LOG
Expand Down Expand Up @@ -269,6 +272,6 @@ def validate_session(
return "OK", 200
else:
LOG.warning("Session expired")
raise UserUnauthorizedException()
raise InvalidSessionTokenException()
LOG.warning("Session header missing")
raise UserUnauthorizedException()
raise InvalidSessionTokenException()
7 changes: 6 additions & 1 deletion chat_server/server_utils/http_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,15 @@ def to_http_response(self):


class UserUnauthorizedException(KlatAPIException):
HTTP_CODE = http.HTTPStatus.FORBIDDEN
HTTP_CODE = http.HTTPStatus.UNAUTHORIZED
MESSAGE = "Requested user is not authorized to perform this action"


class InvalidSessionTokenException(KlatAPIException):
HTTP_CODE = http.HTTPStatus.UNAUTHORIZED
MESSAGE = "Session token is invalid or expired"


class ItemNotFoundException(KlatAPIException):
HTTP_CODE = http.HTTPStatus.NOT_FOUND
MESSAGE = "Requested item not found"
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ httpx==0.27.0 # required by FastAPI
Jinja2==3.1.3
jsbeautifier==1.15.1
kubernetes==29.0.0
neon-mq-connector==0.7.2a5
neon-mq-connector==0.7.2a7
neon-sftp~=0.1
neon_utils[sentry]==1.11.1a5
pre-commit==3.7.0
Expand Down
2 changes: 1 addition & 1 deletion requirements/services/observer.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
neon-mq-connector==0.7.2a5
neon-mq-connector==0.7.2a7
websocket-client==1.7.0
websockets==12.0

0 comments on commit 83bf100

Please sign in to comment.