Revert "Remove opt out middleware"

This reverts commit 933825759569dd78cd0b62e84337789f9be703ff.