From 9cadebcd503445e0170187a6ef599c5705fcb064 Mon Sep 17 00:00:00 2001 From: kevgliss Date: Mon, 30 Nov 2015 13:51:27 -0800 Subject: [PATCH 1/2] adding example requests --- lemur/certificates/views.py | 56 +++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 11 deletions(-) diff --git a/lemur/certificates/views.py b/lemur/certificates/views.py index 6a58e93b..17cfca69 100644 --- a/lemur/certificates/views.py +++ b/lemur/certificates/views.py @@ -7,31 +7,22 @@ """ import base64 from builtins import str - from flask import Blueprint, make_response, jsonify from flask.ext.restful import reqparse, Api, fields - from cryptography import x509 from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import serialization - from lemur.certificates import service from lemur.authorities.models import Authority - from lemur.auth.service import AuthenticatedResource from lemur.auth.permissions import ViewKeyPermission, AuthorityPermission, UpdateCertificatePermission - from lemur.roles import service as role_service - from lemur.common.utils import marshal_items, paginated_parser - from lemur.notifications.views import notification_list - mod = Blueprint('certificates', __name__) api = Api(mod) - FIELDS = { 'name': fields.String, 'id': fields.Integer, @@ -104,6 +95,7 @@ def private_key_str(value, name): class CertificatesList(AuthenticatedResource): """ Defines the 'certificates' endpoint """ + def __init__(self): self.reqparse = reqparse.RequestParser() super(CertificatesList, self).__init__() @@ -354,6 +346,7 @@ class CertificatesList(AuthenticatedResource): class CertificatesUpload(AuthenticatedResource): """ Defines the 'certificates' upload endpoint """ + def __init__(self): self.reqparse = reqparse.RequestParser() super(CertificatesUpload, self).__init__() @@ -442,6 +435,7 @@ class CertificatesUpload(AuthenticatedResource): class CertificatesStats(AuthenticatedResource): """ Defines the 'certificates' stats endpoint """ + def __init__(self): self.reqparse = reqparse.RequestParser() super(CertificatesStats, self).__init__() @@ -646,6 +640,7 @@ class Certificates(AuthenticatedResource): class NotificationCertificatesList(AuthenticatedResource): """ Defines the 'certificates' endpoint """ + def __init__(self): self.reqparse = reqparse.RequestParser() super(NotificationCertificatesList, self).__init__() @@ -795,6 +790,38 @@ class CertificateExport(AuthenticatedResource): Host: example.com Accept: application/json, text/javascript + { + "export": { + "plugin": { + "pluginOptions": [{ + "available": ["Java Key Store (JKS)"], + "required": true, + "type": "select", + "name": "type", + "helpMessage": "Choose the format you wish to export", + "value": "Java Key Store (JKS)" + }, { + "required": false, + "type": "str", + "name": "passphrase", + "validation": "^(?=.*[A-Za-z])(?=.*\\d)(?=.*[$@$!%*#?&])[A-Za-z\\d$@$!%*#?&]{8,}$", + "helpMessage": "If no passphrase is given one will be generated for you, we highly recommend this. Minimum length is 8." + }, { + "required": false, + "type": "str", + "name": "alias", + "helpMessage": "Enter the alias you wish to use for the keystore." + }], + "version": "unknown", + "description": "Attempts to generate a JKS keystore or truststore", + "title": "Java", + "author": "Kevin Glisson", + "type": "export", + "slug": "java-export" + } + } + } + **Example response**: @@ -804,6 +831,11 @@ class CertificateExport(AuthenticatedResource): Vary: Accept Content-Type: text/javascript + { + "data": "base64encodedstring", + "passphrase": "UAWOHW#&@_%!tnwmxh832025", + "extension": "jks" + } :reqheader Authorization: OAuth token to authenticate :statuscode 200: no error @@ -831,5 +863,7 @@ api.add_resource(CertificatesStats, '/certificates/stats', endpoint='certificate api.add_resource(CertificatesUpload, '/certificates/upload', endpoint='certificateUpload') api.add_resource(CertificatePrivateKey, '/certificates//key', endpoint='privateKeyCertificates') api.add_resource(CertificateExport, '/certificates//export', endpoint='exportCertificate') -api.add_resource(NotificationCertificatesList, '/notifications//certificates', endpoint='notificationCertificates') -api.add_resource(CertificatesReplacementsList, '/certificates//replacements', endpoint='replacements') +api.add_resource(NotificationCertificatesList, '/notifications//certificates', + endpoint='notificationCertificates') +api.add_resource(CertificatesReplacementsList, '/certificates//replacements', + endpoint='replacements') From c3091a7346be1b55d4a7279d8d4d472645d3ee59 Mon Sep 17 00:00:00 2001 From: kevgliss Date: Mon, 30 Nov 2015 14:08:17 -0800 Subject: [PATCH 2/2] Adding missing files. --- .../certificates/certificate/export.tpl.html | 42 +++++++++++++++++++ .../certificate/replaces.tpl.html | 28 +++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 lemur/static/app/angular/certificates/certificate/export.tpl.html create mode 100644 lemur/static/app/angular/certificates/certificate/replaces.tpl.html diff --git a/lemur/static/app/angular/certificates/certificate/export.tpl.html b/lemur/static/app/angular/certificates/certificate/export.tpl.html new file mode 100644 index 00000000..bf42b424 --- /dev/null +++ b/lemur/static/app/angular/certificates/certificate/export.tpl.html @@ -0,0 +1,42 @@ + diff --git a/lemur/static/app/angular/certificates/certificate/replaces.tpl.html b/lemur/static/app/angular/certificates/certificate/replaces.tpl.html new file mode 100644 index 00000000..74cc381a --- /dev/null +++ b/lemur/static/app/angular/certificates/certificate/replaces.tpl.html @@ -0,0 +1,28 @@ +
+ +
+
+ + + + +
+ + + + + + +
{{ replacement.name }}{{ replacement.description }} + +
+
+