mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-07 10:04:07 +00:00
forward-port 4.1.0
This commit is contained in:
@@ -289,6 +289,8 @@ linkcheck_ignore = [
|
||||
"https://github.com/jupyterhub/jupyterhub/compare/", # too many comparisons in changelog
|
||||
r"https?://(localhost|127.0.0.1).*", # ignore localhost references in auto-links
|
||||
r"https://linux.die.net/.*", # linux.die.net seems to block requests from CI with 403 sometimes
|
||||
# don't check links to unpublished advisories
|
||||
r"https://github.com/jupyterhub/jupyterhub/security/advisories/.*",
|
||||
]
|
||||
linkcheck_anchors_ignore = [
|
||||
"/#!",
|
||||
|
@@ -1203,6 +1203,7 @@ class HubOAuth(HubAuth):
|
||||
for cookie_name, cookie in handler.request.cookies.items():
|
||||
if cookie_name.startswith(self.state_cookie_name):
|
||||
self._clear_cookie(
|
||||
handler,
|
||||
cookie_name,
|
||||
path=self.cookie_path,
|
||||
)
|
||||
|
@@ -86,17 +86,9 @@ async def test_hubauth_token(app, mockservice_url, create_user_with_scopes):
|
||||
sub_reply = {key: reply.get(key, 'missing') for key in ['name', 'admin']}
|
||||
assert sub_reply == {'name': u.name, 'admin': False}
|
||||
|
||||
# token in ?token parameter
|
||||
# token in ?token parameter is not allowed by default
|
||||
r = await async_requests.get(
|
||||
public_url(app, mockservice_url) + '/whoami/?token=%s' % token
|
||||
)
|
||||
r.raise_for_status()
|
||||
reply = r.json()
|
||||
sub_reply = {key: reply.get(key, 'missing') for key in ['name', 'admin']}
|
||||
assert sub_reply == {'name': u.name, 'admin': False}
|
||||
|
||||
r = await async_requests.get(
|
||||
public_url(app, mockservice_url) + '/whoami/?token=no-such-token',
|
||||
public_url(app, mockservice_url) + '/whoami/?token=%s' % token,
|
||||
allow_redirects=False,
|
||||
)
|
||||
assert r.status_code == 302
|
||||
@@ -180,21 +172,9 @@ async def test_hubauth_service_token(request, app, mockservice_url, scopes, allo
|
||||
else:
|
||||
assert r.status_code == 403
|
||||
|
||||
# token in ?token parameter
|
||||
# token in ?token parameter is not allowed by default
|
||||
r = await async_requests.get(
|
||||
public_url(app, mockservice_url) + 'whoami/?token=%s' % token
|
||||
)
|
||||
if allowed:
|
||||
r.raise_for_status()
|
||||
assert r.status_code == 200
|
||||
reply = r.json()
|
||||
assert service_model.items() <= reply.items()
|
||||
assert not r.cookies
|
||||
else:
|
||||
assert r.status_code == 403
|
||||
|
||||
r = await async_requests.get(
|
||||
public_url(app, mockservice_url) + 'whoami/?token=no-such-token',
|
||||
public_url(app, mockservice_url) + 'whoami/?token=%s' % token,
|
||||
allow_redirects=False,
|
||||
)
|
||||
assert r.status_code == 302
|
||||
@@ -385,22 +365,14 @@ async def test_oauth_service_roles(
|
||||
|
||||
# token-authenticated request to HubOAuth
|
||||
token = app.users[name].new_api_token()
|
||||
# token in ?token parameter
|
||||
r = await async_requests.get(url_concat(url, {'token': token}), headers=s.headers)
|
||||
s.headers["Authorization"] = f"Bearer {token}"
|
||||
r = await async_requests.get(url, headers=s.headers)
|
||||
r.raise_for_status()
|
||||
reply = r.json()
|
||||
assert reply['name'] == name
|
||||
|
||||
# verify that ?token= requests set a cookie
|
||||
assert len(r.cookies) != 0
|
||||
# ensure cookie works in future requests
|
||||
r = await async_requests.get(
|
||||
url, cookies=r.cookies, allow_redirects=False, headers=s.headers
|
||||
)
|
||||
r.raise_for_status()
|
||||
assert r.url == url
|
||||
reply = r.json()
|
||||
assert reply['name'] == name
|
||||
# tokens in headers don't set cookies
|
||||
assert len(r.cookies) == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
@@ -394,7 +394,7 @@ async def test_nbclassic_control_panel(app, user, full_spawn):
|
||||
async def test_token_url_cookie(app, user, full_spawn, accept_token_in_url):
|
||||
if accept_token_in_url:
|
||||
user.spawner.environment["JUPYTERHUB_ALLOW_TOKEN_IN_URL"] = accept_token_in_url
|
||||
should_accept = accept_token_in_url != "0"
|
||||
should_accept = accept_token_in_url == "1"
|
||||
|
||||
await user.spawn()
|
||||
await app.proxy.add_user(user)
|
||||
|
Reference in New Issue
Block a user