@@ -29,6 +29,18 @@ def get_icon_path():
2929 os .path .dirname (os .path .abspath (__file__ )), 'icons' , 'rstudio.svg'
3030 )
3131
32+ def rewrite_auth (response , request ):
33+ '''
34+ As of rstudio-server 1.4ish, it would send the client to /auth-sign-in
35+ rather than what the client sees as the full URL followed by
36+ /auth-sign-in. See rstudio/rstudio#8888. We rewrite the response by
37+ sending the client to the right place.
38+ '''
39+ for header , v in response .headers .get_all ():
40+ if header == "Location" and v .startswith ("/auth-sign-in" ):
41+ # Visit the correct page
42+ response .headers [header ] = request .uri + v
43+
3244def setup_rserver ():
3345 def _get_env (port ):
3446 return dict (USER = getpass .getuser ())
@@ -65,29 +77,21 @@ def _get_cmd(port):
6577 '--www-verify-user-agent=0' ,
6678 '--secure-cookie-key-file=' + ntf .name ,
6779 '--server-user=' + getpass .getuser (),
80+ '--www-root-path={base_url}rstudio/' ,
81+ f'--database-config-file={ db_config ()} '
6882 ]
6983
70- # Add additional options for RStudio >= 1.4.x. Since we cannot
71- # determine rserver's version from the executable, we must use
72- # explicit configuration. In this case the environment variable
73- # RSESSION_PROXY_RSTUDIO_1_4 must be set.
74- if os .environ .get ('RSESSION_PROXY_RSTUDIO_1_4' , False ):
75- # base_url has a trailing slash
76- cmd .append ('--www-root-path={base_url}rstudio/' )
77- cmd .append (f'--database-config-file={ db_config ()} ' )
78-
7984 return cmd
8085
8186 server_process = {
8287 'command' : _get_cmd ,
8388 'environment' : _get_env ,
89+ 'rewrite_response' : rewrite_auth ,
8490 'launcher_entry' : {
8591 'title' : 'RStudio' ,
8692 'icon_path' : get_icon_path ()
8793 }
8894 }
89- if os .environ .get ('RSESSION_PROXY_RSTUDIO_1_4' , False ):
90- server_process ['launcher_entry' ]['path_info' ] = 'rstudio/auth-sign-in?appUrl=%2F'
9195 return server_process
9296
9397def setup_rsession ():
0 commit comments