Ejemplo n.º 1
0
  def active_session(self):
    if datetime.datetime.now() - self._active_session_ts > datetime.timedelta(minutes=5):
       logging.warning("Webharness.active_session() Reset")
       self._active_session = None

    logging.warning("Webharness.active_session() => %s, Age: %s" % 
        (self._active_session, datetime.datetime.now() - self._active_session_ts))
    return self._active_session
Ejemplo n.º 2
0
    def active_session(self):
        if datetime.datetime.now(
        ) - self._active_session_ts > datetime.timedelta(minutes=5):
            logging.warning("Webharness.active_session() Reset")
            self._active_session = None

        logging.warning("Webharness.active_session() => %s, Age: %s" %
                        (self._active_session,
                         datetime.datetime.now() - self._active_session_ts))
        return self._active_session
Ejemplo n.º 3
0
    def process_request(self, request):
        logging.warning("DjRsAuthMiddleware::process_request() url: %s" % request.get_full_path())
        logging.warning("DjRsAuthMiddleware::process_request() path: %s" % request.path)

        request.session['djrs'] = 'offline'
        if request.path == reverse('djrs_busy'):
            logging.warning("DjRsAuthMiddleware::process_request() Going to Busy Anyway")
            return None

        harness = getWebHarness()
        request.session.modified = True
        session_key = request.session.session_key
        active_session = harness.active_session()

        logging.warning("DjRsAuthMiddleware::process_request() active_session: %s" % active_session)
        logging.warning("DjRsAuthMiddleware::process_request() user_session: %s" % session_key)

        if active_session:
            if active_session == session_key:
                logging.warning("DjRsAuthMiddleware::process_request() Session Active and OK")
            else:
                logging.warning("DjRsAuthMiddleware::process_request() Session Invalid => Busy View")
                return HttpResponseRedirect(reverse('djrs_busy'))

        # if webharness is connected, get session id.
        if harness.is_connected() is False or not active_session:
            logging.warning("DjRsAuthMiddleware::process_request() Not Connected or Active")

            # if they are going to login -> let them through.
            if request.path == reverse('djrs_login'):
                logging.warning("DjRsAuthMiddleware::process_request() Going to Login Anyway")
                return None
               
            logging.warning("DjRsAuthMiddleware::process_request() Redirect to login")
            return HttpResponseRedirect(reverse('djrs_login'))

        logging.warning("DjRsAuthMiddleware::process_request() Is Connected")
        harness.keep_session_current()
        request.session['djrs'] = 'online'
        return None
Ejemplo n.º 4
0
 def keep_session_current(self):
     logging.warning("Webharness.keep_session_current()")
     self._active_session_ts = datetime.datetime.now()
Ejemplo n.º 5
0
 def set_session(self, session_key):
     logging.warning("Webharness.set_session(%s)" % session_key)
     self._active_session = session_key
     self.keep_session_current()
Ejemplo n.º 6
0
 def keep_session_current(self):
   logging.warning("Webharness.keep_session_current()")
   self._active_session_ts = datetime.datetime.now()
Ejemplo n.º 7
0
 def set_session(self, session_key):
   logging.warning("Webharness.set_session(%s)" % session_key)
   self._active_session = session_key
   self.keep_session_current()