Skip to content
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

Merged
merged 5 commits into from
Nov 10, 2020

Conversation

danxmoran
Copy link
Contributor

@danxmoran danxmoran commented Nov 10, 2020

Closes #19974

This is a big of a hack, it doesn't fit how we structure our auth checks elsewhere. Suggestions appreciated!

  • CHANGELOG.md updated with a link to the PR (not the Issue)
  • Well-formatted commit messages
  • Rebased/mergeable
  • Tests pass
  • http/swagger.yml updated (if modified Go structs or API)
  • Feature flagged (if modified API)
  • Documentation updated or issue created (provide link to issue/pr)
  • Signed CLA (if not already signed)

@@ -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))
Copy link
Contributor Author

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,
Copy link
Contributor Author

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) {
Copy link
Contributor

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.

Copy link
Contributor

@stuartcarnie stuartcarnie left a 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.

http/legacy/write_handler.go Outdated Show resolved Hide resolved
@danxmoran danxmoran marked this pull request as ready for review November 10, 2020 23:21
Copy link
Contributor

@stuartcarnie stuartcarnie left a 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

@danxmoran danxmoran merged commit d8e7de9 into master Nov 10, 2020
@danxmoran danxmoran deleted the dm-legacy-write-auth-19974 branch November 10, 2020 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade: User with a read only permission should not be able to write into a bucket
3 participants