Skip to content

Commit 745d6b7

Browse files
committed
Rewrite /auth-sign-in header.
1 parent 3ce3ae4 commit 745d6b7

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

jupyter_rsession_proxy/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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, orig_response, host, port, path):
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+
3244
def setup_rserver():
3345
def _get_env(port):
3446
return dict(USER=getpass.getuser())
@@ -74,6 +86,7 @@ def _get_cmd(port):
7486
server_process = {
7587
'command': _get_cmd,
7688
'environment': _get_env,
89+
'rewrite_response': rewrite_auth,
7790
'launcher_entry': {
7891
'title': 'RStudio',
7992
'icon_path': get_icon_path()

0 commit comments

Comments
 (0)