The general thinking is that a law is unjust if it doesn't square with natural law. This is certainly the view that was put forth in Martin Luther King's Letter from Birmingham Jail.
So, a law that was passed that treated people differently wouldn't square with the natural law that all humans are equal. And thus, one would have the obligation to disobey that law.