Merge pull request #2818 from erasche/rstudio-1610

Return of RStudio
This commit is contained in:
Martin Cech
2016-11-16 16:01:12 -05:00
committed by GitHub
3 changed files with 35 additions and 67 deletions
@@ -6,7 +6,7 @@
# appropriate `apt-get/pip install` statements.
---
-
image: erasche/docker-rstudio-notebook:15.10
image: erasche/docker-rstudio-notebook:16.10
description: |
If you've ever done R analysis, you probably used RStudio. This
familiar R analysis software suite will let you explore your datasets
@@ -1,15 +1,7 @@
function message_failed_auth(password){
toastr.info(
"Automatic authorization failed. You can manually login with:<br>" + password + "<br> <a href='https://github.com/bgruening/galaxy-ipython/wiki/Automatic-Authorization-Failed' target='_blank'>More details ...</a>",
"Please login manually",
{'closeButton': true, 'timeOut': 100000, 'tapToDismiss': false}
);
}
function message_failed_connection(){
toastr.error(
"Could not connect to IPython Notebook. Please contact your administrator. <a href='https://github.com/bgruening/galaxy-ipython/wiki/Could-not-connect-to-IPython-Notebook' target='_blank'>More details ...</a>",
"Security warning",
"Could not connect to RStudio. Please contact your administrator.",
"Security warning",
{'closeButton': true, 'timeOut': 20000, 'tapToDismiss': true}
);
}
@@ -45,62 +37,36 @@ function load_notebook(notebook_login_url, notebook_access_url, notebook_pubkey_
var enc_hex = rsa.encrypt(payload);
var encrypted = hex2b64(enc_hex);
console.log("E: " + encrypted);
_handle_notebook_loading(encrypted, notebook_login_url, notebook_access_url);
// Now we can login
$.ajax({
type: "POST",
// to the Login URL
url: notebook_login_url,
// With our password
data: {
'v': encrypted,
'persist': 1,
'clientPath': '/rstudio/auth-sign-in',
'appUri': '',
},
contentType: "application/x-www-form-urlencoded",
xhrFields: {
withCredentials: true
},
// If that is successful, load the notebook
success: function(){
append_notebook(notebook_access_url);
},
error: function(jqxhr, status, error){
message_failed_connection();
// Do we want to try and load the notebook anyway? Just in case?
append_notebook(notebook_access_url);
}
});
}
});
});
});
}
/**
* Must be implemented by IEs
*/
function _handle_notebook_loading(password, notebook_login_url, notebook_access_url){
if ( ie_password_auth ) {
$.ajax({
type: "POST",
// to the Login URL
url: notebook_login_url,
// With our password
data: {
'v': password,
'persist': 1,
'clientPath': '/rstudio/auth-sign-in',
'appUri': '',
},
contentType: "application/x-www-form-urlencoded",
xhrFields: {
withCredentials: true
},
// If that is successful, load the notebook
success: function(){
append_notebook(notebook_access_url);
},
error: function(jqxhr, status, error){
if(ie_password_auth){
// Failure now happens because the redirect that RStudio gives us includes the
// port internal to nginx. (E.g. localhost:NNNN/rstudio/NNNN/)
// so disabling the message here makes sense as long as it's working correctly
//
// Additionally:
// XMLHttpRequest cannot load http://localhost:46725/rstudio/46725/. The
// 'Access-Control-Allow-Origin' header has a value 'http://localhost:8081' that
// is not equal to the supplied origin. Origin 'null' is therefore not allowed
// access.
// message_failed_auth(ie_password);
append_notebook(notebook_access_url);
}else{
message_failed_connection();
// Do we want to try and load the notebook anyway? Just in case?
append_notebook(notebook_access_url);
}
}
});
}
else {
// Not using password auth, just embed it to avoid content-origin issues.
message_no_auth();
append_notebook(notebook_access_url);
}
}
@@ -9,8 +9,10 @@ ie_request.load_deploy_config()
ie_request.attr.docker_port = 80
# Create tempdir in galaxy
temp_dir = ie_request.temp_dir
PASSWORD = ie_request.notebook_pw
USERNAME = "galaxy"
PASSWORD = "rstudio"
USERNAME = "rstudio"
# Then override it again
ie_request.notebook_pw = "rstudio"
# Did the user give us an RData file?
if hda.datatype.__class__.__name__ == "RData":
@@ -31,7 +33,7 @@ ie_request.launch(
# through proxy.
notebook_pubkey_url = ie_request.url_template('${PROXY_URL}/rstudio/auth-public-key')
notebook_access_url = ie_request.url_template('${PROXY_URL}/rstudio/')
notebook_login_url = ie_request.url_template('${PROXY_URL}/rstudio/auth-do-sign-in')
notebook_login_url = ie_request.url_template('${PROXY_URL}/rstudio/auth-sign-in')
%>
<html>