Module Make_Auth.Session_manager

SessionManager is a module that sets local variables from session for every request via Auth_sign.SESSIONMANAGER.auth_setup middleware

type entity = M.t

type entity is a type of authenticatable entity equal to MODEL.t

val auth_setup : Dream.middleware

auth_setup is a middleware which controlls session, setups field variables and helper functions for downstream handlers

auth_setup tries to extract auth string from session and determine the status of authentication. If there is no auth, then there were no authentication. If auth exisits, than set_helpers checks it and manages authentication status. If something is wrong with a session, Error Error.t is returned, and in this case session is invalidated, error is logged and 401 is sent. If session is ok, Ok request is recived, and that requested is passed on.