| 1 | cscip-python python jupyterhub 5.2.1 `examples.read-only.jupyterhub_config`/c. = get_config() # noqa |
| 2 | |
| 3 | # define custom scopes so they can be assigned to users |
| 4 | # these could be |
| 5 | |
| 6 | cscip-python python jupyterhub 5.2.1 `examples.read-only.jupyterhub_config`/c..JupyterHub.custom_scopes = { |
| 7 | "custom:jupyter_server:read:*": { |
| 8 | "description": "read-only access to your server", |
| 9 | }, |
| 10 | "custom:jupyter_server:write:*": { |
| 11 | "description": "access to modify files on your server. Does not include execution.", |
| 12 | "subscopes": ["custom:jupyter_server:read:*"], |
| 13 | }, |
| 14 | "custom:jupyter_server:execute:*": { |
| 15 | "description": "Execute permissions on servers.", |
| 16 | "subscopes": [ |
| 17 | "custom:jupyter_server:write:*", |
| 18 | "custom:jupyter_server:read:*", |
| 19 | ], |
| 20 | }, |
| 21 | } |
| 22 | |
| 23 | cscip-python python jupyterhub 5.2.1 `examples.read-only.jupyterhub_config`/c..JupyterHub.load_roles = [ |
| 24 | # grant specific users read-only access to all servers |
| 25 | { |
| 26 | "name": "read-only-all", |
| 27 | "scopes": [ |
| 28 | "access:servers", |
| 29 | "custom:jupyter_server:read:*", |
| 30 | ], |
| 31 | "groups": ["read-only"], |
| 32 | }, |
| 33 | { |
| 34 | "name": "read-only-read-only-percy", |
| 35 | "scopes": [ |
| 36 | "access:servers!user=percy", |
| 37 | "custom:jupyter_server:read:*!user=percy", |
| 38 | ], |
| 39 | "users": ["vex"], |
| 40 | }, |
| 41 | { |
| 42 | "name": "admin-ui", |
| 43 | "scopes": [ |
| 44 | "admin-ui", |
| 45 | "list:users", |
| 46 | "admin:servers", |
| 47 | ], |
| 48 | "users": ["admin"], |
| 49 | }, |
| 50 | { |
| 51 | "name": "full-access", |
| 52 | "scopes": [ |
| 53 | "access:servers", |
| 54 | "custom:jupyter_server:execute:*", |
| 55 | ], |
| 56 | "users": ["minrk"], |
| 57 | }, |
| 58 | # all users have full access to their own servers |
| 59 | { |
| 60 | "name": "user", |
| 61 | "scopes": [ |
| 62 | "custom:jupyter_server:execute:*!user", |
| 63 | "custom:jupyter_server:read:*!user", |
| 64 | "self", |
| 65 | ], |
| 66 | }, |
| 67 | ] |
| 68 | |
| 69 | # servers request access to themselves |
| 70 | |
| 71 | cscip-python python jupyterhub 5.2.1 `examples.read-only.jupyterhub_config`/c..Spawner.oauth_client_allowed_scopes = [ |
| 72 | "access:servers!server", |
| 73 | "custom:jupyter_server:read:*!server", |
| 74 | "custom:jupyter_server:execute:*!server", |
| 75 | ] |
| 76 | |
| 77 | # enable the jupyter-server extension |
| 78 | cscip-python python jupyterhub 5.2.1 `examples.read-only.jupyterhub_config`/c..Spawner.environment = { |
| 79 | "JUPYTERHUB_SINGLEUSER_EXTENSION": "1", |
| 80 | } |
| 81 | |
| 82 | from pathlibscip-python python python-stdlib 3.11 pathlib/__init__: import Pathscip-python python python-stdlib 3.11 pathlib/Path# |
| 83 | |
| 84 | herescip-python python jupyterhub 5.2.1 `examples.read-only.jupyterhub_config`/here. = Pathscip-python python python-stdlib 3.11 pathlib/Path#(__file__scip-python python jupyterhub 5.2.1 `examples.read-only.jupyterhub_config`/).parentscip-python python python-stdlib 3.11 pathlib/PurePath#parent()..resolvescip-python python python-stdlib 3.11 pathlib/Path#resolve().() |
| 85 | |
| 86 | # load the server config that enables granular permissions |
| 87 | cscip-python python jupyterhub 5.2.1 `examples.read-only.jupyterhub_config`/c..Spawner.args = [ |
| 88 | f"--config={herescip-python python jupyterhub 5.2.1 `examples.read-only.jupyterhub_config`/here.}/jupyter_server_config.py", |
| 89 | ] |
| 90 | |
| 91 | |
| 92 | # example boilerplate: dummy auth/spawner |
| 93 | cscip-python python jupyterhub 5.2.1 `examples.read-only.jupyterhub_config`/c..JupyterHub.authenticator_class = 'dummy' |
| 94 | cscip-python python jupyterhub 5.2.1 `examples.read-only.jupyterhub_config`/c..JupyterHub.spawner_class = 'simple' |
| 95 | cscip-python python jupyterhub 5.2.1 `examples.read-only.jupyterhub_config`/c..JupyterHub.ip = '127.0.0.1' |