Make debug an authenticated route

Require authentication on debug page and some minor cleanup.

Will rebase if/when #2915 lands.