Exemple #1
0
def generate_session_id():
    """
    Default firenado session id generator

    Returns:
        A random string containing digits, upper and lower characters
    """
    return random_string(64)
Exemple #2
0
    def get(self):
        #x_real_ip = self.request.headers.get("X-Real-IP")
        #remote_ip = self.request.remote_ip if not x_real_ip else x_real_ip
        if self.signin_service.is_ip_locked(self.request.remote_ip, 6):
            print "The ip is blocked!!!"

        self.signin_service.increment_ip(self.request.remote_ip)
        image = ImageCaptcha(fonts=[
            '/usr/share/fonts/dejavu/DejaVuSans.ttf',
            '/usr/share/calibre/fonts/liberation/LiberationSerif-Regular.ttf'
        ])
        string = random_string(5)
        anti_cache = random_string(22)
        self.session.set('captcha_string', string)
        data = image.generate(string)
        if os.path.exists('%s/static/captcha/%s%s.png' %
                          (firenado.conf.APP_CONFIG_ROOT_PATH, self.session.id,
                           self.session.get('anti_cache'))):
            os.remove('%s/static/captcha/%s%s.png' %
                      (firenado.conf.APP_CONFIG_ROOT_PATH, self.session.id,
                       self.session.get('anti_cache')))
        self.session.set('anti_cache', anti_cache)

        image.write(string,
                    'static/captcha/%s%s.png' % (self.session.id, anti_cache))
        f = Image.open(
            '%s/static/captcha/%s%s.png' %
            (firenado.conf.APP_CONFIG_ROOT_PATH, self.session.id, anti_cache))
        o = io.BytesIO()
        f.save(o, format="PNG")
        s = o.getvalue()

        #data = collections.defaultdict(lambda: collections.defaultdict(dict))
        #data['photo']=s

        self.render("jetpack:singin/email.html",
                    session_id=self.session.id,
                    anti_cache=anti_cache)
Exemple #3
0
 def run(self, namespace):
     from firenado.util import random_string
     print(random_string(64))
Exemple #4
0
 def __generate_session_id():
     # TODO we should make this generation more secure
     # TODO I think this is a good place to put a customized session
     # generator based on the configuration
     return random_string(64)
Exemple #5
0
 def __generate_session_id():
     # TODO we should make this generation more secure
     # TODO I think this is a good place to put a customized session
     # generator based on the configuration
     return random_string(64)