diff --git a/api/auth/auth_jwt.py b/api/auth/auth_jwt.py index 4fd7191a9..5075ff331 100644 --- a/api/auth/auth_jwt.py +++ b/api/auth/auth_jwt.py @@ -32,6 +32,7 @@ class JWTAuth(HTTPBearer): super(JWTAuth, self).__init__(auto_error=auto_error) async def __call__(self, request: Request) -> Optional[schemas.CurrentContext]: + logger.info(request.url.path) if request.url.path in ["/refresh", "/api/refresh"]: return await self.__process_refresh_call(request) @@ -45,6 +46,8 @@ class JWTAuth(HTTPBearer): raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="Invalid authentication scheme.") jwt_payload = authorizers.jwt_authorizer(scheme=credentials.scheme, token=credentials.credentials) + logger.info("------ jwt_payload ------") + logger.info(jwt_payload) auth_exists = jwt_payload is not None and users.auth_exists(user_id=jwt_payload.get("userId", -1), jwt_iat=jwt_payload.get("iat", 100)) if jwt_payload is None \ diff --git a/api/chalicelib/core/authorizers.py b/api/chalicelib/core/authorizers.py index 221c1389b..858b24b4f 100644 --- a/api/chalicelib/core/authorizers.py +++ b/api/chalicelib/core/authorizers.py @@ -9,14 +9,6 @@ from chalicelib.utils.TimeUTC import TimeUTC logger = logging.getLogger(__name__) -logger.info("--------- authorizer config ---------") -logger.info(f'JWT_REFRESH_EXPIRATION:{config("JWT_REFRESH_EXPIRATION", cast=int)}') -logger.info(f'JWT_SPOT_REFRESH_EXPIRATION:{config("JWT_SPOT_REFRESH_EXPIRATION", cast=int)}') -logger.info(f'JWT_ISSUER:{config("JWT_ISSUER")}') -logger.info(f'JWT_REFRESH_SECRET:{config("JWT_REFRESH_SECRET")}') -logger.info(f'JWT_SPOT_REFRESH_SECRET:{config("JWT_SPOT_REFRESH_SECRET")}') -logger.info("--------- authorizer config ---------") - def get_supported_audience(): return [users.AUDIENCE, spot.AUDIENCE] diff --git a/api/chalicelib/core/users.py b/api/chalicelib/core/users.py index e520633fb..4ad7c56e3 100644 --- a/api/chalicelib/core/users.py +++ b/api/chalicelib/core/users.py @@ -525,7 +525,7 @@ def get_by_invitation_token(token, pass_token=None): return helper.dict_to_camel_case(r) -def auth_exists(user_id, jwt_iat): +def auth_exists(user_id, jwt_iat) -> bool: with pg_client.PostgresClient() as cur: cur.execute( cur.mogrify(f"""SELECT user_id, EXTRACT(epoch FROM jwt_iat)::BIGINT AS jwt_iat diff --git a/ee/api/chalicelib/core/users.py b/ee/api/chalicelib/core/users.py index f282e1d8d..730d65c4f 100644 --- a/ee/api/chalicelib/core/users.py +++ b/ee/api/chalicelib/core/users.py @@ -608,7 +608,7 @@ def get_by_invitation_token(token, pass_token=None): return helper.dict_to_camel_case(r) -def auth_exists(user_id, tenant_id, jwt_iat): +def auth_exists(user_id, tenant_id, jwt_iat) -> bool: with pg_client.PostgresClient() as cur: cur.execute( cur.mogrify(