core: introducing lager metadata for better logging.
Added the session_id to the #context{} for better debugging/logging.
Misc fixes for authentication.
Issue #781