Some nations do have exceptions to the philosophy above and simply won't allow anyone but the crew on the flight deck in their airspace or on services to/from their nations.
Actually Keg, my understanding is that is not the case.
The two most restrictive conditions are imposed by the UK and the USA and the Qantas security program is tailored to meet both strictures.
The UK requires that jumpseat riders be employees and not go in/out of the flight deck inflight, provided no seats available in the cabin. This clause caused the most hand wringing in Qantas as their security procedures were amended to meet this requirement but other Australian operators were not required to do so under the Australian Transport Security Act 2004.
The US Transport Security Administration requires that notification be provided 24 hrs prior to entry into their airspace of all persons having access to the flight deck inflight. Qantas amended their access rules to the US to crew only as this was the list provided automatically to the TSA from ARMS. If Qantas wanted to make the effort, they could advise the TSA that the Second Officer's wife (for example) would have access to the flight deck and would thus meet the TSA notice requirements. You couldn't do this to the UK because the S/O's wife is not an employee.
There used to be a clause in the Qantas security program that the two exemptions to the above policy were the CEO and Chief Pilot who had access at any time inflight. This has disappeared for some reason but I am sure both the UK and US authorities had no problem with it. Probably QF just erring on the side of caution. Again.
The above is my understanding of how things came to be, and, as I have not paid any attention to these issues in years, because it has become a massive yawn, I am happy to be corrected.