2015-09-05 00:52:56 +02:00
|
|
|
"""
|
|
|
|
.. 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
|
2016-11-23 06:11:20 +01:00
|
|
|
from flask_restful import Api
|
2015-09-05 00:52:56 +02:00
|
|
|
|
2016-12-02 00:42:03 +01:00
|
|
|
from lemur.common.schema import validate_schema
|
|
|
|
from lemur.authorities.service import get_by_name
|
2015-09-05 00:52:56 +02:00
|
|
|
from lemur.auth.service import AuthenticatedResource
|
|
|
|
|
2016-12-02 00:42:03 +01:00
|
|
|
from lemur.defaults.schemas import default_output_schema
|
|
|
|
|
2015-09-05 00:52:56 +02:00
|
|
|
|
|
|
|
mod = Blueprint('default', __name__)
|
|
|
|
api = Api(mod)
|
|
|
|
|
|
|
|
|
|
|
|
class LemurDefaults(AuthenticatedResource):
|
|
|
|
""" Defines the 'defaults' endpoint """
|
|
|
|
def __init__(self):
|
|
|
|
super(LemurDefaults)
|
|
|
|
|
2016-12-02 00:42:03 +01:00
|
|
|
@validate_schema(None, default_output_schema)
|
2015-09-05 00:52:56 +02:00
|
|
|
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
|
|
|
|
"""
|
2016-12-02 00:42:03 +01:00
|
|
|
|
|
|
|
default_authority = get_by_name(current_app.config.get('LEMUR_DEFAULT_AUTHORITY'))
|
|
|
|
|
2015-09-05 00:52:56 +02:00
|
|
|
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'),
|
2016-12-02 18:54:16 +01:00
|
|
|
organizational_unit=current_app.config.get('LEMUR_DEFAULT_ORGANIZATIONAL_UNIT'),
|
|
|
|
issuer_plugin=current_app.config.get('LEMUR_DEFAULT_ISSUER_PLUGIN'),
|
2016-12-02 00:42:03 +01:00
|
|
|
authority=default_authority
|
2015-09-05 00:52:56 +02:00
|
|
|
)
|
|
|
|
|
2016-11-21 23:29:20 +01:00
|
|
|
|
2015-09-05 00:52:56 +02:00
|
|
|
api.add_resource(LemurDefaults, '/defaults', endpoint='default')
|