Move the auth code entierly into its own module in preperation for seperation.