Campaigners win apology for persecution of gay codebreaker