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

@ -14,9 +14,10 @@ from flask import g, Blueprint, current_app
from flask.ext.restful import reqparse, Resource, Api from flask.ext.restful import reqparse, Resource, Api
from flask.ext.principal import Identity, identity_changed from flask.ext.principal import Identity, identity_changed
from lemur.common.utils import get_psuedo_random_string
from lemur.users import service as user_service from lemur.users import service as user_service
from lemur.roles import service as role_service from lemur.roles import service as role_service
from lemur.certificates import service as cert_service
from lemur.auth.service import create_token, fetch_token_header, get_rsa_public_key from lemur.auth.service import create_token, fetch_token_header, get_rsa_public_key
@ -202,7 +203,7 @@ class Ping(Resource):
user = user_service.create( user = user_service.create(
profile['email'], profile['email'],
cert_service.create_challenge(), get_psuedo_random_string(),
profile['email'], profile['email'],
True, True,
profile.get('thumbnailPhotoUrl'), profile.get('thumbnailPhotoUrl'),

View File

@ -105,7 +105,6 @@ def mint(issuer_options):
csr, private_key = create_csr(issuer_options) csr, private_key = create_csr(issuer_options)
issuer_options['challenge'] = create_challenge() # TODO deprecate
issuer_options['creator'] = g.user.email issuer_options['creator'] = g.user.email
cert_body, cert_chain = issuer.create_certificate(csr, issuer_options) cert_body, cert_chain = issuer.create_certificate(csr, issuer_options)
@ -354,18 +353,6 @@ def create_csr(csr_config):
return csr, pem return csr, pem
# TODO deprecate
def create_challenge():
"""
Create a random and strongish csr 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
def stats(**kwargs): def stats(**kwargs):
""" """
Helper that defines some useful statistics about certifications. Helper that defines some useful statistics about certifications.

View File

@ -6,6 +6,8 @@
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com> .. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
""" """
import string
import random
from functools import wraps from functools import wraps
from flask import current_app from flask import current_app
@ -15,6 +17,17 @@ from flask.ext.restful.reqparse import RequestParser
from flask.ext.sqlalchemy import Pagination 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): class marshal_items(object):
def __init__(self, fields, envelope=None): def __init__(self, fields, envelope=None):
self.fields = fields self.fields = fields