saadmuqtadeer opened a new issue, #34203:
URL: https://github.com/apache/superset/issues/34203

   ### Bug description
   
   Trying to apply different RLS clause for different datasets by passing 
dataset ID, but every time superset is applying each clause to all 
charts/datasets which is ending up as Errors, Error: column "XYZ" does not 
exist. 
   
   ### Code
   ```
   public async Task<string> GenerateUserSpecificGuestTokenAsync(string 
dashboardId, string email, List<string> roles)
   {
       string adminToken = await GetAdminAccessTokenAsync();
       _httpClient.DefaultRequestHeaders.Authorization = new 
AuthenticationHeaderValue("Bearer", adminToken);
   
       // ✅ Correct RLS rules with dataset-specific bindings
       var rlsRules = new List<object>
       {
           new {
               datasource = new { id = 41, type = "table" },
               clause = $"'{email}' = ANY(capabilityowner)"
           },
           new {
               datasource = new { id = 42, type = "table" },
               clause = $"'{email}' = ANY(businessowner) OR '{email}' = 
ANY(technicalowner)"
           },
           new {
               datasource = new { id = 43, type = "table" },
               clause = $"'{email}' = ANY(businessowner) OR '{email}' = 
ANY(technicalowner)"
           }
       };
   
       var guestTokenRequest = new
       {
           user = new
           {
               username = _guestUserName,
           },
           resources = new List<object>
           {
               new { type = "dashboard", id = dashboardId }
           },
           rls = rlsRules, // ✅ Pass under "rls", not "rls_rules"
           duration = 600
       };
   
       var guestTokenUrl = $"{_supersetUrl}/api/v1/security/guest_token/";
       var response = await _httpClient.PostAsync(
           guestTokenUrl,
           new StringContent(JsonSerializer.Serialize(guestTokenRequest), 
Encoding.UTF8, "application/json")
       );
   
       response.EnsureSuccessStatusCode();
       var responseData = JsonSerializer.Deserialize<JsonElement>(await 
response.Content.ReadAsStringAsync());
       return responseData.GetProperty("token").GetString();
   }
   
   The JSON guest token which is being generated is does not contain details of 
DataSource which is being passed while generating the guest token. 
   
   ```
   
   ### Screenshots/recordings
   
   <img width="1132" height="525" alt="Image" 
src="https://github.com/user-attachments/assets/c3b67c3a-1288-4475-9fc3-1f227be8a1bf";
 />
   
   ### Superset version
   
   master / latest-dev
   
   ### Python version
   
   3.9
   
   ### Node version
   
   16
   
   ### Browser
   
   Chrome
   
   ### Additional context
   
   _No response_
   
   ### Checklist
   
   - [x] I have searched Superset docs and Slack and didn't find a solution to 
my problem.
   - [x] I have searched the GitHub issue tracker and didn't find a similar bug 
report.
   - [ ] I have checked Superset's logs for errors and if I found a relevant 
Python stacktrace, I included it here as text in the "additional context" 
section.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to