diff --git a/lemur/auth/service.py b/lemur/auth/service.py index 5fd20f42..6386f6d0 100644 --- a/lemur/auth/service.py +++ b/lemur/auth/service.py @@ -72,13 +72,13 @@ def create_token(user): :param user: :return: """ - expiration_delta = timedelta(days=int(current_app.config.get('TOKEN_EXPIRATION', 1))) + expiration_delta = timedelta(days=int(current_app.config.get('LEMUR_TOKEN_EXPIRATION', 1))) payload = { 'sub': user.id, 'iat': datetime.now(), 'exp': datetime.now() + expiration_delta } - token = jwt.encode(payload, current_app.config['TOKEN_SECRET']) + token = jwt.encode(payload, current_app.config['LEMUR_TOKEN_SECRET']) return token.decode('unicode_escape') @@ -102,7 +102,7 @@ def login_required(f): return dict(message='Token is invalid'), 403 try: - payload = jwt.decode(token, current_app.config['TOKEN_SECRET']) + payload = jwt.decode(token, current_app.config['LEMUR_TOKEN_SECRET']) except jwt.DecodeError: return dict(message='Token is invalid'), 403 except jwt.ExpiredSignatureError: diff --git a/lemur/certificates/service.py b/lemur/certificates/service.py index fb52a812..5cfb6484 100644 --- a/lemur/certificates/service.py +++ b/lemur/certificates/service.py @@ -301,14 +301,15 @@ def create_csr(csr_config): backend=default_backend() ) + # TODO When we figure out a better way to validate these options they should be parsed as unicode builder = x509.CertificateSigningRequestBuilder() builder = builder.subject_name(x509.Name([ - x509.NameAttribute(x509.OID_COMMON_NAME, csr_config['commonName']), - x509.NameAttribute(x509.OID_ORGANIZATION_NAME, csr_config['organization']), - x509.NameAttribute(x509.OID_ORGANIZATIONAL_UNIT_NAME, csr_config['organizationalUnit']), - x509.NameAttribute(x509.OID_COUNTRY_NAME, csr_config['country']), - x509.NameAttribute(x509.OID_STATE_OR_PROVINCE_NAME, csr_config['state']), - x509.NameAttribute(x509.OID_LOCALITY_NAME, csr_config['location']) + x509.NameAttribute(x509.OID_COMMON_NAME, unicode(csr_config['commonName'])), + x509.NameAttribute(x509.OID_ORGANIZATION_NAME, unicode(csr_config['organization'])), + x509.NameAttribute(x509.OID_ORGANIZATIONAL_UNIT_NAME, unicode(csr_config['organizationalUnit'])), + x509.NameAttribute(x509.OID_COUNTRY_NAME, unicode(csr_config['country'])), + x509.NameAttribute(x509.OID_STATE_OR_PROVINCE_NAME, unicode(csr_config['state'])), + x509.NameAttribute(x509.OID_LOCALITY_NAME, unicode(csr_config['location'])), ])) builder = builder.add_extension(