Merge pull request #3135 from charhate/key_type_column
Column addition key_type
This commit is contained in:
commit
531e5c0d00
|
@ -9,10 +9,8 @@ from datetime import timedelta
|
||||||
|
|
||||||
import arrow
|
import arrow
|
||||||
from cryptography import x509
|
from cryptography import x509
|
||||||
from cryptography.hazmat.primitives.asymmetric import rsa, ec
|
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
from idna.core import InvalidCodepoint
|
from idna.core import InvalidCodepoint
|
||||||
from lemur.common.utils import get_key_type_from_ec_curve
|
|
||||||
from sqlalchemy import (
|
from sqlalchemy import (
|
||||||
event,
|
event,
|
||||||
Integer,
|
Integer,
|
||||||
|
@ -154,6 +152,7 @@ class Certificate(db.Model):
|
||||||
Integer, ForeignKey("authorities.id", ondelete="CASCADE")
|
Integer, ForeignKey("authorities.id", ondelete="CASCADE")
|
||||||
)
|
)
|
||||||
rotation_policy_id = Column(Integer, ForeignKey("rotation_policies.id"))
|
rotation_policy_id = Column(Integer, ForeignKey("rotation_policies.id"))
|
||||||
|
key_type = Column(String(128))
|
||||||
|
|
||||||
notifications = relationship(
|
notifications = relationship(
|
||||||
"Notification",
|
"Notification",
|
||||||
|
@ -297,6 +296,8 @@ class Certificate(db.Model):
|
||||||
def distinguished_name(self):
|
def distinguished_name(self):
|
||||||
return self.parsed_cert.subject.rfc4514_string()
|
return self.parsed_cert.subject.rfc4514_string()
|
||||||
|
|
||||||
|
"""
|
||||||
|
# Commenting this property as key_type is now added as a column. This code can be removed in future.
|
||||||
@property
|
@property
|
||||||
def key_type(self):
|
def key_type(self):
|
||||||
if isinstance(self.parsed_cert.public_key(), rsa.RSAPublicKey):
|
if isinstance(self.parsed_cert.public_key(), rsa.RSAPublicKey):
|
||||||
|
@ -305,6 +306,7 @@ class Certificate(db.Model):
|
||||||
)
|
)
|
||||||
elif isinstance(self.parsed_cert.public_key(), ec.EllipticCurvePublicKey):
|
elif isinstance(self.parsed_cert.public_key(), ec.EllipticCurvePublicKey):
|
||||||
return get_key_type_from_ec_curve(self.parsed_cert.public_key().curve.name)
|
return get_key_type_from_ec_curve(self.parsed_cert.public_key().curve.name)
|
||||||
|
"""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def validity_remaining(self):
|
def validity_remaining(self):
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from sqlalchemy import Column, Integer, String, text, Text
|
from sqlalchemy import Column, Integer, String, text
|
||||||
from sqlalchemy.dialects.postgresql import JSON
|
from sqlalchemy.dialects.postgresql import JSON
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
from sqlalchemy_utils import ArrowType
|
from sqlalchemy_utils import ArrowType
|
||||||
|
@ -12,7 +12,7 @@ class DnsProvider(db.Model):
|
||||||
__tablename__ = "dns_providers"
|
__tablename__ = "dns_providers"
|
||||||
id = Column(Integer(), primary_key=True)
|
id = Column(Integer(), primary_key=True)
|
||||||
name = Column(String(length=256), unique=True, nullable=True)
|
name = Column(String(length=256), unique=True, nullable=True)
|
||||||
description = Column(Text(), nullable=True)
|
description = Column(String(length=1024), nullable=True)
|
||||||
provider_type = Column(String(length=256), nullable=True)
|
provider_type = Column(String(length=256), nullable=True)
|
||||||
credentials = Column(Vault, nullable=True)
|
credentials = Column(Vault, nullable=True)
|
||||||
api_endpoint = Column(String(length=256), nullable=True)
|
api_endpoint = Column(String(length=256), nullable=True)
|
||||||
|
|
|
@ -67,7 +67,8 @@ def run_migrations_online():
|
||||||
context.configure(
|
context.configure(
|
||||||
connection=connection,
|
connection=connection,
|
||||||
target_metadata=target_metadata,
|
target_metadata=target_metadata,
|
||||||
**current_app.extensions["migrate"].configure_args
|
**current_app.extensions["migrate"].configure_args,
|
||||||
|
compare_type=True
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
"""empty message
|
||||||
|
|
||||||
|
Revision ID: 434c29e40511
|
||||||
|
Revises: 8323a5ea723a
|
||||||
|
Create Date: 2020-09-11 17:24:51.344585
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '434c29e40511'
|
||||||
|
down_revision = '8323a5ea723a'
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.add_column('certificates', sa.Column('key_type', sa.String(length=128), nullable=True))
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_column('certificates', 'key_type')
|
||||||
|
# ### end Alembic commands ###
|
Loading…
Reference in New Issue