refactor of the authentication to allow for oauth2 support