From 03e2991ced00a3dfdf0d39f1b94f3abee7e7efef Mon Sep 17 00:00:00 2001
From: kevgliss
Date: Sat, 29 Aug 2015 11:48:39 -0700
Subject: [PATCH 01/21] Closes #57
---
lemur/certificates/service.py | 4 ++++
lemur/certificates/views.py | 4 +++-
.../app/angular/certificates/certificate/upload.tpl.html | 9 +++++++++
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/lemur/certificates/service.py b/lemur/certificates/service.py
index 8a1e20fa..1eb82b7b 100644
--- a/lemur/certificates/service.py
+++ b/lemur/certificates/service.py
@@ -168,6 +168,10 @@ def upload(**kwargs):
kwargs.get('intermediate_cert'),
)
+ # we override the generated name if one is provided
+ if kwargs.get('name'):
+ cert.name = kwargs['name']
+
cert.description = kwargs.get('description')
cert.owner = kwargs['owner']
diff --git a/lemur/certificates/views.py b/lemur/certificates/views.py
index b6cb597d..4643dedc 100644
--- a/lemur/certificates/views.py
+++ b/lemur/certificates/views.py
@@ -332,7 +332,8 @@ class CertificatesUpload(AuthenticatedResource):
"intermediateCert": "---Begin Public...",
"privateKey": "---Begin Private..."
"destinations": [],
- "notifications": []
+ "notifications": [],
+ "name": "cert1"
}
**Example response**:
@@ -373,6 +374,7 @@ class CertificatesUpload(AuthenticatedResource):
"""
self.reqparse.add_argument('description', type=str, location='json')
self.reqparse.add_argument('owner', type=str, required=True, location='json')
+ self.reqparse.add_argument('name', type=str, location='json')
self.reqparse.add_argument('publicCert', type=pem_str, required=True, dest='public_cert', location='json')
self.reqparse.add_argument('destinations', type=list, default=[], dest='destinations', location='json')
self.reqparse.add_argument('notifications', type=list, default=[], dest='notifications', location='json')
diff --git a/lemur/static/app/angular/certificates/certificate/upload.tpl.html b/lemur/static/app/angular/certificates/certificate/upload.tpl.html
index 6ba63232..928e923e 100644
--- a/lemur/static/app/angular/certificates/certificate/upload.tpl.html
+++ b/lemur/static/app/angular/certificates/certificate/upload.tpl.html
@@ -18,6 +18,15 @@
email.
+
Date: Tue, 1 Sep 2015 14:05:32 -0700
Subject: [PATCH 06/21] Allows authorities to have editable owners and
descriptions
---
lemur/authorities/service.py | 5 +++-
lemur/authorities/views.py | 25 +++++++++++++------
.../{authorityEdit.tpl.html => edit.tpl.html} | 25 ++++++++++++++++++-
.../app/angular/authorities/view/view.js | 21 +++++++++++++++-
.../angular/authorities/view/view.tpl.html | 2 +-
lemur/static/app/angular/roles/services.js | 2 --
6 files changed, 67 insertions(+), 13 deletions(-)
rename lemur/static/app/angular/authorities/authority/{authorityEdit.tpl.html => edit.tpl.html} (59%)
diff --git a/lemur/authorities/service.py b/lemur/authorities/service.py
index 23961ede..5a1f4341 100644
--- a/lemur/authorities/service.py
+++ b/lemur/authorities/service.py
@@ -22,7 +22,7 @@ from lemur.certificates.models import Certificate
from lemur.plugins.base import plugins
-def update(authority_id, active=None, roles=None):
+def update(authority_id, description=None, owner=None, active=None, roles=None):
"""
Update a an authority with new values.
@@ -37,6 +37,9 @@ def update(authority_id, active=None, roles=None):
if active:
authority.active = active
+
+ authority.description = description
+ authority.owner = owner
return database.update(authority)
diff --git a/lemur/authorities/views.py b/lemur/authorities/views.py
index f449a837..43a65fe5 100644
--- a/lemur/authorities/views.py
+++ b/lemur/authorities/views.py
@@ -20,6 +20,7 @@ from lemur.common.utils import paginated_parser, marshal_items
FIELDS = {
'name': fields.String,
+ 'owner': fields.String,
'description': fields.String,
'options': fields.Raw,
'pluginName': fields.String,
@@ -264,7 +265,9 @@ class Authorities(AuthenticatedResource):
{
"roles": [],
- "active": false
+ "active": false,
+ "owner": "bob@example.com",
+ "description": "this is authority1"
}
**Example response**:
@@ -279,12 +282,12 @@ class Authorities(AuthenticatedResource):
"id": 1,
"name": "authority1",
"description": "this is authority1",
- "pluginname": null,
+ "pluginName": null,
"chain": "-----begin ...",
"body": "-----begin ...",
"active": false,
- "notbefore": "2015-06-05t17:09:39",
- "notafter": "2015-06-10t17:09:39"
+ "notBefore": "2015-06-05t17:09:39",
+ "notAfter": "2015-06-10t17:09:39"
"options": null
}
@@ -292,8 +295,10 @@ class Authorities(AuthenticatedResource):
:statuscode 200: no error
:statuscode 403: unauthenticated
"""
- self.reqparse.add_argument('roles', type=list, location='json')
- self.reqparse.add_argument('active', type=str, location='json')
+ self.reqparse.add_argument('roles', type=list, default=[], location='json')
+ self.reqparse.add_argument('active', type=str, location='json', required=True)
+ self.reqparse.add_argument('owner', type=str, location='json', required=True)
+ self.reqparse.add_argument('description', type=str, location='json', required=True)
args = self.reqparse.parse_args()
authority = service.get(authority_id)
@@ -315,7 +320,13 @@ class Authorities(AuthenticatedResource):
return dict(message="You are not allowed to associate a role which you are not a member of"), 400
if permission.can():
- return service.update(authority_id, active=args['active'], roles=args['roles'])
+ return service.update(
+ authority_id,
+ owner=args['owner'],
+ description=args['description'],
+ active=args['active'],
+ roles=args['roles']
+ )
return dict(message="You are not authorized to update this authority"), 403
diff --git a/lemur/static/app/angular/authorities/authority/authorityEdit.tpl.html b/lemur/static/app/angular/authorities/authority/edit.tpl.html
similarity index 59%
rename from lemur/static/app/angular/authorities/authority/authorityEdit.tpl.html
rename to lemur/static/app/angular/authorities/authority/edit.tpl.html
index f100ba1b..fe3d3eac 100644
--- a/lemur/static/app/angular/authorities/authority/authorityEdit.tpl.html
+++ b/lemur/static/app/angular/authorities/authority/edit.tpl.html
@@ -1,9 +1,32 @@