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

(cherry picked from commit fedf770fc0c2ce9a5b9b0699cdafdba806d9faed)