Adds the ability to clone existing certificates. (#513)

This commit is contained in:
kevgliss
2016-11-17 16:19:52 -08:00
committed by GitHub
parent a616310eb7
commit 6fd47edbe3
9 changed files with 264 additions and 54 deletions

View File

@ -148,6 +148,19 @@ class Certificate(db.Model):
else_=False
)
@property
def extensions(self):
# TODO pull the OU, O, CN, etc + other extensions.
names = [{'name_type': 'DNSName', 'value': x.name} for x in self.domains]
extensions = {
'sub_alt_names': {
'names': names
}
}
return extensions
def get_arn(self, account_number):
"""
Generate a valid AWS IAM arn

View File

@ -110,9 +110,17 @@ class CertificateNestedOutputSchema(LemurOutputSchema):
chain = fields.String()
description = fields.String()
name = fields.String()
# Note aliasing is the first step in deprecating these fields.
cn = fields.String()
common_name = fields.String(attribute='cn')
not_after = fields.DateTime()
validity_end = ArrowDateTime(attribute='not_after')
not_before = fields.DateTime()
validity_start = ArrowDateTime(attribute='not_before')
owner = fields.Email()
status = fields.Boolean()
creator = fields.Nested(UserNestedOutputSchema)
@ -127,8 +135,6 @@ class CertificateCloneSchema(LemurOutputSchema):
class CertificateOutputSchema(LemurOutputSchema):
id = fields.Integer()
active = fields.Boolean()
notify = fields.Boolean()
bits = fields.Integer()
body = fields.String()
chain = fields.String()
@ -136,15 +142,31 @@ class CertificateOutputSchema(LemurOutputSchema):
description = fields.String()
issuer = fields.String()
name = fields.String()
# Note aliasing is the first step in deprecating these fields.
notify = fields.Boolean()
active = fields.Boolean(attribute='notify')
cn = fields.String()
common_name = fields.String(attribute='cn')
not_after = fields.DateTime()
validity_end = ArrowDateTime(attribute='not_after')
not_before = fields.DateTime()
validity_start = ArrowDateTime(attribute='not_before')
owner = fields.Email()
san = fields.Boolean()
serial = fields.String()
signing_algorithm = fields.String()
status = fields.Boolean()
user = fields.Nested(UserNestedOutputSchema)
extensions = fields.Nested(ExtensionSchema)
# associated objects
domains = fields.Nested(DomainNestedOutputSchema, many=True)
destinations = fields.Nested(DestinationNestedOutputSchema, many=True)
notifications = fields.Nested(NotificationNestedOutputSchema, many=True)