more stuff

This commit is contained in:
Curtis Castrapel 2018-04-10 16:04:07 -07:00
parent f61098b874
commit 5beb319b27
8 changed files with 174 additions and 13 deletions

View File

@ -28,6 +28,7 @@ from lemur.endpoints.views import mod as endpoints_bp
from lemur.logs.views import mod as logs_bp
from lemur.api_keys.views import mod as api_key_bp
from lemur.pending_certificates.views import mod as pending_certificates_bp
from lemur.dns_providers.views import mod as dns_providers_bp
from lemur.__about__ import (
__author__, __copyright__, __email__, __license__, __summary__, __title__,
@ -56,6 +57,7 @@ LEMUR_BLUEPRINTS = (
logs_bp,
api_key_bp,
pending_certificates_bp,
dns_providers_bp,
)

View File

@ -0,0 +1,20 @@
from sqlalchemy import Column, Integer, PrimaryKeyConstraint, String, text, UniqueConstraint
from sqlalchemy.dialects.postgresql import JSON
from sqlalchemy_utils import ArrowType
from lemur.database import db
class DnsProviders(db.Model):
db.Table('dns_providers',
Column('id', Integer(), nullable=False),
Column('name', String(length=256), nullable=True),
Column('description', String(length=1024), nullable=True),
Column('provider_type', String(length=256), nullable=True),
Column('credentials', String(length=256), nullable=True),
Column('api_endpoint', String(length=256), nullable=True),
Column('date_created', ArrowType(), server_default=text('now()'), nullable=False),
Column('status', String(length=128), nullable=True),
Column('options', JSON),
PrimaryKeyConstraint('id'),
UniqueConstraint('name'))

View File

@ -0,0 +1,10 @@
from lemur.dns_providers.models import DnsProviders
def get_all_dns_providers(status="active"):
"""
Retrieves all certificates within Lemur.
:return:
"""
return DnsProviders.query.all(status=status)

View File

@ -0,0 +1,72 @@
"""
.. module: lemur.dns)providers.views
:platform: Unix
:copyright: (c) 2015 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: Curtis Castrapel <ccastrapel@netflix.com>
"""
from flask import Blueprint
from flask_restful import reqparse, Api
from lemur.auth.service import AuthenticatedResource
from lemur.dns_providers import service
mod = Blueprint('dns_providers', __name__)
api = Api(mod)
class DnsProvidersList(AuthenticatedResource):
""" Defines the 'dns_providers' endpoint """
def __init__(self):
self.reqparse = reqparse.RequestParser()
super(DnsProvidersList, self).__init__()
def get(self):
"""
.. http:get:: /dns_providers
The current list of DNS Providers
**Example request**:
.. sourcecode:: http
GET /dns_providers HTTP/1.1
Host: example.com
Accept: application/json, text/javascript
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept
Content-Type: text/javascript
{
"items": [{
"id": 1,
"name": "test",
"description": "test",
"provider_type": "dyn",
"status": "active",
}],
"total": 1
}
:query sortBy: field to sort on
:query sortDir: asc or desc
:query page: int. default is 1
:query filter: key value pair format is k;v
:query count: count number. default is 10
:reqheader Authorization: OAuth token to authenticate
:statuscode 200: no error
:statuscode 403: unauthenticated
"""
return service.get_all_dns_providers()
api.add_resource(DnsProvidersList, '/dns_providers', endpoint='dns_providers')

View File

@ -0,0 +1,39 @@
"""Create dns_providers table
Revision ID: 3adfdd6598df
Revises: 556ceb3e3c3e
Create Date: 2018-04-10 13:25:47.007556
"""
# revision identifiers, used by Alembic.
revision = '3adfdd6598df'
down_revision = '556ceb3e3c3e'
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects.postgresql import JSON
from sqlalchemy_utils import ArrowType
def upgrade():
# create provider table
op.create_table(
'dns_providers',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=256), nullable=True),
sa.Column('description', sa.String(length=1024), nullable=True),
sa.Column('provider_type', sa.String(length=256), nullable=True),
sa.Column('credentials', sa.String(length=256), nullable=True),
sa.Column('api_endpoint', sa.String(length=256), nullable=True),
sa.Column('date_created', ArrowType(), server_default=sa.text('now()'), nullable=False),
sa.Column('status', sa.String(length=128), nullable=True),
sa.Column('options', JSON),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('name')
)
def downgrade():
op.drop_table('dns_providers')

View File

@ -0,0 +1,22 @@
"""Add dns_provider id column to certificates table
Revision ID: 4e78b9e4e1dd
Revises: 3adfdd6598df
Create Date: 2018-04-10 14:00:30.701669
"""
# revision identifiers, used by Alembic.
revision = '4e78b9e4e1dd'
down_revision = '3adfdd6598df'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.add_column('certificates', sa.Column('dns_provider_id', sa.Integer(), nullable=True))
def downgrade():
op.drop_column('certificates', 'dns_provider_id')

View File

@ -132,16 +132,3 @@ pending_cert_role_associations = db.Table('pending_cert_role_associations',
)
Index('pending_cert_role_associations_ix', pending_cert_role_associations.c.pending_cert_id, pending_cert_role_associations.c.role_id)
dns_providers = db.Table('dns_providers',
Column('id', Integer(), nullable=False),
Column('name', String(length=256), nullable=True),
Column('description', String(length=1024), nullable=True),
Column('provider_type', String(length=256), nullable=True),
Column('credentials', String(length=256), nullable=True),
Column('api_endpoint', String(length=256), nullable=True),
Column('date_created', ArrowType(), server_default=text('now()'), nullable=False),
Column('status', String(length=128), nullable=True),
Column('options', JSON),
PrimaryKeyConstraint('id'),
UniqueConstraint('name'))

View File

@ -231,6 +231,15 @@
</label>
</div>
</div>
<!-- <div class="form-group">
<label class="control-label col-sm-2">
DNS Provider (Only needed for LetsEncrypt or ACME implementations)
</label>
<div class="col-sm-10">
<select class="form-control" ng-model="certificate.extensions.crlDistributionPoints.includeCrlDp"
ng-options="item for item in ['yes', 'no', 'default']"></select>
</div> -->
</div>
</div>
</div>
<div class="form-group">