BZ-1141816 Centralizing user and session retrieval so that REST requests are also handled

(cherry picked from commit 2c17083a151a4a34bbf92a8c4ddc1ae2f2a54622)