Traditionally graphite powder has been in use for years by locksmiths, I can remember coming home filthy most days from my apprenticeship years.. these days I am using Inox spray which is now available at most hardwares. It is great for lock barrels as well as the internal mechanism of the lock body. You can just spray it in every crevace and it is clear liquid so you don't get messy.
WD40 is ok as a temprary measure, but when it dries out it gets sticky. With Inox it does not get sticky and seems to last longer.