mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-15 22:13:00 +00:00
Pass in base_url rather than app object
- Limits what we consider public API - Still allows for redirects outside JupyterHub
This commit is contained in:
@@ -1269,7 +1269,8 @@ class JupyterHub(Application):
|
||||
2. request - A Tornado HTTPServerRequest object representing the
|
||||
current request.
|
||||
3. user - The currently authenticated user.
|
||||
4. app - The JupyterHub object
|
||||
4. base_url - The base_url of the current hub, to allow for relative
|
||||
redirects
|
||||
|
||||
It should return the new URL to redirect to, or None to preserve
|
||||
current behavior.
|
||||
|
@@ -1490,7 +1490,7 @@ class UserRedirectHandler(BaseHandler):
|
||||
if self.app.user_redirect_hook:
|
||||
url = await maybe_future(
|
||||
self.app.user_redirect_hook(
|
||||
path, self.request, self.current_user, self.app
|
||||
path, self.request, self.current_user, self.base_url
|
||||
)
|
||||
)
|
||||
if url is None:
|
||||
|
@@ -406,11 +406,11 @@ async def test_user_redirect_hook(app, username):
|
||||
name = username
|
||||
cookies = await app.login_user(name)
|
||||
|
||||
async def dummy_redirect(path, request, user, passed_app):
|
||||
assert passed_app == app
|
||||
async def dummy_redirect(path, request, user, base_url):
|
||||
assert base_url == app.base_url
|
||||
assert path == 'redirect-to-terminal'
|
||||
assert request.uri == ujoin(
|
||||
app.hub.base_url, 'user-redirect', 'redirect-to-terminal'
|
||||
base_url, 'hub', 'user-redirect', 'redirect-to-terminal'
|
||||
)
|
||||
url = ujoin(user.url, '/terminals/1')
|
||||
return url
|
||||
|
Reference in New Issue
Block a user