how to access superset details in middleware #31707
Replies: 2 comments 11 replies
-
To access user details in middleware for every API call in Superset, you can add custom middleware by updating the Here's a basic example of how you might implement this:
from flask import g
class UserDetailMiddleware:
def __init__(self, app):
self.app = app
def __call__(self, environ, start_response):
# Access user details from the Flask global object `g`
user = g.user if hasattr(g, 'user') else None
if user:
# Implement logic to handle user details
print(f"User ID: {user.id}, Username: {user.username}")
return self.app(environ, start_response)
ADDITIONAL_MIDDLEWARE = [
'path.to.your.UserDetailMiddleware',
] This setup will allow your middleware to intercept API calls and access user details for each request [1]. To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
Beta Was this translation helpful? Give feedback.
-
@dosu i already tried this option it gives RuntimeError: Working outside of application context. find below error superset | [2025-01-04 10:42:14 +0000] [76] [ERROR] Error handling request /superset/welcome/ |
Beta Was this translation helpful? Give feedback.
-
in superset config how do i implement to access user details for every api calls made
Beta Was this translation helpful? Give feedback.
All reactions