Merge pull request #2814 from intgr/expose-cert-hasprivaatekey

Expose new certificate field hasPrivateKey
This commit is contained in:
Curtis 2019-06-25 09:40:27 -07:00 committed by GitHub
commit 5df06501f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 3 deletions

View File

@ -137,7 +137,7 @@ class Certificate(db.Model):
not_before = Column(ArrowType) not_before = Column(ArrowType)
not_after = Column(ArrowType) not_after = Column(ArrowType)
not_after_ix = Index('ix_certificates_not_after', not_after.desc()) not_after_ix = Index("ix_certificates_not_after", not_after.desc())
date_created = Column(ArrowType, PassiveDefault(func.now()), nullable=False) date_created = Column(ArrowType, PassiveDefault(func.now()), nullable=False)
@ -337,6 +337,14 @@ class Certificate(db.Model):
def revoked(cls): def revoked(cls):
return case([(cls.status == "revoked", True)], else_=False) return case([(cls.status == "revoked", True)], else_=False)
@hybrid_property
def has_private_key(self):
return self.private_key is not None
@has_private_key.expression
def has_private_key(cls):
return case([(cls.private_key.is_(None), True)], else_=False)
@hybrid_property @hybrid_property
def in_rotation_window(self): def in_rotation_window(self):
""" """

View File

@ -247,6 +247,7 @@ class CertificateOutputSchema(LemurOutputSchema):
# Note aliasing is the first step in deprecating these fields. # Note aliasing is the first step in deprecating these fields.
notify = fields.Boolean() notify = fields.Boolean()
active = fields.Boolean(attribute="notify") active = fields.Boolean(attribute="notify")
has_private_key = fields.Boolean()
cn = fields.String() cn = fields.String()
common_name = fields.String(attribute="cn") common_name = fields.String(attribute="cn")

View File

@ -203,10 +203,10 @@
</uib-tab-heading> </uib-tab-heading>
<pre style="width: 100%">{{ certificate.body }}</pre> <pre style="width: 100%">{{ certificate.body }}</pre>
</uib-tab> </uib-tab>
<uib-tab ng-click="loadPrivateKey(certificate)"> <uib-tab ng-click="loadPrivateKey(certificate)" disable="!certificate.hasPrivateKey">
<uib-tab-heading> <uib-tab-heading>
Private Key Private Key
<i class="glyphicon glyphicon-copy" style="cursor: pointer" clipboard text="certificate.privateKey"></i> <i class="glyphicon glyphicon-copy" style="cursor: pointer" clipboard ng-if="certificate.hasPrivateKey" text="certificate.privateKey"></i>
</uib-tab-heading> </uib-tab-heading>
<pre style="width: 100%">{{ certificate.privateKey }}</pre> <pre style="width: 100%">{{ certificate.privateKey }}</pre>
</uib-tab> </uib-tab>