Add anti-CSRF support

This commit goes with the Web Server anti-CSRF patch.

It primarily tidies up some code and modifies a few interfaces.  This is an essential part of
the much larger commit on the PZH Web Server.

Jira issue: WP-781