CSRFMiddleware
deletes all cookies (including login session) if CSRF checks fail. However that doesn't stop a forged login since there isn't a session cookie yet anyway. The login continues and you are logged in.
Also we have no tests for CSRF functionality.
Branch db/7893
/auth/
as your first page<form action="http://localhost/auth/do_login" method="POST"> <input type="hidden" name="username" value="test-user" /> <input type="hidden" name="password" value="foo" /> </form>
)/auth/
still work like forgot password, changing settings, etc.Overall looks and works good!
One concern of mine is that
/auth/oauth
urls now require csrf token. I'm not sure if clients that use oauth will work properly after this change. It seems to me that now clients would have to explicitly send some request to generate csrf token and then send it with all other params. Though, I'm not very familiar with how OAuth work, so can misunderstand something.Also, you have a couple of print statements in tests, which probably should be removed.
/auth/oauth
is just for the HTML interface that people use to manually manage their oauth apps and tokens. Using oauth tokens in an automated fashion goes through/rest/oauth
Right, I meant
/rest/oauth
there, but typed/auth/oauth
. I saw some changes for tests involving/rest/oauth
, which have introduced_session_id
.I see now that one of them is commented out (
test_request_token_valid
), so maybe these test changes are not required there after all? Since new logic affects only paths that start from/auth/
, as far as I can tell from code. If that's the case these tests should also be cleaned up to avoid confusion.I agree. I've removed all the _session_id changes to the /rest/oauth tests. They were unnecessary.
Looks good, merged.