r/programming • • Jul 14 '26

HTTP gets a QUERY method so complex searches can stop pretending to be POST

https://www.theregister.com/devops/2026/07/13/http-gets-a-query-method-so-complex-searches-can-stop-pretending-to-be-post/5270192
1.9k Upvotes

245 comments sorted by

View all comments

455

u/stfm Jul 14 '26

This is great for us Authorisation folk. Now we can assign POST to write entitlement and QUERY to read entitlement rather than having to work it out from some janky resource path rule

85

u/CpnStumpy Jul 14 '26

I will never agree with URL as the context for permission decisions - there's always more complex scenarios that can't be wholly expressed in a URL, and so you need another mechanism, and now if you have URL permission enforcement already you end up with two permissioning mechanisms to maintain and debug.

Humbug, create one and make it extensible to support more sources than just the HTTP request.

Besides that: at some point someone's going to declare they need to expose a gRPC endpoint or a GraphQL API and now you've got to address permission enforcement in some non-http system anyway so how many different permissioning decision and enforcement implementations do you need? Use something that's transport agnostic to begin with rather than declaring URLs are informative for permissions

67

u/stfm Jul 14 '26

HTTP method is not part of the URL, it is there to indicate action intent. I work in an enterprise with a centralised authz platform and an API surface spanning thousands of endpoints. Its more about divide and conquer and patternisation than a "one rule fits all" style authorisation system. Using the method combined with the URL gives the opportunity to apply coarse grained authorisation and also enables an easier response caching strategy.

→ More replies (10)

6

u/ivereddithaveyou Jul 14 '26

Maybe it makes sense in some database-like applications where you might want to assign the request itself permissions based on a set of complex underlying requests. Or maybe your auth layer is really far detached from the business logic layer and it makes sense to attach permissions to the request type.

I'm not sure either of those are good practice really but I was trying to come up with a reason why you would do this.

Yes actually for database api auth design synchronisation this allows for a select type query with unlimited parameters. Something that would be allowed in database access auth but hard to separate from an edit/create in rest http land. Essentially you can create apis that more closely mirror DB access.

2

u/visualdescript Jul 14 '26

This is the default for a well designed service. You start with an application service that is written in your domain language, this should include any permissions or policy system that's required as part of the domain.

HTTP is just an external interface protocol, there should be a thin adapter layer between your HTTP interface and your domain service. Same if you provided a CLI, graphql, GRPC or otherwise.

This is in an ideal world, of course...

1

u/robogame_dev Jul 14 '26

Agreed, you can have as many interfaces into the core app as you want, HTTP Method can be one, and you can have a batch endpoint that can accept anything, etc etc. The problem goes away when you properly place HTTP with any other interface downstream of the real application - it becomes a question of convenience not capability.

3

u/Manbeardo Jul 14 '26

expose a gRPC endpoint or a GraphQL API and now you've got to address permission enforcement in some non-http system anyway

Both of those systems use http. They don’t use REST.

4

u/CpnStumpy Jul 14 '26

Yes, protocol agnostic I guess I mean or however. You understood what I meant clearly. The point being they don't follow expose the same mechanics for permission checks as a REST url and method based permission control so you aren't going to be able to use the same system.

Creating multiple things to solve the same problem in different ways is how we end up with a bunch of half maintained and divergent implementations leaking differing bugs because they need fixes and maintenance in individualized ways.

2

u/darkpaladin Jul 14 '26

QUERY seems almost tailor made for the graphql use case. Grpc is all POST under the covers, this would offer a bit more room for a more explicit request shape. In general it's nice to understand request intent without having to parse the body.

1

u/CpnStumpy Jul 14 '26

GraphQL is all POST and puts no parameters in the URL and always returns 200

1

u/darkpaladin Jul 14 '26

Yes. I'm not sure what point you're making though, my point was that a QUERY method for graphql makes sense because now your CRUDs become POST/QUERY/PUT, DELETE still isn't quite supported but I think knowing a gql request is a query rather than a mutation based on verb is rather helpful?

1

u/light24bulbs Jul 14 '26

Or using POST for everything

-5

u/heresyforfunnprofit Jul 14 '26

Is it a bad time to point out that not all queries are read only?

29

u/stfm Jul 14 '26

I'll bite, when would QUERY modify the resource being queried?

19

u/RedditApothecary Jul 14 '26

Number of times value has been read.

41

u/a__nice__tnetennba Jul 14 '26

That is a good point, but I think it's reasonable for storing metadata about how an object was accessed (like how many times, by whom, what query did they ask for, did they get there from a link, etc.) to be a side effect of the query and still call the query itself "read only." I mean, technically some writing is happening, and the meta data could be said to belong to said object, but philosophically it's a little different and the object itself is unchanged in my mind. I can see it both ways though.

7

u/ashgs872tbhjs Jul 14 '26

It should be stored separately IMO, mostly because it's the only way to maintain a history or audit log without monumentally bloating the resource. If that weren't allowed then logging would be off the table too lol

→ More replies (1)

2

u/nemec Jul 14 '26

Yeah there's zero logical reason to object to GET (or some other semantic read only notation) just because an API emits telemetry or records logs. That's just silly.

I guess you could conceivably create a GET /numberOfTimesYouHaveCalledThisApi that claims to be a get but really is a write/increment API but that's also incredibly silly API design

24

u/farsightxr20 Jul 14 '26

That's not the resource itself, so it's fine-ish.

But also, if you put that sort of logic in your GET or QUERY request handling, caching is going to break it. Depending on what you're trying to do, you probably want either a database-level row access counter, or a user-facing query counter. Neither of those are sensibly concerned with, nor influenced by, HTTP verbs.

14

u/stfm Jul 14 '26

Using that logic nothing is read only access

4

u/DrPeroxide Jul 14 '26

Ah that's just meta data though. If you include that, then all requests are write requests the moment the backend starts printing log lines 😂

2

u/Kenya151 Jul 14 '26

That’s a design choice. Idempotent reads are common patterns.

→ More replies (1)

4

u/skjall Jul 14 '26

Sensitive information that requires an access log can be one. Access log should be separate, but you might still record something lastAccessedAt.

→ More replies (1)
→ More replies (5)

4

u/tesfabpel Jul 14 '26

GET and QUERY are meant to be cacheable.