I am working on a containerized JupyterHub based on https://opendreamkit.org/2018/10/17/jupyterhub-docker project. I have put it in a EC2 and all work fine: all my users have a private storage and shared storage to share its notebook.
Now i need to add new users and they need to see only a little part of the shared space. Then, I would like this configuration:
/shared/new_space/ >>> New users & Old users
/shared/ >>> Only old users
I am thinking to "play" with the the DockerSpawner but i don't have any idea how to do this. I can put a new directory into the
c.DockerSpawner.volumes = {
'jupyterhub-user-{username}': notebook_dir,
'/home/ubuntu/efs-disk/data-shared': '/home/jovyan/shared'
'/home/ubuntu/efs-disk/data-shared/NEW_SPACE': '/home/jovyan/shared/NEW_SPACE' #Need to try
}
but how can i do the users's permissions? Which component manages user permissions? Do you have any suggestion for completing my task?
Thanks in advance, regards.
After a big search in the Web i find a solution here: Then i modify my jupyterhub_config.py as:
import os
from dockerspawner import DockerSpawner
class MyDockerSpawner(DockerSpawner):
# Questa è la lista di Utenti che non vedranno la cartella sharedm ma solo la shared_notebooks
denied_team = ['test1','test2','test3']
def start(self):
if self.user.name in self.denied_team:
self.volumes['jupyterhub-user-{username}'] = {'bind': '/home/jovyan' , 'mode': 'rw'}
self.volumes['/home/ubuntu/efs-disk/shared_notebooks'] = {'bind': '/home/jovyan/shared_notebooks', 'mode': 'rw'}
else:
self.volumes['jupyterhub-user-{username}'] = {'bind': '/home/jovyan' , 'mode': 'rw'}
self.volumes['/home/ubuntu/efs-disk/data_shared'] = {'bind': '/home/jovyan/shared', 'mode': 'rw'}
self.volumes['/home/ubuntu/efs-disk/shared_notebooks'] = {'bind': '/home/jovyan/shared_notebooks', 'mode': 'rw'}
return super().start()
c.JupyterHub.spawner_class = MyDockerSpawner
c.JupyterHub.<OTHER-SETTINGS>
I would like to put the "denied_team" in a better position but for now I will not move it.
Regards