Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UserManager race conditions #52

Open
johniez opened this issue Apr 29, 2016 · 5 comments
Open

UserManager race conditions #52

johniez opened this issue Apr 29, 2016 · 5 comments
Labels

Comments

@johniez
Copy link
Contributor

johniez commented Apr 29, 2016

UserManager update() method reads and writes users.json file, but if two processes (for example two people will login at ~ same time) performs update() simultaneously, the later one can overwrite the data with some old version. Same applies for delete_user() method, but it is probably unused now.

And a note for auth: writing 'authenticated' flag into users.json is not necessary, as the user successfully loaded using loginmanager.user_loader has to be authenticated (or he was, just before he was written to the session after successfull login).

@alexanderjulo
Copy link
Owner

Very well possible, yeah. Unfortunately I am not really maintaining this project very much at the moment, so if you'd propose a fix (via PR) I'd happily merge it but I do not currently have the time to write one myself, sorry!

@johniez
Copy link
Contributor Author

johniez commented May 3, 2016

I can send a pull request, if adding python-fasteners dependency is not a problem :-)
It implements InterProcessLock for both windows and posix systems...

@alexanderjulo
Copy link
Owner

Whether it should be that library or another one is probably discussable but from what my quick research turned up this seems to be a difficult topic, so using an external library for locking stuff should be alright. We should probably implement it for other places aswell, not only the auth file.

@johniez
Copy link
Contributor Author

johniez commented May 5, 2016

In fact, Page.save() is not ready for concurrent usage at all. Current implementation is very simple, but does not cover situations where two or more people starts editing same page at some point, saving it far later (the last one will overwrite all others changes). So it needs locking, but it will make more sense with some "conflict guard" (at least file mtime or hash at the start of page editing).

@alexanderjulo
Copy link
Owner

Agreed, yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants