Now the abuse of authority can be of two kinds. First, when what is commanded by the ruler is contrary to the purpose for which the ruler was appointed: for example, if some sinful act is commanded contrary to the virtue which the ruler is ordained to foster and preserve. In this case, not only is one not bound to obey the ruler, but one is bound not to obey him, as in the case of the holy martyrs who suffered death rather than obey the ungodly commands of tyrants.

Second, when what is demanded goes beyond what the order of authority can require: if, for example, a master were to exact a payment which a servant is not bound to give, or something of the kind. In this case the subject is not bound to obey; nor, however, is he bound not to obey.

Thomas Aquinas (1225-1274) Italian friar, philosopher, theologian
Commentary on the Sentences of Peter Lombard [Scriptum super libros Sententiarium], Book 2, dist. 44, quest. 2, art. 2 (1252-56) [tr. Dyson (2002)]
    (Source)

Alt. trans. [Dawson]:
With regard to the abuse of authority, this also may come about in two ways. First, when what is ordered by an authority is opposed to the object for which that authority was constituted (if, for example, some sinful action is commanded or one which is contrary to virtue, when it is precisely for the protection and fostering of virtue that authority is instituted). In such a case, not only is there no obligation to obey the authority, but one is obliged to disobey it, as did the holy martyrs who suffered death rather than obey the impious commands of tyrants.

Secondly, when those who bear such authority command things which exceed the competence of such authority; as, for example, when a master demands payment from a servant which the latter is not bound to make, and other similar cases. In this instance the subject is free to obey or disobey.