Refactoring authentication services