Aligning config variables

This commit is contained in:
kevgliss 2015-07-07 17:23:46 -07:00
parent 8239aa55e1
commit f660450043
2 changed files with 10 additions and 9 deletions

View File

@ -72,13 +72,13 @@ def create_token(user):
:param user: :param user:
:return: :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 = { payload = {
'sub': user.id, 'sub': user.id,
'iat': datetime.now(), 'iat': datetime.now(),
'exp': datetime.now() + expiration_delta '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') return token.decode('unicode_escape')
@ -102,7 +102,7 @@ def login_required(f):
return dict(message='Token is invalid'), 403 return dict(message='Token is invalid'), 403
try: try:
payload = jwt.decode(token, current_app.config['TOKEN_SECRET']) payload = jwt.decode(token, current_app.config['LEMUR_TOKEN_SECRET'])
except jwt.DecodeError: except jwt.DecodeError:
return dict(message='Token is invalid'), 403 return dict(message='Token is invalid'), 403
except jwt.ExpiredSignatureError: except jwt.ExpiredSignatureError:

View File

@ -301,14 +301,15 @@ def create_csr(csr_config):
backend=default_backend() 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 = x509.CertificateSigningRequestBuilder()
builder = builder.subject_name(x509.Name([ builder = builder.subject_name(x509.Name([
x509.NameAttribute(x509.OID_COMMON_NAME, csr_config['commonName']), x509.NameAttribute(x509.OID_COMMON_NAME, unicode(csr_config['commonName'])),
x509.NameAttribute(x509.OID_ORGANIZATION_NAME, csr_config['organization']), x509.NameAttribute(x509.OID_ORGANIZATION_NAME, unicode(csr_config['organization'])),
x509.NameAttribute(x509.OID_ORGANIZATIONAL_UNIT_NAME, csr_config['organizationalUnit']), x509.NameAttribute(x509.OID_ORGANIZATIONAL_UNIT_NAME, unicode(csr_config['organizationalUnit'])),
x509.NameAttribute(x509.OID_COUNTRY_NAME, csr_config['country']), x509.NameAttribute(x509.OID_COUNTRY_NAME, unicode(csr_config['country'])),
x509.NameAttribute(x509.OID_STATE_OR_PROVINCE_NAME, csr_config['state']), x509.NameAttribute(x509.OID_STATE_OR_PROVINCE_NAME, unicode(csr_config['state'])),
x509.NameAttribute(x509.OID_LOCALITY_NAME, csr_config['location']) x509.NameAttribute(x509.OID_LOCALITY_NAME, unicode(csr_config['location'])),
])) ]))
builder = builder.add_extension( builder = builder.add_extension(