Refactoring authentication provider