Move authentication handling methods to classes
The authentication methods should be moved to classes, which can be used to perform authorization.
A base class with stub methods for authentication and general methods to perform csrf checks etc. should be created. Classes for token authentication and for the different API key authentications should be created, as well as mix-in classes that allow authentication via multiple methods.
An start to this was performed in e5c78ce5