adomass commented on issue #34611:
URL: https://github.com/apache/superset/issues/34611#issuecomment-3180099068

   The fix i made locally is override register_request_handlers and only change 
     # Fallback for guest users
                   if not sub:
                       sub = "guest"
   
   `class CustomAsyncQueryManager(AsyncQueryManager):
   
       def __init__(self):
           super().__init__()
           self.logger = logging.getLogger(__name__)
       
       def register_request_handlers(self, app: Flask) -> None:
           @app.after_request
           def validate_session(response: Response) -> Response:
   
               self.logger.debug("Validating session for async queries...")
               user_id = get_user_id()
   
               reset_token = (
                   not request.cookies.get(self._jwt_cookie_name)
                   or "async_channel_id" not in session
                   or "async_user_id" not in session
                   or user_id != session["async_user_id"]
               )
   
               if reset_token:
                   async_channel_id = str(uuid.uuid4())
                   session["async_channel_id"] = async_channel_id
                   session["async_user_id"] = user_id
   
                   sub = str(user_id) if user_id else None
   
                   # Fallback for guest users
                   if not sub:
                       sub = "guest"
   
                   token = jwt.encode(
                       {"channel": async_channel_id, "sub": sub},
                       self._jwt_secret,
                       algorithm="HS256",
                   )
   
                   self.logger.debug(f"Generated JWT token for async queries: 
{token}")
   
                   response.set_cookie(
                       self._jwt_cookie_name,
                       value=token,
                       httponly=True,
                       secure=self._jwt_cookie_secure,
                       domain=self._jwt_cookie_domain,
                       samesite=self._jwt_cookie_samesite,
                   )
   
               return response`
   
   Not sure if that is best approach but at leat it works


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to