mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-12 12:33:02 +00:00
esnure activity permissions are present in server tokens
with a warning avoids case where custom server token permissions remove necessary permissions for posting activity updates
This commit is contained in:
@@ -374,13 +374,13 @@ async def test_spawner_bad_api_token(app):
|
||||
(["self"], [], ["access:servers!server=USER/", "users:activity!user"]),
|
||||
(
|
||||
["self"],
|
||||
["admin:groups", "users:activity!server"],
|
||||
["users:activity!server=USER/"],
|
||||
["admin:groups", "read:servers!server"],
|
||||
["users:activity!user", "read:servers!server=USER/"],
|
||||
),
|
||||
(
|
||||
["self", "read:groups!group=x"],
|
||||
["admin:groups", "users:activity!user"],
|
||||
["read:groups!group=x", "read:groups:name!group=x", "users:activity!user"],
|
||||
["self", "read:groups!group=x", "users:activity"],
|
||||
["admin:groups", "users:activity"],
|
||||
["read:groups!group=x", "read:groups:name!group=x", "users:activity"],
|
||||
),
|
||||
],
|
||||
)
|
||||
|
@@ -693,6 +693,16 @@ class User:
|
||||
scope + server_filter if scope.endswith("!server") else scope
|
||||
for scope in requested_scopes
|
||||
}
|
||||
# ensure activity scope is requested, since activity doesn't work without
|
||||
activity_scope = "users:activity!user"
|
||||
if not {activity_scope, "users:activity", "inherit"}.intersection(
|
||||
requested_scopes
|
||||
):
|
||||
self.log.warning(
|
||||
f"Adding required scope {activity_scope} to server token, missing from Spawner.server_token_scopes. Please make sure to add it!"
|
||||
)
|
||||
requested_scopes |= {activity_scope}
|
||||
|
||||
have_scopes = roles.roles_to_scopes(roles.get_roles_for(self.orm_user))
|
||||
have_scopes |= {"inherit"}
|
||||
jupyterhub_client = (
|
||||
|
Reference in New Issue
Block a user