They enter a code and if the cockpit doesn't reject it within a certain time frame the door opens.
See Helios flight 522.