WIP, modular authentication

* Basic refactoring
* Not tested, probably not working yet