Major Spanish railway stations have security checks for passengers on high-speed trains. They won't X-ray your person - only your baggage. These checks only take a few minutes but factor this into the time you plan to arrive at the station.