Quota: Fix failure when checking session limits (#58865)

This commit is contained in:
Sofia Papagiannaki
2022-11-17 00:30:27 +01:00
committed by GitHub
parent c4528f9bd8
commit ab36252c86
5 changed files with 12 additions and 8 deletions
@@ -104,7 +104,7 @@ func getContextHandler(t *testing.T) *ContextHandler {
return ProvideService(cfg, userAuthTokenSvc, authJWTSvc, remoteCacheSvc,
renderSvc, sqlStore, tracer, authProxy, loginService, nil, authenticator,
&userService, orgService, nil, nil)
&userService, orgService, nil, nil, nil)
}
type FakeGetSignUserStore struct {
@@ -22,6 +22,7 @@ import (
"github.com/grafana/grafana/pkg/middleware/cookies"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/apikey"
"github.com/grafana/grafana/pkg/services/auth"
"github.com/grafana/grafana/pkg/services/contexthandler/authproxy"
"github.com/grafana/grafana/pkg/services/contexthandler/ctxkey"
"github.com/grafana/grafana/pkg/services/featuremgmt"
@@ -48,6 +49,11 @@ func ProvideService(cfg *setting.Cfg, tokenService models.UserTokenService, jwtS
tracer tracing.Tracer, authProxy *authproxy.AuthProxy, loginService login.Service,
apiKeyService apikey.Service, authenticator loginpkg.Authenticator, userService user.Service,
orgService org.Service, oauthTokenService oauthtoken.OAuthTokenService, features *featuremgmt.FeatureManager,
// before 9.3.0 the quota service used to depend on on the ActiveTokenService
// since 9.3.0 after the quota refactoring ActiveTokenService depends on the quota
// therefore it's added to avoid cycle dependencies
// since it's used only by the middleware for enforcing quota limits.
activeTokenService auth.ActiveTokenService,
) *ContextHandler {
return &ContextHandler{
Cfg: cfg,
+3 -5
View File
@@ -82,12 +82,10 @@ func (s *service) QuotaReached(c *models.ReqContext, targetSrv quota.TargetSrv)
return false, nil
}
var params *quota.ScopeParameters
params := &quota.ScopeParameters{}
if c.IsSignedIn {
params = &quota.ScopeParameters{
OrgID: c.OrgID,
UserID: c.UserID,
}
params.OrgID = c.OrgID
params.UserID = c.UserID
}
return s.CheckQuotaReached(c.Req.Context(), targetSrv, params)
}