Refactored MS authentication logic out of Startup.Auth.