Auth system refactoring