Rotation ui (#633)

* Adding rotation to the UI.

* Removing spinkit dependency.
This commit is contained in:
kevgliss
2016-12-26 15:55:11 -08:00
committed by GitHub
parent ce75bba2c3
commit 700c57b807
18 changed files with 417 additions and 391 deletions

View File

@ -196,6 +196,8 @@ def reissue(old_certificate_name, commit):
if commit:
print("[!] Running in COMMIT mode.")
print("[+] Starting certificate re-issuance.")
old_cert = validate_certificate(old_certificate_name)
if not old_cert:

View File

@ -66,7 +66,7 @@ class Certificate(db.Model):
bits = Column(Integer())
san = Column(String(1024)) # TODO this should be migrated to boolean
rotation = Column(Boolean)
rotation = Column(Boolean, default=False)
user_id = Column(Integer, ForeignKey('users.id'))
authority_id = Column(Integer, ForeignKey('authorities.id', ondelete="CASCADE"))

View File

@ -62,6 +62,7 @@ class CertificateInputSchema(CertificateCreationSchema):
key_type = fields.String(validate=validate.OneOf(['RSA2048', 'RSA4096']), missing='RSA2048')
notify = fields.Boolean(default=True)
rotation = fields.Boolean()
# certificate body fields
organizational_unit = fields.String(missing=lambda: current_app.config.get('LEMUR_DEFAULT_ORGANIZATIONAL_UNIT'))
@ -84,9 +85,11 @@ class CertificateInputSchema(CertificateCreationSchema):
class CertificateEditInputSchema(CertificateSchema):
notify = fields.Boolean()
owner = fields.String()
notify = fields.Boolean()
rotation = fields.Boolean()
destinations = fields.Nested(AssociatedDestinationSchema, missing=[], many=True)
notifications = fields.Nested(AssociatedNotificationSchema, missing=[], many=True)
replaces = fields.Nested(AssociatedCertificateSchema, missing=[], many=True)
@ -116,12 +119,20 @@ class CertificateEditInputSchema(CertificateSchema):
class CertificateNestedOutputSchema(LemurOutputSchema):
__envelope__ = False
id = fields.Integer()
active = fields.Boolean()
name = fields.String()
owner = fields.Email()
creator = fields.Nested(UserNestedOutputSchema)
description = fields.String()
status = fields.Boolean()
bits = fields.Integer()
body = fields.String()
chain = fields.String()
description = fields.String()
name = fields.String()
active = fields.Boolean()
rotation = fields.Boolean()
notify = fields.Boolean()
# Note aliasing is the first step in deprecating these fields.
cn = fields.String() # deprecated
@ -133,9 +144,6 @@ class CertificateNestedOutputSchema(LemurOutputSchema):
not_before = fields.DateTime() # deprecated
validity_start = ArrowDateTime(attribute='not_before')
owner = fields.Email()
status = fields.Boolean()
creator = fields.Nested(UserNestedOutputSchema)
issuer = fields.Nested(AuthorityNestedOutputSchema)
@ -155,6 +163,8 @@ class CertificateOutputSchema(LemurOutputSchema):
issuer = fields.String()
name = fields.String()
rotation = fields.Boolean()
# Note aliasing is the first step in deprecating these fields.
notify = fields.Boolean()
active = fields.Boolean(attribute='notify')

View File

@ -126,26 +126,16 @@ def export(cert, export_plugin):
return plugin.export(cert.body, cert.chain, cert.private_key, export_plugin['pluginOptions'])
def update(cert_id, owner, description, notify, destinations, notifications, replaces, roles):
def update(cert_id, **kwargs):
"""
Updates a certificate
:param cert_id:
:param owner:
:param description:
:param notify:
:param destinations:
:param notifications:
:param replaces:
:return:
"""
cert = get(cert_id)
cert.notify = notify
cert.description = description
cert.destinations = destinations
cert.notifications = notifications
cert.roles = roles
cert.replaces = replaces
cert.owner = owner
for key, value in kwargs.items():
setattr(cert, key, value)
return database.update(cert)
@ -555,7 +545,7 @@ def reissue_certificate(certificate, replace=None, user=None):
primitives['creator'] = user
if replace:
primitives['replacements'] = [certificate]
primitives['replaces'] = [certificate]
new_cert = create(**primitives)

View File

@ -638,18 +638,13 @@ class Certificates(AuthenticatedResource):
for destination in data['destinations']:
if destination.plugin.requires_key:
if not cert.private_key:
return dict(message='Unable to add destination: {0}. Certificate does not have required private key.'.format(destination.label)), 400
return dict(
message='Unable to add destination: {0}. Certificate does not have required private key.'.format(
destination.label
)
), 400
return service.update(
certificate_id,
data['owner'],
data['description'],
data['notify'],
data['destinations'],
data['notifications'],
data['replacements'],
data['roles']
)
return service.update(certificate_id)
class NotificationCertificatesList(AuthenticatedResource):