-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: check write permission in legacy write path #19980
Conversation
@@ -954,8 +954,7 @@ func (m *Launcher) run(ctx context.Context) (err error) { | |||
} | |||
} | |||
|
|||
// N.B. the BucketService used by the DBRP service doesn't perform authorization. | |||
dbrpSvc := dbrp.NewAuthorizedService(dbrp.NewService(ctx, ts.BucketService, m.kvStore)) | |||
dbrpSvc := dbrp.NewAuthorizedService(dbrp.NewService(ctx, authorizer.NewBucketService(ts.BucketService), m.kvStore)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this back in didn't fix the problem, but I was nervous about what other unknown effects it might be having.
@@ -94,7 +93,7 @@ func TestWriteHandler_BucketAndMappingExists(t *testing.T) { | |||
handler := NewWriterHandler(&PointsWriterBackend{ | |||
HTTPErrorHandler: DefaultErrorHandler, | |||
Logger: zaptest.NewLogger(t), | |||
BucketService: authorizer.NewBucketService(bucketService), | |||
BucketService: bucketService, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this accurately reflects the setup constructed by the influxd
launcher. It'd be nice to have one setup function that both the tests and main code could call, to ensure they stay in sync.
@@ -105,6 +104,84 @@ func TestWriteHandler_BucketAndMappingExists(t *testing.T) { | |||
assert.Equal(t, "", w.Body.String()) | |||
} | |||
|
|||
func TestWriteHandler_BucketAndMappingExistsNoPermissions(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good, this should help a lot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great – I'd suggested a minor change to follow the same pattern as the v2 API implementation of the write handler.
ca7af25
to
94be2e4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solid work – thanks for sorting this out and 💯 for adding additional tests
Closes #19974
This is a big of a hack, it doesn't fit how we structure our auth checks elsewhere. Suggestions appreciated!