Instructions
Equip a pickaxe, and remove a two-block-high, one-block-wide space for a door in your base or house.
Craft an iron door, by placing six iron ingots in the crafting grid. Wood may be used, but it is not as secure.
Place the door in the space created in Step 1. Craft a lever, by placing a cobblestone and a wooden stick in the crafting grid, and place it on the wall -- right next to the iron door. You should be able to flip the lever, to open and close the door.
Place a trail of redstone dust leading away from the door on the inside of your structure. Attach a second lever to the end of the redstone dust trial.
Flip the lever on the inside of your house, to deactivate the redstone dust trail. This will lock the door, making the lever on the outside unusable. Turn the lever on, reactivating the redstone dust, to unlock the door and make the switch usable again.