[v9.3.x] Access Control: Clear user's permission cache after resource creation (#59307)
Access Control: Clear user's permission cache after resource creation (#59101)
* refresh user's permission cache after resource creation
* clear the cache instead of reloading the permissions
* don't error if can't clear cache
* fix tests
* fix tests again
(cherry picked from commit a8bae3f0b0)
Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
This commit is contained in:
co-authored by
Ieva
parent
d147f3d366
commit
2e36890b56
@@ -396,6 +396,12 @@ func (hs *HTTPServer) AddDataSource(c *models.ReqContext) response.Response {
|
||||
return response.Error(500, "Failed to add datasource", err)
|
||||
}
|
||||
|
||||
// Clear permission cache for the user who's created the data source, so that new permissions are fetched for their next call
|
||||
// Required for cases when caller wants to immediately interact with the newly created object
|
||||
if !hs.AccessControl.IsDisabled() {
|
||||
hs.accesscontrolService.ClearUserPermissionCache(c.SignedInUser)
|
||||
}
|
||||
|
||||
ds := hs.convertModelToDtos(c.Req.Context(), cmd.Result)
|
||||
return response.JSON(http.StatusOK, util.DynMap{
|
||||
"message": "Datasource added",
|
||||
|
||||
Reference in New Issue
Block a user