Split out http authentication handling into a separate file