示例#1
0
文件: auth.py 项目: norann/GateOne
 def get_current_user(self):
     """Tornado standard method--implemented our way."""
     expiration = self.settings.get("auth_timeout", "14d")
     # Need the expiration in days (which is a bit silly but whatever):
     expiration = float(total_seconds(convert_to_timedelta(expiration))) / float(86400)
     user_json = self.get_secure_cookie("gateone_user", max_age_days=expiration)
     if not user_json:
         return None
     user = tornado.escape.json_decode(user_json)
     # Add the IP attribute
     user["ip_address"] = self.request.remote_ip
     return user
示例#2
0
 def get_current_user(self):
     """Tornado standard method--implemented our way."""
     expiration = self.settings.get('auth_timeout', "14d")
     # Need the expiration in days (which is a bit silly but whatever):
     expiration = (float(total_seconds(convert_to_timedelta(expiration))) /
                   float(86400))
     user_json = self.get_secure_cookie("gateone_user",
                                        max_age_days=expiration)
     if not user_json: return None
     user = tornado.escape.json_decode(user_json)
     # Add the IP attribute
     user['ip_address'] = self.request.remote_ip
     return user
示例#3
0
 def __init__(self, **kwargs):
     self.io_loop = IOLoop.current()
     self.executor = None
     self.shutdown_timeout = None
     self.timeout = kwargs.pop('timeout', None)
     if not self.timeout:
         self.timeout = timedelta(seconds=30)
     if not isinstance(self.timeout, timedelta):
         self.timeout = convert_to_timedelta(self.timeout)
     self.interval = kwargs.pop('interval', None)
     if not self.interval:
         self.interval = "30s"
     global MEMO # Use a global so that instances can share the cache
     if not MEMO:
         MEMO = AutoExpireDict(timeout=self.timeout, interval=self.interval)
示例#4
0
 def __init__(self, **kwargs):
     self.running = True
     self.shutdown_timeout = None
     self.timeout = kwargs.pop('timeout', None)
     if not self.timeout:
         self.timeout = timedelta(minutes=2)
     if not isinstance(self.timeout, timedelta):
         self.timeout = convert_to_timedelta(self.timeout)
     self.interval = kwargs.pop('interval', None)
     if not self.interval:
         self.interval = "30s"
     global MEMO # Use a global so that instances can share the cache
     if not MEMO:
         MEMO = AutoExpireDict(timeout=self.timeout, interval=self.interval)
     self.restart_shutdown_timeout()