Those lines you mention in terms of denying housing are legally defined, fortunately. Being black or gay is legally defined as being a member of a protected class. The logic is of course that you don't get to choose whether you are black or gay (or several other things) so therefore you should not be penalized and people should not be allowed to make judgements about you based on those qualities. Klansmen are not a protected class because you're completely able to choose whether or not you want to be a member of the Klu Klux Klan. On the other hand, if a business was refusing service to white people on the basis of their race then the same equal protection bits of the law can be brought into play.