The use of force always bears a heavy burden of proof, but I think it can sometimes be met. When? No one can give a general answer to that.
There are some approaches, for example, by the most important UN resolution condemning terrorism in all its forms and calling on all countries to stamp out the plague, passed in 1987 under Reaganite pressures to mobilize the world for its “war on terror.” The resolution was not reported here and remains unmentionable, for the usual reason. Apart from one abstention (Honduras) and two negative votes, it passed unanimously. The two negative votes, as usual, were the US and its Israeli client…The resolution endorsed the right of people to resist racist and colonialist regimes (meaning the US-Israeli ally apartheid South Africa) and foreign military occupation (meaning US-backed Israel). Therefore, the strongest international condemnation of terrorism has been effaced from the history of terrorism and the reaction to it — joining a lot more unacceptable facts.
The resolution did not spell out what kind of resistance is legitimate, but one can make some plausible inferences.