Move SignedInUser to user service and RoleType and Roles to org (#53445)
* Move SignedInUser to user service and RoleType and Roles to org * Use go naming convention for roles * Fix some imports and leftovers * Fix ldap debug test * Fix lint * Fix lint 2 * Fix lint 3 * Fix type and not needed conversion * Clean up messages in api tests * Clean up api tests 2
This commit is contained in:
@@ -17,6 +17,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/plugins/adapters"
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
"github.com/grafana/grafana/pkg/services/oauthtoken"
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/tsdb/grafanads"
|
||||
"github.com/grafana/grafana/pkg/tsdb/legacydata"
|
||||
@@ -72,7 +73,7 @@ func (s *Service) Run(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// QueryData can process queries and return query responses.
|
||||
func (s *Service) QueryData(ctx context.Context, user *models.SignedInUser, skipCache bool, reqDTO dtos.MetricRequest, handleExpressions bool) (*backend.QueryDataResponse, error) {
|
||||
func (s *Service) QueryData(ctx context.Context, user *user.SignedInUser, skipCache bool, reqDTO dtos.MetricRequest, handleExpressions bool) (*backend.QueryDataResponse, error) {
|
||||
parsedReq, err := s.parseMetricRequest(ctx, user, skipCache, reqDTO)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -84,7 +85,7 @@ func (s *Service) QueryData(ctx context.Context, user *models.SignedInUser, skip
|
||||
}
|
||||
|
||||
// QueryData can process queries and return query responses.
|
||||
func (s *Service) QueryDataMultipleSources(ctx context.Context, user *models.SignedInUser, skipCache bool, reqDTO dtos.MetricRequest, handleExpressions bool) (*backend.QueryDataResponse, error) {
|
||||
func (s *Service) QueryDataMultipleSources(ctx context.Context, user *user.SignedInUser, skipCache bool, reqDTO dtos.MetricRequest, handleExpressions bool) (*backend.QueryDataResponse, error) {
|
||||
byDataSource := models.GroupQueriesByDataSource(reqDTO.Queries)
|
||||
|
||||
if len(byDataSource) == 1 {
|
||||
@@ -111,7 +112,7 @@ func (s *Service) QueryDataMultipleSources(ctx context.Context, user *models.Sig
|
||||
}
|
||||
|
||||
// handleExpressions handles POST /api/ds/query when there is an expression.
|
||||
func (s *Service) handleExpressions(ctx context.Context, user *models.SignedInUser, parsedReq *parsedRequest) (*backend.QueryDataResponse, error) {
|
||||
func (s *Service) handleExpressions(ctx context.Context, user *user.SignedInUser, parsedReq *parsedRequest) (*backend.QueryDataResponse, error) {
|
||||
exprReq := expr.Request{
|
||||
OrgId: user.OrgId,
|
||||
Queries: []expr.Query{},
|
||||
@@ -143,7 +144,7 @@ func (s *Service) handleExpressions(ctx context.Context, user *models.SignedInUs
|
||||
return qdr, nil
|
||||
}
|
||||
|
||||
func (s *Service) handleQueryData(ctx context.Context, user *models.SignedInUser, parsedReq *parsedRequest) (*backend.QueryDataResponse, error) {
|
||||
func (s *Service) handleQueryData(ctx context.Context, user *user.SignedInUser, parsedReq *parsedRequest) (*backend.QueryDataResponse, error) {
|
||||
ds := parsedReq.parsedQueries[0].datasource
|
||||
if err := s.pluginRequestValidator.Validate(ds.Url, nil); err != nil {
|
||||
return nil, datasources.ErrDataSourceAccessDenied
|
||||
@@ -235,7 +236,7 @@ func customHeaders(jsonData *simplejson.Json, decryptedJsonData map[string]strin
|
||||
return headers
|
||||
}
|
||||
|
||||
func (s *Service) parseMetricRequest(ctx context.Context, user *models.SignedInUser, skipCache bool, reqDTO dtos.MetricRequest) (*parsedRequest, error) {
|
||||
func (s *Service) parseMetricRequest(ctx context.Context, user *user.SignedInUser, skipCache bool, reqDTO dtos.MetricRequest) (*parsedRequest, error) {
|
||||
if len(reqDTO.Queries) == 0 {
|
||||
return nil, NewErrBadQuery("no queries found")
|
||||
}
|
||||
@@ -299,7 +300,7 @@ func (s *Service) parseMetricRequest(ctx context.Context, user *models.SignedInU
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func (s *Service) getDataSourceFromQuery(ctx context.Context, user *models.SignedInUser, skipCache bool, query *simplejson.Json, history map[string]*datasources.DataSource) (*datasources.DataSource, error) {
|
||||
func (s *Service) getDataSourceFromQuery(ctx context.Context, user *user.SignedInUser, skipCache bool, query *simplejson.Json, history map[string]*datasources.DataSource) (*datasources.DataSource, error) {
|
||||
var err error
|
||||
uid := query.Get("datasource").Get("uid").MustString()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user