mirror of https://github.com/apache/superset.git
Pass security manager to QUERY_LOGGER (#6548)
* Pass security manager to log_query * Fix lint
This commit is contained in:
parent
fe994900ec
commit
672c470e79
|
@ -285,7 +285,14 @@ BACKUP_COUNT = 30
|
||||||
# Custom logger for auditing queries. This can be used to send ran queries to a
|
# Custom logger for auditing queries. This can be used to send ran queries to a
|
||||||
# structured immutable store for auditing purposes. The function is called for
|
# structured immutable store for auditing purposes. The function is called for
|
||||||
# every query ran, in both SQL Lab and charts/dashboards.
|
# every query ran, in both SQL Lab and charts/dashboards.
|
||||||
# def QUERY_LOGGER(database, query, schema=None, user=None, client=None):
|
# def QUERY_LOGGER(
|
||||||
|
# database,
|
||||||
|
# query,
|
||||||
|
# schema=None,
|
||||||
|
# user=None,
|
||||||
|
# client=None,
|
||||||
|
# security_manager=None,
|
||||||
|
# ):
|
||||||
# pass
|
# pass
|
||||||
|
|
||||||
# Set this API key to enable Mapbox visualizations
|
# Set this API key to enable Mapbox visualizations
|
||||||
|
|
|
@ -813,7 +813,7 @@ class Database(Model, AuditMixinNullable, ImportMixin):
|
||||||
|
|
||||||
def _log_query(sql):
|
def _log_query(sql):
|
||||||
if log_query:
|
if log_query:
|
||||||
log_query(engine.url, sql, schema, username, __name__)
|
log_query(engine.url, sql, schema, username, __name__, security_manager)
|
||||||
|
|
||||||
with closing(engine.raw_connection()) as conn:
|
with closing(engine.raw_connection()) as conn:
|
||||||
with closing(conn.cursor()) as cursor:
|
with closing(conn.cursor()) as cursor:
|
||||||
|
|
|
@ -189,6 +189,7 @@ def execute_sql(
|
||||||
query.schema,
|
query.schema,
|
||||||
user_name,
|
user_name,
|
||||||
__name__,
|
__name__,
|
||||||
|
security_manager,
|
||||||
)
|
)
|
||||||
db_engine_spec.execute(cursor, query.executed_sql, async_=True)
|
db_engine_spec.execute(cursor, query.executed_sql, async_=True)
|
||||||
logging.info('Handling cursor')
|
logging.info('Handling cursor')
|
||||||
|
|
Loading…
Reference in New Issue