refactor auth as a service.