The specific circumstances are key here but any time I ever found myself in a similar situation, where I wasn’t completely outgunned and overruled, a good confrontation and line drawing seemed to help things. If nothing else it lets people know that you’re only willing to put up with so much and you’re not a pushover.
If you flip it around, as I’m the boss now, the same thing applies. I’m human and prone to human misjudgments and miscalculations just like anybody else but sometimes it’s the employee being the fuckhead, not the boss.
If I feel like an employee, or anybody in my life inside or outside of the workplace is taking the piss, I’ll take a moment to think about how much I need them or respect them, size that up to whatever issue we’re having, and then plot my course of action from there. Sometimes that means I tell the person to fuck off and never contact me again, sometimes that comes down to a mild reprimand that’s also an apology on my part.
Circumstances are key and everyone has some degree of leverage, unless you’re in the military or prison (pretty much the same thing) or bound by a shitty contract of some sort. If that’s the case you’re fucked.