A Kantian account of ethics holds that morality rests in the nature of human freedom. A sound critique of this analysis arises if one believes that true freedom means that one may act in any way one sees fit, and thus that true morality cannot ever be based on freedom since morality requires a set of rules for how one ought to act. In this essay I will begin by furthering the claims of the objection before defending the Kantian account of morality by first justifying why human freedom is compatible with one’s actions being bound by a particular set of rules, and then arguing how morality is based in human freedom by connecting the formulation of the categorical imperative as a test of universal laws to the respect for and consideration of dignity and autonomy by the laws which the categorical imperative permits.
Prima facie, the notion of freedom seems at odds with the idea that a free individual is bound by any moral law to act, or to try to act, in any particular way. An absolutely free individual may give their assent to any laws they choose, or to none at all, and thus is not compelled to try to act a certain way. In contrast to this permissive conception of freedom, a Kantian account of liberty sees human freedom  as autonomy, or self governance. Autonomous beings are governed by the laws which they give themselves, laws which must adhere to the rationality of the categorical imperative: that one may will the maxim to be a universal law, and therein be in accordance with objective morality. Since absolute freedom seems to preclude the existence of universal moral laws to which one must be bound to act, and is indeed more permissive, and thus more free, than the Kantian notion of autonomy, it would seem impossible that any particular rules of conduct may be derived from freedom. Since morality requires these sorts of universal laws to exist, one may reasonably argue that morality cannot be based in freedom, contrary to the Kantian account.
The Kantian does however have a strong defense of the idea that autonomy is the correct understanding of human freedom, and that morality is thus not only compatible with freedom but predicated on it. Considering the original critique, that freedom is compatible with choosing or endorsing any old rule we want. The first main counterpoint lies in the notion of “choosing.” If one chooses to act in a certain way, then it must be that the decision to act is made freely by the individual of their own volition; any other reason for acting in this manner cannot be considered a “choice” because the person is being compelled to act, possibly against their will. If one’s choices are not made rationally, then they are not truly free choices, but manifestations of instinct, desire, or an external will. Such visceral foundations are antithetical to the faculty of a free being, and so the only choices which can be made freely are those which are made rationally. While absolute freedom may permit such choices to be made, it cannot permit such choices to be the product of a free will. Just as one who consents to be compelled to act in a certain way does not preform these actions of their own volition, so too are the decisions made without reason made illiberally. Thus it is not only possible that free individuals may be bound by rules, but is in fact necessary that they be bound by the laws resulting from rational considerations.
By way of comparison, one may think of a liberal democracy  as analogous to a free, and therefore autonomous, will. Although citizens of such a state are considered free, their actions are still governed by laws. However, since these laws derive from the governed themselves, the laws are self-given. In this way a self-governing—that is to say autonomous—society provides for the freedom of its citizens.
A critical eye may respond to this defense of autonomy as the correct notion of freedom by pointing out that even if they were to concede that freedom is compatible with there being restrictions on one’s actions, so long as they are rationally made and self-administered, this doesn’t mean that a universal system of moral laws can coexist with personal autonomy. After all, a moral system has laws which must necessarily apply to everyone, and it could be that the laws which one person gives themselves are incongruous with the laws another person gives themselves. Were this to be the case, we could never arrive at a system of morality since to do so would mean enforcing the will of others which strictly violates personal autonomy. 
This additional critique of morality’s basis in autonomy gives rise to a Kantian’s second counterpoint, which lies in the discussion of what exactly may qualify as a moral law. For a maxim to be a law of action, applicable to all rational beings, it must be universalizable. This is the statement of a categorical imperative, that one may act only on those maxims which can at the same time be willed to be universal laws, binding for all people. Since an autonomous person chooses to act in a rational manner, dutifully considering whether their actions and justifications are in fact permissible by checking to see if one can reasonably will that all are bound by them. As all rational beings adhere to the same criterion to determine the moral permissibility of a maxim, all rational beings will arrive at a set of personal laws which are mutually compatible and harmonious. Thus while one is only bound by the laws one puts on oneself, all rational beings are subject to a particular set of rules which govern their actions, all the while retaining their autonomy.
This argument, of course, rests on the idea that Kant’s categorical imperative—in its current formulation—is the unique way to qualify rational action, and that there cannot be a separate test one could devise to test the rational permissibility of a maxim which could produce a different result for a particular maxim. The agreement of this test with any other purely rational test which could be contrived results from the fact that both such tests must adhere to the same consistent rules of rationality. Since reason itself is self-consistent,  so too are rational tests, and so there is but a single categorical imperative for rational action which produces rules for how one may or may not act. But while humans may all be subject to such rules, one may yet still contend that this isn’t necessarily a theory of morality. Perhaps, instead, humanity is collectively self-bound by laws which permit rational but immoral maxims. Why should purely rational considerations lead us to produce rules which permit only moral actions with moral justifications?
This, again, is a reasonable argument to consider. If, however, we examine a rational will considering a maxim for action, such a person shall consider the permissibility under the question of whether such a maxim may be willed to be a universal law. Importantly, if one can rationally choose to act in a given manner, then such an action is done with mutual respect for the humanity—the autonomy and dignity—of others, for one cannot  rationally will that another should disregard these provisions when interacting with them. In this way, rational considerations provides a foundation for morality. Moral maxims are those which can be willed to be universal laws for all rational beings, and vice-versa. An autonomously free person, then, is self-constrained by laws which protect the humanity and dignity of all others, and so acts in a way which is not merely harmonious with others, but also in a way which is fundamentally moral.
While the intuitive notion of freedom as “being able to act without restriction” seems on the face of it to be incompatible with a universal system of moral laws by which one is bound, a Kantian account of morality holds that human autonomy is not only compatible with morality but serves as a foundation for it. By first arguing under this perspective that actions which are made irrationally are in fact made unfreely, I then demonstrated that a truly free individual may be, and indeed is, still governed by self-administered rational consideration. This rational consideration, by virtue of its base in reason, lends itself to all rational beings being governed by the same set of laws which are, in turn, mutually respectful of one another’s autonomy, dignity, and humanity. In this way, human freedom as autonomy becomes the base for morality.
— Jackson Petty
New Haven, CT
Or more generally, a rational being’s freedom.
One may object to this notion on the account that such societies perhaps do not or even cannot exist. Regardless of the existence of such states, the concept of political freedom is a useful analogue for that of free will. The empirical account of such societies, or lack thereof, does not affect the freedom of their citizens, were they to exist.
I suppose that another option is possible, in which people simply live immorally and nothing is done about it. This option still runs into the same flaw, which is that the fundamental rules of morality would be incompatible with human freedom in such a scenario.
This I take to be a given, although there is certainly a metaphysical argument one could make about the nature of reason and logic and whether or not they both are immutable and do not admit contradictions. This seemed like it was a bit outside the scope of what the prompt was asking for, though.
This is where the categoricalness of the categorical imperative becomes important. Even if one wishes that they be victimized by others, the categorical imperative rejects that this is a moral maxim since it cannot be said for all rational beings.