"AS Augustine says (De Lib. Arb. i, 5) "that which is not just seems to be no law at all": wherefore the force of a law depends on the extent of its justice. Now in human affairs a thing is said to be just, from being right, according to the rule of reason. But the first rule of reason is the law of nature, as is clear from what has been stated above (Q. 91, Art. 2, ad 2). Consequently every human law has just so much of the nature of law, as it is derived from the law of nature. But if in any point it deflects from the law of nature, it is no longer a law but a perversion of law."
--Summa Theologica, I-II, Q. 94, Art. 2.
"LAWS are said to be just, both from the end, when, to wit, they are ordained to the common good—and from their author, that is to say, when the law that is made does not exceed the power of the lawgiver—and from their form, when, to wit, burdens are laid on the subjects, according to an equality of proportion and with a view to the common good...
"On the other hand laws may be unjust in two ways: first, by being contrary to human good, through being opposed to the things mentioned above—either in respect of the end, as when an authority imposes on his subjects burdensome laws, conducive, not to the common good, but rather to his own cupidity or vainglory—or in respect of the author, as when a man makes a law that goes beyond the power committed to him—or in respect of the form, as when burdens are imposed unequally on the community, although with a view to the common good. The like are acts of violence rather than laws; because, as Augustine says (De Lib. Arb. i, 5), "a law that is not just, seems to be no law at all." Wherefore such laws do not bind in conscience, except perhaps in order to avoid scandal or disturbance...
"Secondly, laws may be unjust through being opposed to the Divine good: such are the laws of tyrants inducing to idolatry, or to anything else contrary to the Divine law: and laws of this kind must nowise be observed, because, as stated in Acts 5:29, "we ought to obey God rather than man.""
--Summa Theologica, I-II, Q. 96, Art. 4.
~St. Thomas Aquinas