When I fitted a cat flap, it had a settable lock which could be set to lock both ways, unlock both ways, or provide one-way access in either direction. Just a basic mechanical rotary catch.
Access was controlled with a little magnet on the collar. This works, but it will fail (obviously) if the cat loses the collar, or if other cats use the same system (as one magnet is the same as another).
You can also get ones which uses coded transponders, which is more discerning, but if I was fitting one again I’d get one that picks up the cat’s ID chip. (Animals can be chipped so that they can play imported games be identified if there’s an accident or they get lost.)