v7 UUIDs aren’t guaranteed to be sequential when generated within the same millisecond. The first part encodes the millisecond; the second part is random.
Wow, I had no idea that there are alternatives to CSRF tokens. That’s really neat. Just tried POSTing to a test handler with and without a matching Origin header and that seems to work well.
Does that make the mention of anti-forgery-token here redundant? https://github.com/jacobobryant/biff/tree/master/libs/authenticate#signing-out
Yeah it’s pretty nifty! re: biff.authenticate, by default that library still includes the “regular” csrf approach: https://github.com/jacobobryant/biff/blob/bb789b6bdd2008767f6649865c7e8174e1832d5e/libs/authenticate/src/com/biffweb/authenticate/impl/system.clj#L67. I put that in there to handle the case where the library is a la carte / outside of a biff project.
But if you set :biff.auth/skip-csrf-protection, then yeah no need for the anti forgery token in the signout POST.
As for why I didn’t just use biff.ring/wrap-csrf-protection in biff.authenticate… I don’t actually remember. Could be worth evaluating.
This might be out of scope, but could be worth considering (with-meta session {:recreate true}) here https://github.com/jacobobryant/biff/blob/bb789b6bdd2008767f6649865c7e8174e1832d5e/libs/authenticate/src/com/biffweb/authenticate/impl/backend.clj#L142, to to force a new session key on login and avoid session fixation attacks. Not applicable with the default cookie session backend because you get a new session key when you change the content, but an in-memory backend or other server-backed sessions they could potentially be vulnerable.
👀 just made an issue here: https://github.com/jacobobryant/biff/issues/259
I’m not familiar with that :recreate true option. What’s the vulnerability it addresses? i.e. what does an attack look like?