gevorg/http-auth — Issue #10: Digest auth: nonces aren't stateless
Author: mogsie
Created: 2012-01-28 00:51:09+00:00
State: open

I believe the way nonces are cached within the server causes the client and server to have shared state, which is unfortunate. I haven't tested myself, but I think it wouldn't work to have two instances of a digest server loadbalanced, since the 401 response from server A would include nonce X, and then when the client sends the correct request with username and hashed password, the request might reach server B (which would not recognise A's nonce) and reject it with 401 again...

As I said, I haven't tested it, but the same thing happens if you restart the server, everyone needs to log in again...

I might have a stab at introducing cryptographically timestamped and signed nonce, which would make the conversation stateless.

1. the options should have a secret, shared between all the servers which will be used to generate and verify nonces
2. a generated nonce would contain
* a timestamp
* a random number (?)
* a signature (hmac maybe)
3. when the server receives a nonce
* extracts the signature, verifies that the nonce is from the server, if it isn't just assume the nonce is bogus.
* extracts the timestamp, verifies that the nonce isn't too old

And then continues as normal. I'm no security expert, so I asked on StackExchange:
http://security.stackexchange.com/questions/11135/is-it-possible-to-have-stateless-server-nonces-in-http-digest