Plugins: Modify interface for plugin validations to allow taking PDC into account (#96089)
* Request interceptor: Do not block PDC * Apply change after feedback received * Add test * Check if secure socks proxy configured for the instance * Apply suggestions from code review * Add dedicated service for datasource request URL validation (#99179) --------- Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
This commit is contained in:
co-authored by
Will Browne
parent
33a53d170b
commit
d192a44469
@@ -2,14 +2,26 @@ package validations
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
)
|
||||
|
||||
type OSSPluginRequestValidator struct{}
|
||||
type OSSDataSourceRequestValidator struct{}
|
||||
|
||||
func (*OSSPluginRequestValidator) Validate(string, *http.Request) error {
|
||||
func (*OSSDataSourceRequestValidator) Validate(*datasources.DataSource, *http.Request) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func ProvideValidator() *OSSPluginRequestValidator {
|
||||
return &OSSPluginRequestValidator{}
|
||||
func ProvideValidator() *OSSDataSourceRequestValidator {
|
||||
return &OSSDataSourceRequestValidator{}
|
||||
}
|
||||
|
||||
type OSSDataSourceRequestURLValidator struct{}
|
||||
|
||||
func (*OSSDataSourceRequestURLValidator) Validate(string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func ProvideURLValidator() *OSSDataSourceRequestURLValidator {
|
||||
return &OSSDataSourceRequestURLValidator{}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,18 @@ package validations
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
)
|
||||
|
||||
type PluginRequestValidator interface {
|
||||
type DataSourceRequestValidator interface {
|
||||
// Validate performs a request validation based
|
||||
// on the data source URL and some of the request
|
||||
// attributes (headers, cookies, etc).
|
||||
Validate(dsURL string, req *http.Request) error
|
||||
Validate(ds *datasources.DataSource, req *http.Request) error
|
||||
}
|
||||
|
||||
type DataSourceRequestURLValidator interface {
|
||||
// Validate performs a request validation based on the data source URL
|
||||
Validate(dsURL string) error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user