Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix custominstallerbuilder/issue#16 #173

Merged
merged 6 commits into from
Aug 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions website/context_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,18 @@ def customizable_strings(request):
"CLEARINGHOUSE_URL": settings.CLEARINGHOUSE_URL,
"DEMOKIT": settings.DEMOKIT,
}

def options(request):
""" If 'clearinghouse.website.context_processor.options'
is added to TEMPLATE_CONTEXT_PROCESSORS in settings.py the items of the
returned dict can be directly accessed in the template engine.
Currently we only make the boolean DEBUG setting available."""

from django.conf import settings
return {
# A debug variable is available to the templates via django's built-in
# 'django.core.context_processors.debug', but only if the request's
# IP address is listed in the INTERNAL_IPS setting, c.f.:
# https://docs.djangoproject.com/en/1.9/ref/templates/api/#django-template-context-processors-debug
"DEBUG" : settings.DEBUG,
}
3 changes: 3 additions & 0 deletions website/html/templates/common/debug_warning.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="warning">
WARNING: you are in DEBUG mode. Change settings.DEBUG to False in production!
</div>
3 changes: 3 additions & 0 deletions website/html/templates/common/geni_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
</head>

<body>
{% if DEBUG %}
{% include "common/debug_warning.html" %}
{% endif %}
{% block header %}
<div id="header">
<span id="logo"><a href="{% url 'profile' %}">{{ TESTBED }} {{ CLEARINGHOUSE }}</a></span>
Expand Down
13 changes: 12 additions & 1 deletion website/html/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import shutil
import subprocess
import xmlrpclib
import ssl

# Needed to escape characters for the Android referrer...
import urllib
Expand Down Expand Up @@ -1112,7 +1113,17 @@ def _build_installer(username, platform):
return False, error_response

try:
xmlrpc_proxy = xmlrpclib.ServerProxy(settings.SEATTLECLEARINGHOUSE_INSTALLER_BUILDER_XMLRPC)
# Per default this setting is True in DEBUG mode.
# Passing an unverified ssl context allows the Custom Installer Builder
# to use self-signed server certificates.
# c.f. https://github.com/SeattleTestbed/custominstallerbuilder/issues/16
if settings.UNVERIFIED_SSL_CONTEXT:
xmlrpc_proxy = xmlrpclib.ServerProxy(
settings.SEATTLECLEARINGHOUSE_INSTALLER_BUILDER_XMLRPC,
context=ssl._create_unverified_context())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this function only available in Python version 2.7+? What if a user is using version <2.7? Should there be checks for Python versions in the code, or some kind of disclaimer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK we agreed that we don't care for Python <2.7 to run clearinghouse (c.f. discussion in SeattleTestbed/custominstallerbuilder#16).

As for the disclaimer, our main instruction to run the clearinghouse already suggests to use Python 2.7

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python 2.6 is plainly unsupported for running a clearinghouse as of the docs change.

else:
xmlrpc_proxy = xmlrpclib.ServerProxy(
settings.SEATTLECLEARINGHOUSE_INSTALLER_BUILDER_XMLRPC)

vessel_list = [{'percentage': 80, 'owner': 'owner', 'users': ['user']}]

Expand Down
9 changes: 9 additions & 0 deletions website/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@
SEATTLECLEARINGHOUSE_INSTALLER_BUILDER_XMLRPC = "https://custombuilder.poly.edu/custom_install/xmlrpc/" # Default, currently no repy_v2 support
#SEATTLECLEARINGHOUSE_INSTALLER_BUILDER_XMLRPC = "https://sensibilityclearinghouse.poly.edu/custominstallerbuilder/xmlrpc/" # SensibilityTestbed's CIB, which supports repy_v2 and thereby NAT traversal.

# In Python 2.7.9+ a HTTPS request to a server using a self-signed certificate
# will raise an exception.
# If set to `True` the SSL context is not verified for HTTPS XMLRPC requests
# and therefore allows the use of self-signed certificates.
# c.f. https://github.com/SeattleTestbed/custominstallerbuilder/issues/16
# NOTE: Don't set to `True` in production!
UNVERIFIED_SSL_CONTEXT = DEBUG

# Not currently used. This is left in for legacy installs
# The directory where the base installers named seattle_linux.tgz, seattle_mac.tgz,
# and seattle_win.zip are located.
Expand Down Expand Up @@ -250,6 +258,7 @@
'social_auth.context_processors.social_auth_by_type_backends',
# Add context processor for TESTBED etc. tags; configure these below.
'clearinghouse.website.context_processor.customizable_strings',
'clearinghouse.website.context_processor.options',
)
# Social_auth follows each of these in order and passes along a object with
# information gathered to each function.
Expand Down