diff --git a/bower.json b/bower.json index 0677d331..ed1b02f4 100644 --- a/bower.json +++ b/bower.json @@ -39,7 +39,7 @@ "angular-ui-switch": "~0.1.0", "angular-sanitize": "^1.5.0", "angular-file-saver": "~1.0.1", - "angular-selectize2": "^3.0.1" + "angular-ui-select": "~0.17.1" }, "resolutions": { "moment": ">=2.8.0 <2.11.0", diff --git a/gulp/build.js b/gulp/build.js index 44ad1c03..1382f157 100644 --- a/gulp/build.js +++ b/gulp/build.js @@ -81,7 +81,7 @@ gulp.task('dev:styles', function () { 'bower_components/angular-wizard/dist/angular-wizard.css', 'bower_components/ng-table/ng-table.css', 'bower_components/angularjs-toaster/toaster.css', - 'bower_components/selectize/dist/css/selectize.bootstrap3.css', + 'bower_components/angular-ui-select/dist/select.css', 'lemur/static/app/styles/lemur.css' ]; diff --git a/lemur/authorities/schemas.py b/lemur/authorities/schemas.py index b6b18f75..7002c4a0 100644 --- a/lemur/authorities/schemas.py +++ b/lemur/authorities/schemas.py @@ -38,7 +38,7 @@ class AuthorityInputSchema(LemurInputSchema): # signing related options type = fields.String(validate=validate.OneOf(['root', 'subca']), missing='root') - authority = fields.Nested(AssociatedAuthoritySchema) + parent = fields.Nested(AssociatedAuthoritySchema) signing_algorithm = fields.String(validate=validate.OneOf(['sha256WithRSA', 'sha1WithRSA']), missing='sha256WithRSA') key_type = fields.String(validate=validate.OneOf(['RSA2048', 'RSA4096']), missing='RSA2048') key_name = fields.String() diff --git a/lemur/authorities/service.py b/lemur/authorities/service.py index 2c9b4d3f..0ce3fbb1 100644 --- a/lemur/authorities/service.py +++ b/lemur/authorities/service.py @@ -48,7 +48,7 @@ def mint(**kwargs): return body, chain, roles -def create_authority_roles(roles, **kwargs): +def create_authority_roles(**kwargs): """ Creates all of the necessary authority roles. :param roles: @@ -56,7 +56,7 @@ def create_authority_roles(roles, **kwargs): :return: """ role_objs = [] - for r in roles: + for r in kwargs['roles']: role = role_service.create( r['name'], password=r['password'], @@ -91,7 +91,12 @@ def create(**kwargs): kwargs['body'] = body kwargs['chain'] = chain - kwargs['roles'] = create_authority_roles(roles, **kwargs) + if kwargs.get('roles'): + kwargs['roles'] += roles + else: + kwargs['roles'] = roles + + kwargs['roles'] = create_authority_roles(**kwargs) if kwargs['type'] == 'subca': description = "This is the ROOT certificate for the {0} sub certificate authority the parent \ diff --git a/lemur/certificates/schemas.py b/lemur/certificates/schemas.py index 8f112269..23e98ae2 100644 --- a/lemur/certificates/schemas.py +++ b/lemur/certificates/schemas.py @@ -120,6 +120,7 @@ class CertificateOutputSchema(LemurOutputSchema): replaces = fields.Nested(CertificateNestedOutputSchema, many=True) authority = fields.Nested(AuthorityNestedOutputSchema) roles = fields.Nested(RoleNestedOutputSchema, many=True) + endpoints = fields.List(fields.Dict(), missing=[]) class CertificateUploadInputSchema(CertificateSchema): diff --git a/lemur/migrations/versions/3307381f3b88_.py b/lemur/migrations/versions/3307381f3b88_.py index e742be38..191b16ee 100644 --- a/lemur/migrations/versions/3307381f3b88_.py +++ b/lemur/migrations/versions/3307381f3b88_.py @@ -12,8 +12,10 @@ down_revision = '412b22cb656a' from alembic import op import sqlalchemy as sa +from sqlalchemy.sql import text from sqlalchemy.dialects import postgresql + def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.alter_column('authorities', 'owner', @@ -35,6 +37,18 @@ def upgrade(): op.create_foreign_key(None, 'certificates', 'authorities', ['root_authority_id'], ['id'], ondelete='CASCADE') ### end Alembic commands ### + # link existing certificate to their authority certificates + conn = op.get_bind() + for id, body in conn.execute(text('select id, body from authorities')): + # look up certificate by body, if duplications are found, pick one + stmt = text('select id from certificates where body=:body') + stmt = stmt.bindparams(body=body) + root_certificate = conn.execute(stmt).fetchone() + if root_certificate: + stmt = text('update certificates set root_authority_id=:root_authority_id where id=:id') + stmt = stmt.bindparams(root_authority_id=id, id=root_certificate[0]) + op.execute(stmt) + def downgrade(): ### commands auto generated by Alembic - please adjust! ### diff --git a/lemur/migrations/versions/412b22cb656a_.py b/lemur/migrations/versions/412b22cb656a_.py index 06122f7d..2e0c811d 100644 --- a/lemur/migrations/versions/412b22cb656a_.py +++ b/lemur/migrations/versions/412b22cb656a_.py @@ -15,8 +15,6 @@ import sqlalchemy as sa from sqlalchemy.sql import text - - def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.create_table('roles_authorities', diff --git a/lemur/static/app/angular/app.js b/lemur/static/app/angular/app.js index 11cc5823..a071a106 100644 --- a/lemur/static/app/angular/app.js +++ b/lemur/static/app/angular/app.js @@ -19,7 +19,7 @@ 'angular-clipboard', 'ngFileSaver', 'ngSanitize', - 'selectize' + 'ui.select' ]); diff --git a/lemur/static/app/angular/authorities/authority/authority.js b/lemur/static/app/angular/authorities/authority/authority.js index bf0bfc61..c67e7513 100644 --- a/lemur/static/app/angular/authorities/authority/authority.js +++ b/lemur/static/app/angular/authorities/authority/authority.js @@ -36,49 +36,14 @@ angular.module('lemur') .controller('AuthorityCreateController', function ($scope, $uibModalInstance, AuthorityService, AuthorityApi, LemurRestangular, RoleService, PluginService, WizardHandler, toaster) { $scope.authority = LemurRestangular.restangularizeElement(null, {}, 'authorities'); - - $scope.authorities = []; - AuthorityApi.getList().then(function (authorities) { - angular.extend($scope.authorities, authorities); - }); - - $scope.authorityConfig = { - valueField: 'id', - labelField: 'name', - placeholder: 'Select Authority', - maxItems: 1, - onChange: function (value) { - angular.forEach($scope.authorities, function (authority) { - if (authority.id === parseInt(value)) { - $scope.authority.authority = authority; - } - }); - }, - render: { - option: function(item) { - return '
' + - '
' + - '' + item.name + ' ' + item.owner + '' + - '
' + - '
' + - '' + item.description + '' + - '
' + - '
'; - } - }, - load: function (value) { - AuthorityService.findAuthorityByName(value).then(function (authorities) { - $scope.authorities = authorities; - }); - } - }; - // set the defaults AuthorityService.getDefaults($scope.authority); - AuthorityApi.getList().then(function (authorities) { - $scope.authorities = authorities; - }); + $scope.getAuthoritiesByName = function (value) { + return AuthorityService.findAuthorityByName(value).then(function (authorities) { + $scope.authorities = authorities; + }); + }; $scope.cancel = function () { $uibModalInstance.dismiss('cancel'); diff --git a/lemur/static/app/angular/authorities/authority/tracking.tpl.html b/lemur/static/app/angular/authorities/authority/tracking.tpl.html index d6361d5f..5b72d775 100644 --- a/lemur/static/app/angular/authorities/authority/tracking.tpl.html +++ b/lemur/static/app/angular/authorities/authority/tracking.tpl.html @@ -65,8 +65,17 @@ Parent Authority
- + + {{$select.selected.name}} + +
+ + + +
+
@@ -111,8 +120,8 @@ is-open="popup2.opened" datepicker-options="dateOptions" close-text="Close" - max-date="authority.authority.notAfter" - min-date="authority.authority.notBefore" + max-date="authority.parent.authorityCertificate.notAfter" + min-date="authority.parent.authorityCertificate.notBefore" alt-input-formats="altInputFormats" /> diff --git a/lemur/static/app/angular/certificates/certificate/certificate.js b/lemur/static/app/angular/certificates/certificate/certificate.js index d3d3c8a2..589ee319 100644 --- a/lemur/static/app/angular/certificates/certificate/certificate.js +++ b/lemur/static/app/angular/certificates/certificate/certificate.js @@ -94,43 +94,12 @@ angular.module('lemur') $uibModalInstance.dismiss('cancel'); }; - $scope.authorities = []; - AuthorityApi.getList().then(function (authorities) { - angular.extend($scope.authorities, authorities); - }); - - $scope.authorityConfig = { - valueField: 'id', - labelField: 'name', - highlight: true, - placeholder: 'Select Authority', - maxItems: 1, - onChange: function (value) { - angular.forEach($scope.authorities, function (authority) { - if (authority.id === parseInt(value)) { - $scope.certificate.authority = authority; - } - }); - }, - render: { - option: function(item) { - return '
' + - '
' + - '' + item.name + ' ' + item.owner + '' + - '
' + - '
' + - '' + item.description + '' + - '
' + - '
'; - } - }, - load: function (value) { - AuthorityService.findAuthorityByName(value).then(function (authorities) { - $scope.authorities = authorities; - }); - } + $scope.getAuthoritiesByName = function (value) { + return AuthorityService.findAuthorityByName(value).then(function (authorities) { + $scope.authorities = authorities; + }); }; - + $scope.dateOptions = { formatYear: 'yy', maxDate: new Date(2020, 5, 22), diff --git a/lemur/static/app/angular/certificates/certificate/tracking.tpl.html b/lemur/static/app/angular/certificates/certificate/tracking.tpl.html index 5ed77615..e68cea33 100644 --- a/lemur/static/app/angular/certificates/certificate/tracking.tpl.html +++ b/lemur/static/app/angular/certificates/certificate/tracking.tpl.html @@ -46,8 +46,17 @@ Certificate Authority
- + + {{$select.selected.name}} + +
+ + + +
+
diff --git a/lemur/static/app/index.html b/lemur/static/app/index.html index f125ed28..af515fc9 100644 --- a/lemur/static/app/index.html +++ b/lemur/static/app/index.html @@ -30,7 +30,6 @@ -