Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: MSSQL (and related) - EXEC sp_set_session_context is executed with @read_only = 1 #2341

Open
1 task done
M4Al opened this issue Aug 20, 2024 · 0 comments · May be fixed by #2344
Open
1 task done

[Bug]: MSSQL (and related) - EXEC sp_set_session_context is executed with @read_only = 1 #2341

M4Al opened this issue Aug 20, 2024 · 0 comments · May be fixed by #2344
Labels
bug Something isn't working cri Customer Reported issue triage issues to be triaged
Milestone

Comments

@M4Al
Copy link

M4Al commented Aug 20, 2024

What happened?

Running on Analytics SQL Endpoint on Fabric

I was trying a row-level-security scenario, based on the one in the documentation.

So I did:
"data-source": { "database-type": "DWSQL", "connection-string": "Data Source=XXXXXXXl", "options": { "set-session-context": true } },

And then configured JWT AzureAD authentication with a custom role. This all works fine.

When I do a query now, just prior to executing the query, in the `src\Core\Resolvers\MsSqlQueryExecutor.cs:222we see the following:string statementToSetReadOnlyParam = "EXEC sp_set_session_context " + $"'{claimType}', " + paramName + ", @read_only = 1;";`

This is executed on every query execution from the frontend:

string sessionParamsQuery = GetSessionParamsQuery(httpContext, parameters, dataSourceName); cmd.CommandText = sessionParamsQuery + sqltext;

I see two issues:

  • This second request fails with Cannot set key 'roles' in the session context. The key has been set as read_only for this session. from the database, as the context is created with read_only=1
  • If a second request comes in, from a different user it will re-use the existing connection, leading to possible race conditions if multiple users are querying since the connection is shared between all users.

The second issue could be my misunderstading of how the backend SQL engine handles these cases.

Version

1.2.10

What database are you using?

Azure SQL

What hosting model are you using?

Container Apps

Which API approach are you accessing DAB through?

GraphQL

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@M4Al M4Al added bug Something isn't working triage issues to be triaged labels Aug 20, 2024
This was referenced Aug 20, 2024
@seantleonard seantleonard added the cri Customer Reported issue label Aug 22, 2024
@seantleonard seantleonard added this to the Backlog milestone Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cri Customer Reported issue triage issues to be triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants