From f676d1eeeb1dbd7073b0a090bf22e0ec5fe950d7 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Thu, 22 Jan 2015 15:43:20 -0500 Subject: [PATCH] Add EULA and EULA acceptance on the config endpoint --- awx/api/templates/api/api_v1_config_view.md | 4 +++- awx/api/templates/eula.md | 20 ++++++++++++++++++++ awx/api/views.py | 7 +++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 awx/api/templates/eula.md diff --git a/awx/api/templates/api/api_v1_config_view.md b/awx/api/templates/api/api_v1_config_view.md index 61eb1a5ae1..21f8581bb5 100644 --- a/awx/api/templates/api/api_v1_config_view.md +++ b/awx/api/templates/api/api_v1_config_view.md @@ -10,7 +10,9 @@ the following fields (some fields may not be visible to all users): * `time_zone`: The configured time zone for the server. * `license_info`: Information about the current license. * `version`: Version of Ansible Tower package installed. +* `eula`: The current End-User License Agreement (_New in Ansible Tower 2.0.0_) Make a POST request to this resource as a super user to install or update the existing license. The license data itself can -be POSTed as a normal json data structure. +be POSTed as a normal json data structure. The POST must include a `eula_accepted` +boolean element indicating acceptance of the End-User License Agreement. diff --git a/awx/api/templates/eula.md b/awx/api/templates/eula.md new file mode 100644 index 0000000000..02a884eef2 --- /dev/null +++ b/awx/api/templates/eula.md @@ -0,0 +1,20 @@ +TOWER SOFTWARE END USER LICENSE AGREEMENT + +Unless otherwise agreed to, and executed in a definitive agreement, between +Ansible, Inc. (“Ansible”) and the individual or entity (“Customer”) signing or +electronically accepting these terms of use for the Tower Software (“EULA”), +all Tower Software, including any and all versions released or made available +by Ansible, shall be subject to the Ansible Software Subscription and Services +Agreement found at www.ansible.com/subscription-agreement (“Agreement”). +Ansible is not responsible for any additional obligations, conditions or +warranties agreed to between Customer and an authorized distributor, or +reseller, of the Tower Software. BY DOWNLOADING AND USING THE TOWER SOFTWARE, +OR BY CLICKING ON THE “YES” BUTTON OR OTHER BUTTON OR MECHANISM DESIGNED TO +ACKNOWLEDGE CONSENT TO THE TERMS OF AN ELECTRONIC COPY OF THIS EULA, THE +CUSTOMER HEREBY ACKNOWLEDGES THAT CUSTOMER HAS READ, UNDERSTOOD, AND AGREES TO +BE BOUND BY THE TERMS OF THIS EULA AND AGREEMENT, INCLUDING ALL TERMS +INCORPORATED HEREIN BY REFERENCE, AND THAT THIS EULA AND AGREEMENT IS +EQUIVALENT TO ANY WRITTEN NEGOTIATED AGREEMENT BETWEEN CUSTOMER AND ANSIBLE. +THIS EULA AND AGREEMENT IS ENFORCEABLE AGAINST ANY PERSON OR ENTITY THAT USES +OR AVAILS ITSELF OF THE TOWER SOFTWARE OR ANY PERSON OR ENTITY THAT USES THE OR +AVAILS ITSELF OF THE TOWER SOFTWARE ON ANOTHER PERSON’S OR ENTITY’S BEHALF. diff --git a/awx/api/views.py b/awx/api/views.py index 10746c8c37..86c4d9efc8 100644 --- a/awx/api/views.py +++ b/awx/api/views.py @@ -23,6 +23,7 @@ from django.utils.datastructures import SortedDict from django.utils.safestring import mark_safe from django.utils.timezone import now from django.views.decorators.csrf import csrf_exempt +from django.template.loader import render_to_string # Django REST Framework from rest_framework.authtoken.views import ObtainAuthToken @@ -183,6 +184,7 @@ class ApiV1ConfigView(APIView): license_info=license_data, version=get_awx_version(), ansible_version=get_ansible_version(), + eula=render_to_string("eula.md"), ) # If LDAP is enabled, user_ldap_fields will return a list of field @@ -205,6 +207,11 @@ class ApiV1ConfigView(APIView): def post(self, request): if not request.user.is_superuser: return Response(None, status=status.HTTP_404_NOT_FOUND) + if "eula_accepted" not in request.DATA: + return Response({"error": "Missing 'eula_accepted' property"}, status=status.HTTP_400_BAD_REQUEST) + if not request.DATA["eula_accepted"]: + return Response({"error": "'eula_accepted' must be True"}, status=status.HTTP_400_BAD_REQUEST) + request.DATA.pop("eula_accepted") try: data_actual = json.dumps(request.DATA) except Exception, e: