RBAC: Permission check performance improvements for the new search (#60729)

* Add checker and update the resource filter function for new search

* Add tests for checker

* small fixes

* handle location for panels correctly

* clean up checker code and extend the tests for it

* more fixes, but tests don't quite work yet

* a small change to return error

* cleanup

* more simplification

* fix tests

* correct wrong argument ordering & use constant

* Apply suggestions from code review

Co-authored-by: Artur Wierzbicki <artur.wierzbicki@grafana.com>

* import

* check general folder from permission checker function

* handle root folder aka general folder properly

* update tests

* clean up

* lint

* add fix from main

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
Co-authored-by: Artur Wierzbicki <artur.wierzbicki@grafana.com>
This commit is contained in:
Ieva
2023-01-27 12:12:30 +00:00
committed by GitHub
co-authored by Artur Wierzbicki Karl Persson
parent dab3fac01b
commit eb9ef34272
27 changed files with 289 additions and 119 deletions
+2 -2
View File
@@ -13,7 +13,7 @@
// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []*json.RawMessage | Type: []json.RawMessage | Type: []string |
// +----------------+----------------+----------------+------------------+----------------+--------------------------+-------------------------+----------------+
// | dashboard | 2 | boom | | /pfix/d/2/ | null | [] | |
// | dashboard | 2 | boom | | /pfix/d/2/ | null | [] | general |
// +----------------+----------------+----------------+------------------+----------------+--------------------------+-------------------------+----------------+
//
//
@@ -122,7 +122,7 @@
[]
],
[
""
"general"
]
]
}
@@ -13,7 +13,7 @@
// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []*json.RawMessage | Type: []json.RawMessage | Type: []string |
// +----------------+----------------+----------------+------------------+----------------+--------------------------+-------------------------+----------------+
// | dashboard | 4 | One more dash | | /pfix/d/4/ | null | [] | |
// | dashboard | 4 | One more dash | | /pfix/d/4/ | null | [] | general |
// +----------------+----------------+----------------+------------------+----------------+--------------------------+-------------------------+----------------+
//
//
@@ -122,7 +122,7 @@
[]
],
[
""
"general"
]
]
}
@@ -13,7 +13,7 @@
// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []*json.RawMessage | Type: []json.RawMessage | Type: []string |
// +----------------+----------------+--------------------+------------------+----------------+--------------------------+-------------------------+----------------+
// | dashboard | 1 | Archer Data System | | /pfix/d/1/ | null | [] | |
// | dashboard | 1 | Archer Data System | | /pfix/d/1/ | null | [] | general |
// +----------------+----------------+--------------------+------------------+----------------+--------------------------+-------------------------+----------------+
//
//
@@ -122,7 +122,7 @@
[]
],
[
""
"general"
]
]
}
@@ -13,7 +13,7 @@
// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []*json.RawMessage | Type: []json.RawMessage | Type: []string |
// +----------------+----------------+--------------------+------------------+----------------+--------------------------+-------------------------+----------------+
// | dashboard | 1 | Archer Data System | | /pfix/d/1/ | null | [] | |
// | dashboard | 1 | Archer Data System | | /pfix/d/1/ | null | [] | general |
// +----------------+----------------+--------------------+------------------+----------------+--------------------------+-------------------------+----------------+
//
//
@@ -122,7 +122,7 @@
[]
],
[
""
"general"
]
]
}
@@ -13,7 +13,7 @@
// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []*json.RawMessage | Type: []json.RawMessage | Type: []string |
// +----------------+----------------+--------------------+------------------+----------------+--------------------------+-------------------------+----------------+
// | dashboard | 2 | Document Sync repo | | /pfix/d/2/ | null | [] | |
// | dashboard | 2 | Document Sync repo | | /pfix/d/2/ | null | [] | general |
// +----------------+----------------+--------------------+------------------+----------------+--------------------------+-------------------------+----------------+
//
//
@@ -122,7 +122,7 @@
[]
],
[
""
"general"
]
]
}
@@ -13,7 +13,7 @@
// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []*json.RawMessage | Type: []json.RawMessage | Type: []string |
// +----------------+----------------+--------------------+------------------+----------------+--------------------------+-------------------------+----------------+
// | dashboard | 1 | Archer Data System | | /pfix/d/1/ | null | [] | |
// | dashboard | 1 | Archer Data System | | /pfix/d/1/ | null | [] | general |
// +----------------+----------------+--------------------+------------------+----------------+--------------------------+-------------------------+----------------+
//
//
@@ -122,7 +122,7 @@
[]
],
[
""
"general"
]
]
}
@@ -13,7 +13,7 @@
// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []*json.RawMessage | Type: []json.RawMessage | Type: []string |
// +----------------+----------------+----------------+------------------+----------------+--------------------------+-------------------------+----------------+
// | dashboard | 1 | heatTorkel | | /pfix/d/1/ | null | [] | |
// | dashboard | 1 | heatTorkel | | /pfix/d/1/ | null | [] | general |
// +----------------+----------------+----------------+------------------+----------------+--------------------------+-------------------------+----------------+
//
//
@@ -122,7 +122,7 @@
[]
],
[
""
"general"
]
]
}
@@ -13,7 +13,7 @@
// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []*json.RawMessage | Type: []json.RawMessage | Type: []string |
// +----------------+----------------+----------------+------------------+----------------+--------------------------+-------------------------+----------------+
// | dashboard | 1 | heat-torkel | | /pfix/d/1/ | null | [] | |
// | dashboard | 1 | heat-torkel | | /pfix/d/1/ | null | [] | general |
// +----------------+----------------+----------------+------------------+----------------+--------------------------+-------------------------+----------------+
//
//
@@ -122,7 +122,7 @@
[]
],
[
""
"general"
]
]
}
+4 -4
View File
@@ -13,8 +13,8 @@
// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []*json.RawMessage | Type: []json.RawMessage | Type: []string |
// +----------------+----------------+------------------+------------------+----------------+--------------------------+-------------------------+----------------+
// | dashboard | 1 | heat-torkel | | /pfix/d/1/ | null | [] | |
// | dashboard | 2 | topology heatmap | | /pfix/d/2/ | null | [] | |
// | dashboard | 1 | heat-torkel | | /pfix/d/1/ | null | [] | general |
// | dashboard | 2 | topology heatmap | | /pfix/d/2/ | null | [] | general |
// +----------------+----------------+------------------+------------------+----------------+--------------------------+-------------------------+----------------+
//
//
@@ -130,8 +130,8 @@
[]
],
[
"",
""
"general",
"general"
]
]
}
@@ -13,7 +13,7 @@
// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []*json.RawMessage | Type: []json.RawMessage | Type: []string |
// +----------------+----------------+--------------------+------------------+----------------+--------------------------+-------------------------+----------------+
// | dashboard | 1 | Archer Data System | | /pfix/d/1/ | null | [] | |
// | dashboard | 1 | Archer Data System | | /pfix/d/1/ | null | [] | general |
// +----------------+----------------+--------------------+------------------+----------------+--------------------------+-------------------------+----------------+
//
//
@@ -122,7 +122,7 @@
[]
],
[
""
"general"
]
]
}
@@ -13,7 +13,7 @@
// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []*json.RawMessage | Type: []json.RawMessage | Type: []string |
// +----------------+----------------+--------------------+------------------+----------------+--------------------------+-------------------------+----------------+
// | dashboard | 1 | Archer Data System | | /pfix/d/1/ | null | [] | |
// | dashboard | 1 | Archer Data System | | /pfix/d/1/ | null | [] | general |
// +----------------+----------------+--------------------+------------------+----------------+--------------------------+-------------------------+----------------+
//
//
@@ -122,7 +122,7 @@
[]
],
[
""
"general"
]
]
}
@@ -13,7 +13,7 @@
// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []*json.RawMessage | Type: []json.RawMessage | Type: []string |
// +----------------+----------------+--------------------+------------------+----------------+--------------------------+-------------------------+----------------+
// | dashboard | 2 | Document Sync repo | | /pfix/d/2/ | null | [] | |
// | dashboard | 2 | Document Sync repo | | /pfix/d/2/ | null | [] | general |
// +----------------+----------------+--------------------+------------------+----------------+--------------------------+-------------------------+----------------+
//
//
@@ -122,7 +122,7 @@
[]
],
[
""
"general"
]
]
}
+2 -2
View File
@@ -13,7 +13,7 @@
// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []*json.RawMessage | Type: []json.RawMessage | Type: []string |
// +----------------+----------------+--------------------+------------------+----------------+--------------------------+-------------------------+----------------+
// | dashboard | 2 | Document Sync repo | | /pfix/d/2/ | null | [] | |
// | dashboard | 2 | Document Sync repo | | /pfix/d/2/ | null | [] | general |
// +----------------+----------------+--------------------+------------------+----------------+--------------------------+-------------------------+----------------+
//
//
@@ -122,7 +122,7 @@
[]
],
[
""
"general"
]
]
}
@@ -13,7 +13,7 @@
// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []*json.RawMessage | Type: []json.RawMessage | Type: []string |
// +----------------+----------------+--------------------------------+------------------+----------------+--------------------------+-------------------------+----------------+
// | dashboard | 1 | Eyjafjallajökull Eruption data | | /pfix/d/1/ | null | [] | |
// | dashboard | 1 | Eyjafjallajökull Eruption data | | /pfix/d/1/ | null | [] | general |
// +----------------+----------------+--------------------------------+------------------+----------------+--------------------------+-------------------------+----------------+
//
//
@@ -122,7 +122,7 @@
[]
],
[
""
"general"
]
]
}
@@ -13,7 +13,7 @@
// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []*json.RawMessage | Type: []json.RawMessage | Type: []string |
// +----------------+----------------+----------------------------------------------------------------------+------------------+----------------+--------------------------+-------------------------+----------------+
// | dashboard | 1 | Three can keep a secret, if two of them are dead (Benjamin Franklin) | | /pfix/d/1/ | null | [] | |
// | dashboard | 1 | Three can keep a secret, if two of them are dead (Benjamin Franklin) | | /pfix/d/1/ | null | [] | general |
// +----------------+----------------+----------------------------------------------------------------------+------------------+----------------+--------------------------+-------------------------+----------------+
//
//
@@ -122,7 +122,7 @@
[]
],
[
""
"general"
]
]
}
+4 -4
View File
@@ -14,8 +14,8 @@
// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []*json.RawMessage | Type: []json.RawMessage | Type: []string | Type: []float64 |
// +----------------+----------------+----------------+------------------+----------------+--------------------------+-------------------------+----------------+-----------------+
// | dashboard | 1 | a-test | | /pfix/d/1/ | null | [] | | 0 |
// | dashboard | 2 | z-test | | /pfix/d/2/ | null | [] | | 1 |
// | dashboard | 1 | a-test | | /pfix/d/1/ | null | [] | general | 0 |
// | dashboard | 2 | z-test | | /pfix/d/2/ | null | [] | general | 1 |
// +----------------+----------------+----------------+------------------+----------------+--------------------------+-------------------------+----------------+-----------------+
//
//
@@ -139,8 +139,8 @@
[]
],
[
"",
""
"general",
"general"
],
[
0,
+4 -4
View File
@@ -14,8 +14,8 @@
// | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: | Labels: |
// | Type: []string | Type: []string | Type: []string | Type: []string | Type: []string | Type: []*json.RawMessage | Type: []json.RawMessage | Type: []string | Type: []float64 |
// +----------------+----------------+----------------+------------------+----------------+--------------------------+-------------------------+----------------+-----------------+
// | dashboard | 2 | z-test | | /pfix/d/2/ | null | [] | | 3 |
// | dashboard | 1 | a-test | | /pfix/d/1/ | null | [] | | 2 |
// | dashboard | 2 | z-test | | /pfix/d/2/ | null | [] | general | 3 |
// | dashboard | 1 | a-test | | /pfix/d/1/ | null | [] | general | 2 |
// +----------------+----------------+----------------+------------------+----------------+--------------------------+-------------------------+----------------+-----------------+
//
//
@@ -139,8 +139,8 @@
[]
],
[
"",
""
"general",
"general"
],
[
3,