Example #1
0
 def __init__(self, config = None, dbengine = None, **kwargs):
     self.config = config
     settings = dict(cookie_secret='12oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=', login_url='/admin/login', template_path=os.path.join(os.path.dirname(taurusxradius.__file__), 'views'), static_path=os.path.join(os.path.dirname(taurusxradius.__file__), 'static'), xsrf_cookies=True, config=self.config, debug=self.config.system.debug, xheaders=True)
     self.tp_lookup = TemplateLookup(directories=[settings['template_path']], default_filters=['decode.utf8', 'h'], input_encoding='utf-8', output_encoding='utf-8', encoding_errors='ignore', module_directory='/var/taurusxr/free_module_manage')
     self.license = storage.Storage(dict(sid=tools.get_sys_uuid(), type='taurusxee', create_at='2017-01-01', expire='3000-12-30'))
     os.environ['LICENSE_TYPE'] = 'taurusxee'
     self.db_engine = dbengine or get_engine(config)
     self.db = scoped_session(sessionmaker(bind=self.db_engine, autocommit=False, autoflush=False))
     redisconf = redis_conf(config)
     self.logtrace = log_trace.LogTrace(redisconf)
     self.session_manager = redis_session.SessionManager(redisconf, settings['cookie_secret'], 3600)
     self.mcache = kwargs.get('cache', CacheManager(redisconf, cache_name='RadiusManageCache-%s' % os.getpid()))
     batchsize = 32 if self.config.database.dbtype == 'sqlite' else 500
     self.db_backup = DBBackup(models.get_metadata(self.db_engine), excludes=['tr_online',
      'system_session',
      'system_cache',
      'tr_ticket',
      'tr_billing'], batchsize=batchsize)
     self.aes = kwargs.get('aes', utils.AESCipher(key=self.config.system.secret))
     self.init_superrpc()
     dispatch.register(self.mcache)
     dispatch.register(self.logtrace)
     if 'elasticsearch' in self.config:
         dispatch.register(eslogapi.EslogApi(self.config.elasticsearch))
     self.mpsapi = None
     self.wechat = None
     self.init_handlers()
     self.init_events()
     cyclone.web.Application.__init__(self, permit.all_handlers, **settings)
     return
Example #2
0
 def init(self):
     _dir = os.path.dirname(__file__)
     self.config = iconfig.find_config(os.path.join(_dir, 'test.json'))
     logger.Logger(self.config, 'taurusxee-test')
     self.dbengine = get_engine(self.config)
     self.db = scoped_session(
         sessionmaker(bind=self.dbengine, autocommit=False, autoflush=True))
     self.aes = utils.AESCipher(key=self.config.system.secret)
Example #3
0
    def post(self):
        new_secret = utils.gen_secret(32)
        new_aes = utils.AESCipher(key=new_secret)
        users = self.db.query(models.TrAccount)
        for user in users:
            oldpwd = self.aes.decrypt(user.password)
            user.password = new_aes.encrypt(oldpwd)

        self.application.aes = new_aes
        self.db.commit()
        self.settings.config['system']['secret'] = new_secret
        self.settings.config.save()
        self.render_json(code=0)
Example #4
0
 def __init__(self, config=None, dbengine=None, **kwargs):
     self.config = config
     os.environ['LICENSE_TYPE'] = 'taurusxee'
     settings = dict(
         cookie_secret='12oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=',
         login_url='/usrportal/login',
         template_path=os.path.join(os.path.dirname(taurusxradius.__file__),
                                    'views'),
         static_path=os.path.join(os.path.dirname(taurusxradius.__file__),
                                  'static'),
         xsrf_cookies=True,
         config=self.config,
         debug=self.config.system.debug,
         xheaders=True)
     self.tp_lookup = TemplateLookup(
         directories=[settings['template_path']],
         default_filters=['decode.utf8', 'h'],
         input_encoding='utf-8',
         output_encoding='utf-8',
         encoding_errors='ignore',
         module_directory='/var/taurusxr/module_usrportal')
     self.db_engine = dbengine or get_engine(config)
     self.db = scoped_session(
         sessionmaker(bind=self.db_engine,
                      autocommit=False,
                      autoflush=False))
     redisconf = redis_conf(config)
     self.logtrace = log_trace.LogTrace(redisconf)
     self.session_manager = redis_session.SessionManager(
         redisconf, settings['cookie_secret'], 3600)
     self.mcache = kwargs.get(
         'cache',
         CacheManager(redisconf, cache_name='UsrpdCache-%s' % os.getpid()))
     self.paycache = CacheManager(redisconf,
                                  cache_name='UsrpdPayCache-%s' %
                                  os.getpid(),
                                  db=9)
     self.aes = kwargs.get('aes',
                           utils.AESCipher(key=self.config.system.secret))
     logger.info('start register usrportal events')
     dispatch.register(self.mcache)
     dispatch.register(self.logtrace)
     if 'elasticsearch' in config:
         dispatch.register(eslogapi.EslogApi(config.elasticsearch))
     load_handlers(handler_path=os.path.join(
         os.path.abspath(os.path.dirname(__file__)), 'usrportal'),
                   pkg_prefix='taurusxradius.modules.usrportal',
                   excludes=['webserver', 'radius'])
     cyclone.web.Application.__init__(self, permit.all_handlers, **settings)
Example #5
0
 def __init__(self, config, dbengine, radcache = None):
     self.config = config
     self.load_plugins(load_types=['radius_auth_req', 'radius_accept'])
     self.dict = dictionary.Dictionary(os.path.join(os.path.dirname(taurusxradius.__file__), 'dictionarys/dictionary'))
     self.db_engine = dbengine or get_engine(config)
     self.aes = utils.AESCipher(key=self.config.system.secret)
     self.mcache = radcache
     self.reject_debug = int(self.get_param_value('radius_reject_debug', 0)) == 1
     self.pusher = ZmqPushConnection(ZmqFactory(), ZmqEndpoint('connect', config.mqproxy['auth_result']))
     self.stat_pusher = ZmqPushConnection(ZmqFactory(), ZmqEndpoint('connect', config.mqproxy['task_connect']))
     self.puller = ZmqPullConnection(ZmqFactory(), ZmqEndpoint('connect', config.mqproxy['auth_message']))
     self.puller.onPull = self.process
     logger.info('radius auth worker %s start' % os.getpid())
     logger.info('init auth worker pusher : %s ' % self.pusher)
     logger.info('init auth worker puller : %s ' % self.puller)
     logger.info('init auth stat pusher : %s ' % self.stat_pusher)
     self.license_ulimit = 50000
Example #6
0
 def __init__(self, config, dbengine, radcache = None):
     self.config = config
     self.load_plugins(load_types=['radius_auth_req', 'radius_accept'])
     self.dict = dictionary.Dictionary(os.path.join(os.path.dirname(taurusxradius.__file__), 'dictionarys/dictionary'))
     self.db_engine = dbengine or get_engine(config)
     self.aes = utils.AESCipher(key=self.config.system.secret)
     self.mcache = radcache
     self.stat_pusher = ZmqPushConnection(ZmqFactory())
     self.zmqrep = ZmqREPConnection(ZmqFactory())
     self.stat_pusher.tcpKeepalive = 1
     self.zmqrep.tcpKeepalive = 1
     self.stat_pusher.addEndpoints([ZmqEndpoint('connect', config.mqproxy.task_connect)])
     self.zmqrep.addEndpoints([ZmqEndpoint('connect', config.mqproxy.auth_connect)])
     self.zmqrep.gotMessage = self.process
     self.reject_debug = int(self.get_param_value('radius_reject_debug', 0)) == 1
     logger.info('radius auth worker %s start' % os.getpid())
     logger.info('init auth worker : %s ' % self.zmqrep)
     logger.info('init auth stat pusher : %s ' % self.stat_pusher)