influxdb/testing
Jamie Strandboge e304ef9764
fix: add write permissions check for DELETE and DROP MEASUREMENT (#23219)
We previously allowed read tokens access to all of v1 query, including
InfluxQL queries that made state changes to the DB, specifically,
'DELETE' and 'DROP MEASUREMENT'. This allowed tokens with only read
permissions to delete points via the legacy /query endpoint.
/api/v2/query was unaffected.

This adjusts the behavior to verify that the token has write permissions
when specifying 'DELETE' and 'DROP MEASUREMENT' InfluxQL queries. We
follow the same pattern as other existing v1 failure scenarios and
instead of failing hard with 401, we use ectx.Send() to send an error to
the user (with 200 status):

{"results":[{"statement_id":0,"error":"insufficient permissions"}]}

Returning in this manner is consistent with Cloud 2, which also returns
200 with "insufficient permissions" for these two InfluxQL queries.

To facilitate authorization unit tests, we add MustNewPermission() to
testing/util.go.

Closes: #22799
2022-03-24 07:28:38 -05:00
..
auth.go fix: more expressive errors (#22448) 2021-09-13 15:12:35 -04:00
bucket_service.go fix: more expressive errors (#22448) 2021-09-13 15:12:35 -04:00
dbrp_mapping.go fix: more expressive errors (#22448) 2021-09-13 15:12:35 -04:00
id.go refactor: automated move of errors and id from root to kit (#21101) 2021-03-30 14:10:02 -04:00
index.go fix(telegraf): support pagination parameters when listing 2020-11-04 15:53:02 +00:00
keyvalue_log.go fix(testing): accidental shadowing in parallel tests (#18945) 2020-07-14 16:18:21 +01:00
kv.go feat(kv): add support for WithCursorLimit to ForwardCursor (#17524) 2020-08-26 12:10:00 +01:00
label_service.go fix: more expressive errors (#22448) 2021-09-13 15:12:35 -04:00
migration.go feat: recommend `influxd downgrade` after encountering unknown KV migration (#22805) 2021-11-01 11:07:54 -04:00
onboarding.go fix: more expressive errors (#22448) 2021-09-13 15:12:35 -04:00
organization_service.go fix: more expressive errors (#22448) 2021-09-13 15:12:35 -04:00
passwords.go fix: more expressive errors (#22448) 2021-09-13 15:12:35 -04:00
scraper_target.go fix: more expressive errors (#22448) 2021-09-13 15:12:35 -04:00
secret.go fix: more expressive errors (#22448) 2021-09-13 15:12:35 -04:00
session.go fix: more expressive errors (#22448) 2021-09-13 15:12:35 -04:00
source.go fix: more expressive errors (#22448) 2021-09-13 15:12:35 -04:00
user_resource_mapping_service.go fix: more expressive errors (#22448) 2021-09-13 15:12:35 -04:00
user_service.go fix: more expressive errors (#22448) 2021-09-13 15:12:35 -04:00
util.go fix: add write permissions check for DELETE and DROP MEASUREMENT (#23219) 2022-03-24 07:28:38 -05:00
variable.go fix: more expressive errors (#22448) 2021-09-13 15:12:35 -04:00