The concept of a passport didn’t emerge out of the ether. If you were traveling on official business, for the state or the military or as a merchant, you’d be carrying papers that said as much. Much of it relied on trust and reputation, and assuming we’re talking about say medieval Europe possibly the signature or word of a Lord. As for enforcement, violence was common.