Hi all,

It seems a old question and I would like to know if it is still not possible to use/know the username of the logged user inside a query. One old post suggested it could be possible to do it so in scheduled executions, but gave no details.

Most references are a bit old posts saying it was not possible then. Some others pointed to a feature request (pending?). Perhaps in Redash v10 it is now possible (or there is some bizarre workaround to get it)

Thanks in advance

Carlos

1 Like

Hi again,

Replying to myself…, I found a (not perfect) workaround that could serve to others.

Although it is not possible to get the username of the one who is logged in query editor, we can retrieve (at least in Oracle and probably in others as well) the username defined in the datasource.

Simply as (select user from dual) we can get it. So, we can use the username of the datasource as something we can use in queries to filter data.

For example, creating a database user as “dept_x” for datasource and using as it were a role, we could use something like this:

Select data
From
all_depts_info_table
Where
condition1
and
column_dept = (select User from dual)

This way only data from dept_x will be shown. All users from dept_x could be associated to that datasource limiting the rows they could see.

Obviously, we are going to have as many datasources a roles, but, and this is important, the same query will serve for them all.

Hope this helps

Carlos

That’s an intriguing solution to this problem!

In broader terms, Redash doesn’t support credential passthrough. So every Redash user that uses one data source will share the same database credentials. However we’d like to implement credential passthrough as an extension to our existing query runner infrastructure. This way it can be implemented piecemeal by different query runners.