diff --git a/lemur/auth/permissions.py b/lemur/auth/permissions.py index 13d8f6e1..6cc04cac 100644 --- a/lemur/auth/permissions.py +++ b/lemur/auth/permissions.py @@ -37,7 +37,7 @@ ViewRoleCredentialsNeed = partial(RoleUser, 'roleView') class ViewRoleCredentialsPermission(Permission): def __init__(self, role_id): - need = ViewRoleCredentialsNeed(str(role_id)) + need = ViewRoleCredentialsNeed(role_id) super(ViewRoleCredentialsPermission, self).__init__(need, RoleNeed('admin')) 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 @@