254 duplication certificate name (#319)
This commit is contained in:
@ -53,8 +53,6 @@ def create_name(issuer, not_before, not_after, subject, san):
|
||||
not_after=not_after.strftime('%Y%m%d')
|
||||
)
|
||||
|
||||
# NOTE we may want to give more control over naming
|
||||
# aws doesn't allow special chars except '-'
|
||||
disallowed_chars = ''.join(c for c in map(chr, range(256)) if not c.isalnum())
|
||||
disallowed_chars = disallowed_chars.replace("-", "")
|
||||
disallowed_chars = disallowed_chars.replace(".", "")
|
||||
@ -64,7 +62,13 @@ def create_name(issuer, not_before, not_after, subject, san):
|
||||
temp = temp.replace(c, "")
|
||||
|
||||
# white space is silly too
|
||||
return temp.replace(" ", "-")
|
||||
final = temp.replace(" ", "-")
|
||||
|
||||
# we don't want any overlapping certificate names
|
||||
if Certificate.query.filter(Certificate.name == final).all():
|
||||
final += '-1'
|
||||
|
||||
return final
|
||||
|
||||
|
||||
def get_signing_algorithm(cert):
|
||||
|
@ -129,7 +129,7 @@ class CertificateUploadInputSchema(LemurInputSchema):
|
||||
|
||||
|
||||
class CertificateExportInputSchema(LemurInputSchema):
|
||||
export = fields.Nested(PluginInputSchema)
|
||||
plugin = fields.Nested(PluginInputSchema)
|
||||
|
||||
|
||||
certificate_input_schema = CertificateInputSchema()
|
||||
|
@ -675,7 +675,7 @@ class CertificateExport(AuthenticatedResource):
|
||||
self.reqparse = reqparse.RequestParser()
|
||||
super(CertificateExport, self).__init__()
|
||||
|
||||
@validate_schema(None, certificate_export_input_schema)
|
||||
@validate_schema(certificate_export_input_schema, None)
|
||||
def post(self, certificate_id, data=None):
|
||||
"""
|
||||
.. http:post:: /certificates/1/export
|
||||
@ -743,11 +743,10 @@ class CertificateExport(AuthenticatedResource):
|
||||
"""
|
||||
cert = service.get(certificate_id)
|
||||
role = role_service.get_by_name(cert.owner)
|
||||
|
||||
permission = UpdateCertificatePermission(certificate_id, getattr(role, 'name', None))
|
||||
|
||||
options = data['export']['plugin']['plugin_options']
|
||||
plugin = data['export']['plugin']
|
||||
options = data['plugin']['plugin_options']
|
||||
plugin = data['plugin']['plugin_object']
|
||||
|
||||
if plugin.requires_key:
|
||||
if permission.can():
|
||||
|
Reference in New Issue
Block a user