From 9da713ab063000f97f6d8dab7ea23ca51b971fd1 Mon Sep 17 00:00:00 2001 From: kevgliss Date: Fri, 4 Sep 2015 15:29:57 -0700 Subject: [PATCH 1/6] cleaning up references to netflix --- lemur/manage.py | 10 +++++----- lemur/plugins/lemur_email/templates/expiration.html | 2 +- .../app/angular/authorities/authority/edit.tpl.html | 2 +- .../angular/authorities/authority/tracking.tpl.html | 2 +- .../angular/certificates/certificate/upload.tpl.html | 4 ++-- lemur/static/app/angular/welcome/welcome.html | 7 ------- lemur/status/views.py | 6 ++++-- 7 files changed, 14 insertions(+), 19 deletions(-) diff --git a/lemur/manage.py b/lemur/manage.py index 42137576..5f9418ad 100755 --- a/lemur/manage.py +++ b/lemur/manage.py @@ -569,11 +569,11 @@ class ProvisionELB(Command): 'authority': authority, 'owner': owner, # defaults: - 'organization': u'Netflix, Inc.', - 'organizationalUnit': u'Operations', - 'country': u'US', - 'state': u'California', - 'location': u'Los Gatos' + 'organization': current_app.config.get('LEMUR_DEFAULT_ORGANIZATION'), + 'organizationalUnit': current_app.config.get('LEMUR_DEFAULT_ORGANIZATIONAL_UNIT'), + 'country': current_app.config.get('LEMUR_DEFAULT_COUNTRY'), + 'state': current_app.config.get('LEMUR_DEFAULT_STATE'), + 'location': current_app.config.get('LEMUR_DEFAULT_LOCATION') } return options diff --git a/lemur/plugins/lemur_email/templates/expiration.html b/lemur/plugins/lemur_email/templates/expiration.html index f3584bd2..32d6883a 100644 --- a/lemur/plugins/lemur_email/templates/expiration.html +++ b/lemur/plugins/lemur_email/templates/expiration.html @@ -53,7 +53,7 @@

- Lemur, Netflix's SSL management portal has noticed that the following certificates are expiring soon, if you rely on these certificates + Lemur, has noticed that the following certificates are expiring soon, if you rely on these certificates you should create new certificates to replace the certificates that are expiring.

diff --git a/lemur/static/app/angular/authorities/authority/edit.tpl.html b/lemur/static/app/angular/authorities/authority/edit.tpl.html index fe3d3eac..a11e9177 100644 --- a/lemur/static/app/angular/authorities/authority/edit.tpl.html +++ b/lemur/static/app/angular/authorities/authority/edit.tpl.html @@ -10,7 +10,7 @@ Owner

-

Enter a valid diff --git a/lemur/static/app/angular/authorities/authority/tracking.tpl.html b/lemur/static/app/angular/authorities/authority/tracking.tpl.html index a2d0def6..b019bcf9 100644 --- a/lemur/static/app/angular/authorities/authority/tracking.tpl.html +++ b/lemur/static/app/angular/authorities/authority/tracking.tpl.html @@ -16,7 +16,7 @@ Owner

- +

You must enter an Certificate Authority owner

diff --git a/lemur/static/app/angular/certificates/certificate/upload.tpl.html b/lemur/static/app/angular/certificates/certificate/upload.tpl.html index 55dc850f..f97d8d67 100644 --- a/lemur/static/app/angular/certificates/certificate/upload.tpl.html +++ b/lemur/static/app/angular/certificates/certificate/upload.tpl.html @@ -11,7 +11,7 @@
-

Enter a valid @@ -24,7 +24,7 @@ Custom Name

- +

SSL In The Cloud Encrypt it all

- -

The Security Operations team manages all of the SSL certificate generation at Netflix. This - portal was created to serve as both a self service application so that application owners can provision - their own certificates and to help enforce some key naming and security conventions, in order provide - Netflix with scalable and manageable SSL security.

- -

See go/ssl for more info.

diff --git a/lemur/status/views.py b/lemur/status/views.py index 65d3af7a..fddfdb69 100644 --- a/lemur/status/views.py +++ b/lemur/status/views.py @@ -5,7 +5,7 @@ """ import os -from flask import app, Blueprint, jsonify +from flask import app, current_app, Blueprint, jsonify from flask.ext.restful import Api from lemur.auth.service import AuthenticatedResource @@ -25,7 +25,9 @@ class Status(AuthenticatedResource): return jsonify({ 'environment': app.config.get('ENVIRONMENT'), 'status': 'degraded', - 'message': "This Lemur instance is in a degraded state and is unable to issue certificates, please alert secops@netflix.com"}) + 'message': "This Lemur instance is in a degraded state and is unable to issue certificates, please alert {0}".format( + current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL') + )}) else: return jsonify({ 'environment': app.config.get('ENVIRONMENT'), From aaae4d5a1f8c4591ff74b11e0f93faed34376696 Mon Sep 17 00:00:00 2001 From: kevgliss Date: Fri, 4 Sep 2015 15:52:56 -0700 Subject: [PATCH 2/6] unifying lemur defaults --- lemur/__init__.py | 4 +- lemur/certificates/views.py | 51 +-------------- lemur/{status => defaults}/__init__.py | 0 lemur/defaults/views.py | 63 +++++++++++++++++++ lemur/static/app/angular/app.js | 9 +++ .../authorities/authority/authority.js | 3 + .../app/angular/authorities/services.js | 12 +++- .../app/angular/certificates/services.js | 4 +- lemur/status/views.py | 35 ----------- 9 files changed, 91 insertions(+), 90 deletions(-) rename lemur/{status => defaults}/__init__.py (100%) create mode 100644 lemur/defaults/views.py delete mode 100644 lemur/status/views.py diff --git a/lemur/__init__.py b/lemur/__init__.py index 24cb6ef1..79b45241 100644 --- a/lemur/__init__.py +++ b/lemur/__init__.py @@ -17,7 +17,7 @@ from lemur.domains.views import mod as domains_bp from lemur.destinations.views import mod as destinations_bp from lemur.authorities.views import mod as authorities_bp from lemur.certificates.views import mod as certificates_bp -from lemur.status.views import mod as status_bp +from lemur.defaults.views import mod as defaults_bp from lemur.plugins.views import mod as plugins_bp from lemur.notifications.views import mod as notifications_bp from lemur.sources.views import mod as sources_bp @@ -31,7 +31,7 @@ LEMUR_BLUEPRINTS = ( destinations_bp, authorities_bp, certificates_bp, - status_bp, + defaults_bp, plugins_bp, notifications_bp, sources_bp diff --git a/lemur/certificates/views.py b/lemur/certificates/views.py index 834fdff7..112c86ad 100644 --- a/lemur/certificates/views.py +++ b/lemur/certificates/views.py @@ -7,7 +7,7 @@ """ from builtins import str -from flask import Blueprint, current_app, make_response, jsonify +from flask import Blueprint, make_response, jsonify from flask.ext.restful import reqparse, Api, fields from cryptography import x509 @@ -668,58 +668,9 @@ class NotificationCertificatesList(AuthenticatedResource): return service.render(args) -class CertificatesDefaults(AuthenticatedResource): - """ Defineds the 'certificates' defaults endpoint """ - def __init__(self): - super(CertificatesDefaults) - - def get(self): - """ - .. http:get:: /certificates/defaults - - Returns defaults needed to generate CSRs - - **Example request**: - - .. sourcecode:: http - - GET /certificates/defaults HTTP/1.1 - Host: example.com - Accept: application/json, text/javascript - - **Example response**: - - .. sourcecode:: http - - HTTP/1.1 200 OK - Vary: Accept - Content-Type: text/javascript - - { - "country": "US", - "state": "CA", - "location": "Los Gatos", - "organization": "Netflix", - "organizationalUnit": "Operations" - } - - :reqheader Authorization: OAuth token to authenticate - :statuscode 200: no error - :statuscode 403: unauthenticated - """ - return dict( - country=current_app.config.get('LEMUR_DEFAULT_COUNTRY'), - state=current_app.config.get('LEMUR_DEFAULT_STATE'), - location=current_app.config.get('LEMUR_DEFAULT_LOCATION'), - organization=current_app.config.get('LEMUR_DEFAULT_ORGANIZATION'), - organizationalUnit=current_app.config.get('LEMUR_DEFAULT_ORGANIZATIONAL_UNIT') - ) - - api.add_resource(CertificatesList, '/certificates', endpoint='certificates') api.add_resource(Certificates, '/certificates/', endpoint='certificate') api.add_resource(CertificatesStats, '/certificates/stats', endpoint='certificateStats') api.add_resource(CertificatesUpload, '/certificates/upload', endpoint='certificateUpload') api.add_resource(CertificatePrivateKey, '/certificates//key', endpoint='privateKeyCertificates') api.add_resource(NotificationCertificatesList, '/notifications//certificates', endpoint='notificationCertificates') -api.add_resource(CertificatesDefaults, '/certificates/defaults', endpoint='certificatesDefault') diff --git a/lemur/status/__init__.py b/lemur/defaults/__init__.py similarity index 100% rename from lemur/status/__init__.py rename to lemur/defaults/__init__.py diff --git a/lemur/defaults/views.py b/lemur/defaults/views.py new file mode 100644 index 00000000..d053aef7 --- /dev/null +++ b/lemur/defaults/views.py @@ -0,0 +1,63 @@ +""" +.. module: lemur.status.views + :copyright: (c) 2015 by Netflix Inc., see AUTHORS for more + :license: Apache, see LICENSE for more details. +""" +from flask import current_app, Blueprint +from flask.ext.restful import Api + +from lemur.auth.service import AuthenticatedResource + + +mod = Blueprint('default', __name__) +api = Api(mod) + + +class LemurDefaults(AuthenticatedResource): + """ Defines the 'defaults' endpoint """ + def __init__(self): + super(LemurDefaults) + + def get(self): + """ + .. http:get:: /defaults + + Returns defaults needed to generate CSRs + + **Example request**: + + .. sourcecode:: http + + GET /defaults HTTP/1.1 + Host: example.com + Accept: application/json, text/javascript + + **Example response**: + + .. sourcecode:: http + + HTTP/1.1 200 OK + Vary: Accept + Content-Type: text/javascript + + { + "country": "US", + "state": "CA", + "location": "Los Gatos", + "organization": "Netflix", + "organizationalUnit": "Operations" + } + + :reqheader Authorization: OAuth token to authenticate + :statuscode 200: no error + :statuscode 403: unauthenticated + """ + return dict( + country=current_app.config.get('LEMUR_DEFAULT_COUNTRY'), + state=current_app.config.get('LEMUR_DEFAULT_STATE'), + location=current_app.config.get('LEMUR_DEFAULT_LOCATION'), + organization=current_app.config.get('LEMUR_DEFAULT_ORGANIZATION'), + organizationalUnit=current_app.config.get('LEMUR_DEFAULT_ORGANIZATIONAL_UNIT') + ) + +api.add_resource(LemurDefaults, '/defaults', endpoint='default') diff --git a/lemur/static/app/angular/app.js b/lemur/static/app/angular/app.js index fd620ffe..da9ce330 100644 --- a/lemur/static/app/angular/app.js +++ b/lemur/static/app/angular/app.js @@ -60,6 +60,15 @@ lemur.controller('datePickerController', function ($scope, $timeout){ }; }); +lemur.service('DefaultService', function (LemurRestangular) { + var DefaultService = this; + DefaultService.get = function () { + return LemurRestangular.all('defaults').customGET().then(function (defaults) { + return defaults; + }); + }; +}); + lemur.factory('LemurRestangular', function (Restangular, $location, $auth) { return Restangular.withConfig(function (RestangularConfigurer) { RestangularConfigurer.setBaseUrl('http://localhost:5000/api/1'); diff --git a/lemur/static/app/angular/authorities/authority/authority.js b/lemur/static/app/angular/authorities/authority/authority.js index 0fcd54b3..be8c4066 100644 --- a/lemur/static/app/angular/authorities/authority/authority.js +++ b/lemur/static/app/angular/authorities/authority/authority.js @@ -30,6 +30,9 @@ angular.module('lemur') .controller('AuthorityCreateController', function ($scope, $modalInstance, AuthorityService, LemurRestangular, RoleService, PluginService, WizardHandler) { $scope.authority = LemurRestangular.restangularizeElement(null, {}, 'authorities'); + // set the defaults + AuthorityService.getDefaults($scope.authority); + $scope.loading = false; $scope.create = function (authority) { WizardHandler.wizard().context.loading = true; diff --git a/lemur/static/app/angular/authorities/services.js b/lemur/static/app/angular/authorities/services.js index eefdbc8c..235b7ee7 100644 --- a/lemur/static/app/angular/authorities/services.js +++ b/lemur/static/app/angular/authorities/services.js @@ -56,7 +56,7 @@ angular.module('lemur') }); return LemurRestangular.all('authorities'); }) - .service('AuthorityService', function ($location, AuthorityApi, toaster) { + .service('AuthorityService', function ($location, AuthorityApi, DefaultService, toaster) { var AuthorityService = this; AuthorityService.findAuthorityByName = function (filterValue) { return AuthorityApi.getList({'filter[name]': filterValue}) @@ -117,6 +117,16 @@ angular.module('lemur') }); }; + AuthorityService.getDefaults = function (authority) { + return DefaultService.get().then(function (defaults) { + authority.caDN.country = defaults.country; + authority.caDN.state = defaults.state; + authority.caDN.location = defaults.location; + authority.caDN.organization = defaults.organization; + authority.caDN.organizationalUnit = defaults.organizationalUnit; + }); + }; + AuthorityService.getRoles = function (authority) { return authority.getList('roles').then(function (roles) { authority.roles = roles; diff --git a/lemur/static/app/angular/certificates/services.js b/lemur/static/app/angular/certificates/services.js index b421537c..fff61221 100644 --- a/lemur/static/app/angular/certificates/services.js +++ b/lemur/static/app/angular/certificates/services.js @@ -89,7 +89,7 @@ angular.module('lemur') }); return LemurRestangular.all('certificates'); }) - .service('CertificateService', function ($location, CertificateApi, LemurRestangular, toaster) { + .service('CertificateService', function ($location, CertificateApi, LemurRestangular, DefaultService, toaster) { var CertificateService = this; CertificateService.findCertificatesByName = function (filterValue) { return CertificateApi.getList({'filter[name]': filterValue}) @@ -207,7 +207,7 @@ angular.module('lemur') }; CertificateService.getDefaults = function (certificate) { - return certificate.customGET('defaults').then(function (defaults) { + return DefaultService.get().then(function (defaults) { certificate.country = defaults.country; certificate.state = defaults.state; certificate.location = defaults.location; diff --git a/lemur/status/views.py b/lemur/status/views.py deleted file mode 100644 index fddfdb69..00000000 --- a/lemur/status/views.py +++ /dev/null @@ -1,35 +0,0 @@ -""" -.. module: lemur.status.views - :copyright: (c) 2015 by Netflix Inc., see AUTHORS for more - :license: Apache, see LICENSE for more details. -""" -import os - -from flask import app, current_app, Blueprint, jsonify -from flask.ext.restful import Api - -from lemur.auth.service import AuthenticatedResource - - -mod = Blueprint('status', __name__) -api = Api(mod) - - -class Status(AuthenticatedResource): - """ Defines the 'accounts' endpoint """ - def __init__(self): - super(Status, self).__init__() - - def get(self): - if not os.path.isdir(os.path.join(app.config.get("KEY_PATH"), "decrypted")): - return jsonify({ - 'environment': app.config.get('ENVIRONMENT'), - 'status': 'degraded', - 'message': "This Lemur instance is in a degraded state and is unable to issue certificates, please alert {0}".format( - current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL') - )}) - else: - return jsonify({ - 'environment': app.config.get('ENVIRONMENT'), - 'status': 'healthy', - 'message': "This Lemur instance is healthy"}) From 0afd4c94b45942ecbd92d5a2992ad45b459075aa Mon Sep 17 00:00:00 2001 From: kevgliss Date: Fri, 4 Sep 2015 15:54:02 -0700 Subject: [PATCH 3/6] removing more netflix --- .../app/angular/certificates/certificate/tracking.tpl.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lemur/static/app/angular/certificates/certificate/tracking.tpl.html b/lemur/static/app/angular/certificates/certificate/tracking.tpl.html index 94fe81d9..11553ffe 100644 --- a/lemur/static/app/angular/certificates/certificate/tracking.tpl.html +++ b/lemur/static/app/angular/certificates/certificate/tracking.tpl.html @@ -6,7 +6,7 @@ Owner
- +

You must enter an Certificate owner

From 8ab9c06778408bf569a0e743bae8200893e695d2 Mon Sep 17 00:00:00 2001 From: kevgliss Date: Fri, 4 Sep 2015 15:54:52 -0700 Subject: [PATCH 4/6] removing more netflix --- .../app/angular/certificates/certificate/destinations.tpl.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lemur/static/app/angular/certificates/certificate/destinations.tpl.html b/lemur/static/app/angular/certificates/certificate/destinations.tpl.html index 9961a6f2..59cbe0b1 100644 --- a/lemur/static/app/angular/certificates/certificate/destinations.tpl.html +++ b/lemur/static/app/angular/certificates/certificate/destinations.tpl.html @@ -4,7 +4,7 @@
- Date: Mon, 7 Sep 2015 21:54:23 -0700 Subject: [PATCH 5/6] fixing setup.py --- setup.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 0e15ea76..fa1a844a 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ from distutils.core import Command from setuptools.command.develop import develop from setuptools.command.install import install from setuptools.command.sdist import sdist -from setuptools import setup +from setuptools import setup, find_packages from subprocess import check_output ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__))) @@ -110,11 +110,11 @@ class BuildStatic(Command): setup( name='lemur', - version='0.1', + version='0.1.3', author='Kevin Glisson', author_email='kglisson@netflix.com', long_description=open(os.path.join(ROOT, 'README.rst')).read(), - packages=['lemur'], + packages=find_packages(), include_package_data=True, zip_safe=False, install_requires=install_requires, @@ -127,7 +127,6 @@ setup( 'build_static': BuildStatic, 'sdist': SdistWithBuildStatic, 'install': SmartInstall - }, entry_points={ 'console_scripts': [ From 0383e2a1e104e8b7d6a8b2c803aab327fd45813f Mon Sep 17 00:00:00 2001 From: kevgliss Date: Mon, 7 Sep 2015 22:14:18 -0700 Subject: [PATCH 6/6] adding manifest --- MANIFEST.in | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..ec344cc4 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,4 @@ +include setup.py package.json bower.json gulpfile.js README.rst MANIFEST.in LICENSE AUTHORS +recursive-include lemur/plugins/lemur_email/templates * +recursive-include lemur/static * +global-exclude *~