diff --git a/config/plugins/interactive_environments/ipython/templates/ipython.mako b/config/plugins/interactive_environments/ipython/templates/ipython.mako index 9772e187e26..a0a3b1e7059 100644 --- a/config/plugins/interactive_environments/ipython/templates/ipython.mako +++ b/config/plugins/interactive_environments/ipython/templates/ipython.mako @@ -3,6 +3,7 @@ <% import os import shutil +import hashlib # Sets ID and sets up a lot of other variables ie_request.load_deploy_config() @@ -10,6 +11,13 @@ ie_request.attr.docker_port = 6789 # Create tempdir in galaxy temp_dir = ie_request.temp_dir +if ie_request.attr.PASSWORD_AUTH: + m = hashlib.sha1() + m.update( ie_request.notebook_pw + ie_request.notebook_pw_salt ) + PASSWORD = 'sha1:%s:%s' % (ie_request.notebook_pw_salt, m.hexdigest()) +else: + PASSWORD = "none" + ## IPython Specific # Prepare an empty notebook notebook_id = ie_request.generate_hex(64) @@ -32,7 +40,9 @@ notebook_login_url = ie_request.url_template('${PROXY_URL}/ipython/${PORT}/login # Add all environment variables collected from Galaxy's IE infrastructure -ie_request.launch() +ie_request.launch(env_override={ + 'notebook_password': PASSWORD, +}) %> diff --git a/lib/galaxy/web/base/interactive_environments.py b/lib/galaxy/web/base/interactive_environments.py index 4504e6f6287..12a3e46b633 100644 --- a/lib/galaxy/web/base/interactive_environments.py +++ b/lib/galaxy/web/base/interactive_environments.py @@ -1,6 +1,5 @@ import ConfigParser -import hashlib import os import random import tempfile @@ -41,6 +40,8 @@ class InteractiveEnviornmentRequest(object): self.attr.HOST = trans.request.host.rsplit(':', 1)[0] self.attr.PORT = self.attr.proxy_request[ 'proxied_port' ] + # Generate per-request passwords the IE plugin can use to configure + # the destination container. self.notebook_pw_salt = self.generate_password(length=12) self.notebook_pw = self.generate_password(length=24) @@ -100,16 +101,6 @@ class InteractiveEnviornmentRequest(object): # Galaxy paster port is deprecated conf_file['galaxy_paster_port'] = conf_file['galaxy_web_port'] - if self.attr.PASSWORD_AUTH: - # Generate a random password + salt - m = hashlib.sha1() - m.update( self.notebook_pw + self.notebook_pw_salt ) - conf_file['notebook_password'] = 'sha1:%s:%s' % (self.notebook_pw_salt, m.hexdigest()) - # Should we use password based connection or "default" connection style in galaxy - else: - notebook_pw = "None" - - self.attr.notebook_pw = notebook_pw return conf_file def generate_hex(self, length):