-
Notifications
You must be signed in to change notification settings - Fork 249
Fix context sql #2344
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
base: main
Are you sure you want to change the base?
Fix context sql #2344
Conversation
// Append statement to set read only param value - can be set only once for a connection. | ||
string statementToSetReadOnlyParam = "EXEC sp_set_session_context " + $"'{claimType}', " + paramName + ", @read_only = 1;"; | ||
string statementToSetReadOnlyParam = "EXEC sp_set_session_context " + $"'{claimType}', " + paramName + ", @read_only = 0;"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curious, did you experience - your mutation operations being blocked because of this setting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the SQL Endpoint did reject the second query as described in #2341
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this smart change to provide the original roles for additional filtering. Left a few nit comments and some questions, looks good to merge otherwise!
/azp run |
src/Core/Parsers/RequestParser.cs
Outdated
@@ -30,7 +30,7 @@ public class RequestParser | |||
/// <summary> | |||
/// Prefix used for specifying limit in the query string of the URL. | |||
/// </summary> | |||
public const string FIRST_URL = "$first"; | |||
public const string FIRST_URL = "$top"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will provide a synonym $top soon. Lets not make this change in this PR. Thank you for your patience.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related #2474
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original PR contained fewer changes, please restrict the changes to the purpose of the PR and lets not add additional changes in the same PR. Waiting for removing the unnecessary changes
@M4Al , let us know if you would be able to address the comments... |
@Aniruddh25 is this something we could wrap? |
The original PR was useful. It now contains additional changes which are not really necessary like $top, DwSQL builder changes. We need to clean those up before merging this in. |
@M4Al, we will take this PR forward and merge from here. |
Added a new constant `ORIGINAL_ROLE_CLAIM_TYPE` in `AuthenticationOptions.cs` to store the original roles claim type. Modified `AuthorizationResolver` to preserve the original 'roles' claim by adding it to the `resolvedClaims` dictionary under the new key. Changed `MsSqlQueryExecutor` to set session context parameters with `@read_only = 0` to allow modifications.
This reverts commit 08f741c.
remove trailing space Co-authored-by: Aniruddh Munde <[email protected]>
Updated the constant `FIRST_URL` in `RequestParser.cs` within the `Azure.DataApiBuilder.Core.Parsers` namespace to use the value `"$top"` instead of `"$first"`. This change aligns with naming conventions or standards used elsewhere in the codebase or API, ensuring consistency and improving clarity for developers.
1479f34
to
de8752e
Compare
/azp run |
Azure Pipelines successfully started running 6 pipeline(s). |
Why make this change?
What is this change?
The changes itself are quite simple and should break nothing, see the diff :-)
How was this tested?
I have not created/adapted any tests yet. Just looking for comments before I go there.
Sample Request(s)
Sample of a JWT token (only the relevant part)
X-MS-API-ROLE: user
before my change the extra 'roles' that do not match the X-MS-API-ROLE header would never reach the database context.
With my change you can do things like this in SQL Predicates to filter out only subsets of the data: