AccessControl: Extend scope parameters with extra params from context (#39722)
* AccessControl: Extend scope parameters with extra params from context Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
This commit is contained in:
co-authored by
Emil Tullstedt
parent
d1b2b10e6a
commit
458371c8eb
@@ -18,8 +18,14 @@ func Scope(parts ...string) string {
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// Parameter returns injectable scope part
|
||||
// Parameter returns injectable scope part, based on URL parameters.
|
||||
// e.g. Scope("users", Parameter(":id")) or "users:" + Parameter(":id")
|
||||
func Parameter(key string) string {
|
||||
return fmt.Sprintf(`{{ index . "%s" }}`, key)
|
||||
return fmt.Sprintf(`{{ index .URLParams "%s" }}`, key)
|
||||
}
|
||||
|
||||
// Field returns an injectable scope part for selected fields from the request's context available in accesscontrol.ScopeParams.
|
||||
// e.g. Scope("orgs", Parameter("OrgID")) or "orgs:" + Parameter("OrgID")
|
||||
func Field(key string) string {
|
||||
return fmt.Sprintf(`{{ .%s }}`, key)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user