Only flight attendants can unlock the door, with a key or an access code, depending on the design of each plane. This measure aims at making sure flight attendants can feel secure and enable them to take a good-quality rest so that they can stay charming and keep smiling when serving passengers.
Of course, they cannot hide themselves in this secret room all the time. They can only stay in it when they have finished serving passengers. When the airplane is landing or departing, for their own safety, they are not allowed to access this compartment either.