Restore spam prevention

closes #3128
- added spam prevention middleware
- restored tests