Restored spam prevention

closes #3128
- added spam prevention middleware
- restored tests
Merge pull request #3282 from sebgie/issue#3128

Restore spam prevention