Skip to content

Commit

Permalink
Merge pull request #17285 from influxdata/la/fix-label-service
Browse files Browse the repository at this point in the history
fix(http): make label service authorized by default
  • Loading branch information
affo authored Mar 16, 2020
2 parents ab1081a + 8a368fa commit 04b86df
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
6 changes: 2 additions & 4 deletions http/api_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func NewAPIHandler(b *APIBackend, opts ...APIHandlerOptFn) *APIHandler {

noAuthUserResourceMappingService := b.UserResourceMappingService
b.UserResourceMappingService = authorizer.NewURMService(b.OrgLookupService, b.UserResourceMappingService)
b.LabelService = authorizer.NewLabelServiceWithOrg(b.LabelService, b.OrgLookupService)

h.Mount("/api/v2", serveLinksHandler(b.HTTPErrorHandler))

Expand All @@ -128,7 +129,6 @@ func NewAPIHandler(b *APIBackend, opts ...APIHandlerOptFn) *APIHandler {

bucketBackend := NewBucketBackend(b.Logger.With(zap.String("handler", "bucket")), b)
bucketBackend.BucketService = authorizer.NewBucketService(b.BucketService, noAuthUserResourceMappingService)
bucketBackend.LabelService = authorizer.NewLabelServiceWithOrg(b.LabelService, b.OrgLookupService)
h.Mount(prefixBuckets, NewBucketHandler(b.Logger, bucketBackend))

checkBackend := NewCheckBackend(b.Logger.With(zap.String("handler", "check")), b)
Expand All @@ -146,14 +146,13 @@ func NewAPIHandler(b *APIBackend, opts ...APIHandlerOptFn) *APIHandler {
h.Mount(prefixDelete, NewDeleteHandler(b.Logger, deleteBackend))

documentBackend := NewDocumentBackend(b.Logger.With(zap.String("handler", "document")), b)
documentBackend.LabelService = authorizer.NewLabelServiceWithOrg(b.LabelService, b.OrgLookupService)
documentBackend.DocumentService = authorizer.NewDocumentService(b.DocumentService)
h.Mount(prefixDocuments, NewDocumentHandler(documentBackend))

fluxBackend := NewFluxBackend(b.Logger.With(zap.String("handler", "query")), b)
h.Mount(prefixQuery, NewFluxHandler(b.Logger, fluxBackend))

h.Mount(prefixLabels, NewLabelHandler(b.Logger, authorizer.NewLabelServiceWithOrg(b.LabelService, b.OrgLookupService), b.HTTPErrorHandler))
h.Mount(prefixLabels, NewLabelHandler(b.Logger, b.LabelService, b.HTTPErrorHandler))

notificationEndpointBackend := NewNotificationEndpointBackend(b.Logger.With(zap.String("handler", "notificationEndpoint")), b)
notificationEndpointBackend.NotificationEndpointService = authorizer.NewNotificationEndpointService(b.NotificationEndpointService,
Expand All @@ -168,7 +167,6 @@ func NewAPIHandler(b *APIBackend, opts ...APIHandlerOptFn) *APIHandler {
orgBackend := NewOrgBackend(b.Logger.With(zap.String("handler", "org")), b)
orgBackend.OrganizationService = authorizer.NewOrgService(b.OrganizationService)
orgBackend.SecretService = authorizer.NewSecretService(b.SecretService)
orgBackend.LabelService = authorizer.NewLabelServiceWithOrg(b.LabelService, b.OrgLookupService)
h.Mount(prefixOrganizations, NewOrgHandler(b.Logger, orgBackend))

scraperBackend := NewScraperBackend(b.Logger.With(zap.String("handler", "scraper")), b)
Expand Down
2 changes: 1 addition & 1 deletion http/check_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func NewCheckHandler(log *zap.Logger, b *CheckBackend) *CheckHandler {
HTTPErrorHandler: b.HTTPErrorHandler,
log: b.log.With(zap.String("handler", "label")),
LabelService: b.LabelService,
ResourceType: influxdb.TelegrafsResourceType,
ResourceType: influxdb.ChecksResourceType,
}
h.HandlerFunc("GET", checksIDLabelsPath, newGetLabelsHandler(labelBackend))
h.HandlerFunc("POST", checksIDLabelsPath, newPostLabelHandler(labelBackend))
Expand Down
2 changes: 1 addition & 1 deletion http/notification_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func NewNotificationEndpointHandler(log *zap.Logger, b *NotificationEndpointBack
HTTPErrorHandler: b.HTTPErrorHandler,
log: b.log.With(zap.String("handler", "label")),
LabelService: b.LabelService,
ResourceType: influxdb.TelegrafsResourceType,
ResourceType: influxdb.NotificationEndpointResourceType,
}
h.HandlerFunc("GET", notificationEndpointsIDLabelsPath, newGetLabelsHandler(labelBackend))
h.HandlerFunc("POST", notificationEndpointsIDLabelsPath, newPostLabelHandler(labelBackend))
Expand Down
2 changes: 1 addition & 1 deletion http/notification_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func NewNotificationRuleHandler(log *zap.Logger, b *NotificationRuleBackend) *No
HTTPErrorHandler: b.HTTPErrorHandler,
log: b.log.With(zap.String("handler", "label")),
LabelService: b.LabelService,
ResourceType: influxdb.TelegrafsResourceType,
ResourceType: influxdb.NotificationRuleResourceType,
}
h.HandlerFunc("GET", notificationRulesIDLabelsPath, newGetLabelsHandler(labelBackend))
h.HandlerFunc("POST", notificationRulesIDLabelsPath, newPostLabelHandler(labelBackend))
Expand Down

0 comments on commit 04b86df

Please sign in to comment.