News for hackers. Stuff that matters.
Re:Limitations of the GET method in HTTP by muaddirac on Monday March 02, 2015 @03:47PM (#9134213)
> As a rule, HTTP GET requests should not modify server state. This rule is useful because it lets intermediaries infer something about the request just by looking at the HTTP method.

As long as we're picking nits, it doesn't really matter if a GET request modifies server state so long as the state after N requests is the same as the state after 1 request (idempotence).

Re:Limitations of the GET method in HTTP by epanastasi on Monday March 02, 2015 @04:08PM (#9134334)
Actually there are two guarantees for GET:

1) It is a "safe" method.

2) It is an idempotent method.

A safe method (GET/HEAD) should not modify server state.

"In particular, the convention has been established that the GET and HEAD methods SHOULD NOT have the significance of taking an action other than retrieval. "

Whereas PUT & DELETE are also idempotent but not "safe".

http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

Re:Limitations of the GET method in HTTP by muaddirac on Monday March 02, 2015 @04:53PM (#9134599)
Also from that RFC:

> Naturally, it is not possible to ensure that the server does not generate side-effects as a result of performing a GET request; in fact, some dynamic resources consider that a feature. The important distinction here is that the user did not request the side-effects, so therefore cannot be held accountable for them.

I guess my point is that idempotence is the aspect that matters to clients - you can have side-effects if you really want, so long as the request can be safely repeated.

Re:Limitations of the GET method in HTTP by meejah on Monday March 02, 2015 @06:01PM (#9134971)
...and in fact, there's a popular use-case called "using memcached" that does have side-effects. That is, doing a GET on something absolutely changes the server "state" (in the sense that memcached might have a key added to it) but that should be invisible to the user.

Of course, it's not actually-invisible: their next request might be a little bit faster.

Re:Limitations of the GET method in HTTP by dragonwriter on Monday March 02, 2015 @06:30PM (#9135119)
Its probably better to think of GET as not affecting the state of the resources within the API rather than not affecting the state of the server.
Re:Limitations of the GET method in HTTP by SilasX on Monday March 02, 2015 @05:49PM (#9134894)
Safe implies idempotent.

"Same effect from 0 or more actions" implies "Same effect from 1 or more actions".

Re:Limitations of the GET method in HTTP by charonn0 on Monday March 02, 2015 @06:20PM (#9135065)
All safe methods are idempotent, but not all idempotent methods are safe (e.g. PUT or DELETE.)
Re:Limitations of the GET method in HTTP by marcosdumay on Monday March 02, 2015 @06:23PM (#9135082)
Safe means you can call it in any way you want. Like from a bot, or an accelerator plugin.
Re:Limitations of the GET method in HTTP by ccleve on Monday March 02, 2015 @04:29PM (#9134445)
One reason to not use GET to modify server state is that bots and crawlers may hit your api. They almost universally use GET and not POST.
Re:Limitations of the GET method in HTTP by sitkack on Monday March 02, 2015 @05:05PM (#9134657)
if your api is modifying server state w/o HMAC, api is probably broken.
Re:Limitations of the GET method in HTTP by dspillett on Tuesday March 03, 2015 @05:07AM (#9136965)
HMAC won't save you if the application is public (and therefore available to scrapers. If a search engine or other bot can get a link to the page from another page in the app just as any interactive user would, it can also get a link with a correct HMAC token just as any interactive user would.
Re:Limitations of the GET method in HTTP by sitkack on Tuesday March 03, 2015 @09:33AM (#9137780)
That isn't how HMAC works. http://en.wikipedia.org/wiki/Hash-based_message_authenticati...

The private key of the API user is hashed with the full URL of the service. The user id is sent in the header of the request. The server looks up the user id and gets their private key, it then uses that key to hash the URL, comparing it to the one passed.

There is no way for a scraper or bot to get the HMAC token.

Re:Limitations of the GET method in HTTP by dspillett on Wednesday March 04, 2015 @05:05AM (#9143469)
For an authenticated user, yes, as you have somewhere to hang a known-by-the-server-but-unknown-elsewhere key from.

For a public interface you don't necessarily have that. Though once you are dealing with a service that can be modified by unauthenticated users you have larger problems from malicious interactive users than from accidents by scrapers, so I'm probably arguing an irrelevant point...