Hi,
I’m currently trying to implement real-time collaboration without impersonation, but using a custom authenticator that supports authenticator-managed roles. My strategy is as follows:
- Each collaboration gets it’s own “collaboration account”
- The authenticator assigns each real user a “collaboration role”
- The collaboration role grants server access to the collaboration account
Unlike in the RTC example linked above, no “collaboration groups” are used.
I’ve implemented my own authenticator as follows (irrelevant code removed):
class MyOAuthenticator(OAuthenticator):
manage_roles = True
reset_managed_roles_on_startup = True
...
async def update_auth_model(self, auth_model):
auth_model = await super().update_auth_model(auth_model)
user_collabs = self._get_collabs(username=auth_model["name"])
# self._create_collabs(user_collabs) # TODO create collaboration accounts
auth_model["roles"] = self._get_collab_roles(user_collabs)
return auth_model
async def load_managed_roles(self):
collabs = self._get_collabs()
return self._get_collab_roles(collabs)
def _get_collabs(self, username=None):
... # return all/user-specific collaboration accounts
def _get_collab_roles(self, collabs):
return [
{
"name": collab,
"scopes": [
"admin-ui",
f"list:users!user={collab}",
f"admin:servers!user={collab}",
f"access:servers!user={collab}",
],
}
for collab in collabs
]
If I understand correctly, the authenticator doesn’t automatically create non-existing collaboration accounts that are specified in "scopes"
, and I will therefore have to explicitly create these accounts during authentication. How could I best implement _create_collabs(self, collabs: list[str]) -> None
to do this (authenticator methods, REST API calls, ORM functionality, …)?
For reference, I’m deploying the JupyterHub Helm chart 4.1.0 (JupyterHub 5.2.1) on a K3s cluster behind a Traefik reverse proxy.
Thanks in advance!