Refactoring out challenge

This commit is contained in:
kevgliss
2015-07-23 08:52:30 -07:00
parent 49c7421591
commit a4ed83cb62
3 changed files with 16 additions and 15 deletions

View File

@ -6,6 +6,8 @@
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
"""
import string
import random
from functools import wraps
from flask import current_app
@ -15,6 +17,17 @@ from flask.ext.restful.reqparse import RequestParser
from flask.ext.sqlalchemy import Pagination
def get_psuedo_random_string():
"""
Create a random and strongish challenge.
"""
challenge = ''.join(random.choice(string.ascii_uppercase) for x in range(6)) # noqa
challenge += ''.join(random.choice("~!@#$%^&*()_+") for x in range(6)) # noqa
challenge += ''.join(random.choice(string.ascii_lowercase) for x in range(6))
challenge += ''.join(random.choice(string.digits) for x in range(6)) # noqa
return challenge
class marshal_items(object):
def __init__(self, fields, envelope=None):
self.fields = fields