Example #1
0
    def post(self, certificate):
        """Create a new certificate.

        :param certificate: a certificate within the request body.
        """
        certificate_dict = certificate.as_dict()
        context = pecan.request.context
        certificate_dict['project_id'] = context.project_id
        certificate_dict['user_id'] = context.user_id
        cert_obj = objects.Certificate(context, **certificate_dict)

        new_cert = pecan.request.rpcapi.sign_certificate(
            certificate.get_bay(), cert_obj)
        return Certificate.convert_with_links(new_cert)
Example #2
0
    def post(self, certificate):
        """Sign a new certificate by the CA.

        :param certificate: a certificate within the request body.
        """
        context = pecan.request.context
        cluster = certificate.get_cluster()
        policy.enforce(context, 'certificate:create', cluster.as_dict(),
                       action='certificate:create')
        certificate_dict = certificate.as_dict()
        certificate_dict['project_id'] = context.project_id
        certificate_dict['user_id'] = context.user_id
        cert_obj = objects.Certificate(context, **certificate_dict)

        new_cert = pecan.request.rpcapi.sign_certificate(cluster,
                                                         cert_obj)
        return Certificate.convert_with_links(new_cert)