[v11.2.x] Canvas: Allow API calls to grafana origin (#94129)

Canvas: Allow API calls to grafana origin  (#91822)

* allow post URL
* check for config
* allow relative paths
* add allowed internal pattern; add checks for method
* update defaults.ini
* add custom header
* update config comment
* use globbing, switch to older middleware - deprecated call
* add codeowner
* update to use current api, add test
* update fall through logic

* Update pkg/middleware/validate_action_url.go

Co-authored-by: Dan Cech <dcech@grafana.com>

* Update pkg/middleware/validate_action_url.go

Co-authored-by: Dan Cech <dcech@grafana.com>

* add more tests

* Update pkg/middleware/validate_action_url_test.go

Co-authored-by: Dan Cech <dcech@grafana.com>

* fix request headers

* add additional tests for all verbs

* fix request headers++

* throw error when method is unknown

---------

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
Co-authored-by: Brian Gann <bkgann@gmail.com>
Co-authored-by: Brian Gann <briangann@users.noreply.github.com>
Co-authored-by: Dan Cech <dcech@grafana.com>
(cherry picked from commit f64b121ddb)

Co-authored-by: Adela Almasan <88068998+adela-almasan@users.noreply.github.com>
This commit is contained in:
grafana-delivery-bot[bot]
2024-10-01 23:21:23 -04:00
committed by GitHub
co-authored by Adela Almasan
parent 35b3075d06
commit c4b8303799
8 changed files with 476 additions and 35 deletions
+2
View File
@@ -179,6 +179,7 @@ type Cfg struct {
DisableFrontendSandboxForPlugins []string
DisableGravatar bool
DataProxyWhiteList map[string]bool
ActionsAllowPostURL string
TempDataLifetime time.Duration
@@ -1521,6 +1522,7 @@ func readSecuritySettings(iniFile *ini.File, cfg *Cfg) error {
cfg.ContentTypeProtectionHeader = security.Key("x_content_type_options").MustBool(true)
cfg.XSSProtectionHeader = security.Key("x_xss_protection").MustBool(true)
cfg.ActionsAllowPostURL = security.Key("actions_allow_post_url").MustString("")
cfg.StrictTransportSecurity = security.Key("strict_transport_security").MustBool(false)
cfg.StrictTransportSecurityMaxAge = security.Key("strict_transport_security_max_age_seconds").MustInt(86400)
cfg.StrictTransportSecurityPreload = security.Key("strict_transport_security_preload").MustBool(false)