The British during WWII had probably the most successful counter-espionage program in history, because they understood the personal motivations of the people who were interested in spying on them and used those motivations to their advantage. There are many books on the subject, my favorite of which is [0].
[0] https://www.amazon.com/Double-Cross-Story-D-Day-Spies/dp/030...