Basic hack auth backport

Manual backport of #3487 
Did it as a PR in case it was better to wait merging until after 5.0.10
Works For Me though :)

@DeepDiver1975 @karlitschek @icewind1991