Issue
We need some parameters handed over using a JWT token that are evaluated at a custom SecurityManager within Apache Superset. I read some information about g being able to handle information like this (in newer versions also across requests).
Ninja states it can read Flask's information from 'g' out of the box (docu Ninja Standard Context). This is a sample code snippet:
@expose('/login/', methods=['GET', 'POST'])
def login(self):
g.my_value = 'bar'
...
Still I do have issues when trying to use the information within SQLLab using e.g.
--{% set x = 'foo' %}
SELECT
{{x}},
{{g.my_value}}
FROM table_xyz
Will result in
g not defined
x
is evaluated correctly to 'foo' if the g field is removed. Any hint if this is possible?
Solution
Accessing the flask.g context is not that straight forward as execution happens on the celery worker. The celery worker has no access to the Flask context (also note depending on configuration it might even run in async mode).
Internal JINJA variables like current_user needed some additional work in Supersets codebase to be made available, but there's no general mechanism to open up user defined JINJA variables out of the box at the time of writing.
Answered By - supernova
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.