Functions for getting and setting tokens in request and session can now be passed in as parameters to middleware