Do you want to know what gives the authority to arrest people (non-military) for violating a base commanders ban on weapons or the ability of the federal prosecutor to prosecute?
I mean heck it is written right into posse comitatus. There is an exception for "carrying out of government operations" and the "protection of property and functions" "by force if necessary".
If the commander deems it a threat to his operations or installation to bring a gun on post then there is sufficiency right there. Hardly a violation of rights to civilians as no one is compelled to go to a military base.
The law that makes his orders binding is the Internal Security Act of 1950. The Internal Security Act of 1950 makes it a criminal misdemeanor to
violate any “regulation or order” issued by any “military commander designated by the Secretary of Defense” for the “protection or security of
property and places subject to his jurisdiction. This was confirmed in Greer v. Spock