There are any number of systems that prevent unauthorized access to the TARDIS - force fields, defense shields and the like. But most of them, more correctly, are designed prevent access in ways other than through the door.
The crash of the Starship Titanic into the side of the TARDIS was caused by (as we found out somewhat after the fact) a number of the capsule's defense mechanism's turned off to fix the events of Time Crash. Similarly, a number of the systems were down to allow Clara to try to fly the ship in Journey to the Center of the TARDIS.
As for the door, all bets are rather off. If the door is locked, the key is (usually) required. They try to find a matching key to open the capsule in The Deadly Assassin when The Doctor returns to Gallifrey. In later seasons, The Doctor learns to open the doors "with a click of his fingers".
The ship does appear to have some ability to prevent access by people. The TARDIS didn't allow Clara to open the door a couple times early in her run on the show, but eventually she too was clicking the doors open and closed.
But past performance suggests that if the doors are open, any damn fool can blunder in.
As for protecting the people in the ship once hostiles are on board, things get a bit sweaty. For some time, it was believed that "a state of temporal grace" existed within the ship, so no weapons could be fired, and no harm could to anyone - "Which means you can't hurt us, and we can't hurt you" (The Hand of Fear). Later seasons had various energy weapons discharged in the control room with casual abandon, calling that idea into question. It wasn't until Let's Kill Hitler that The Doctor admitted it was "a clever lie", after Mels successfully fired her revolver, hitting the Time Rotor and causing no end of chaos.