| 1 | import osscip-python python python-stdlib 3.11 os/__init__: |
| 2 | import warningsscip-python python python-stdlib 3.11 warnings/__init__: |
| 3 | |
| 4 | # When Swagger performs OAuth2 in the browser, it will set |
| 5 | # the request host + relative path as the redirect uri, causing a |
| 6 | # uri mismatch if the oauth_redirect_uri is just the relative path |
| 7 | # is set in the c.JupyterHub.services entry (as per default). |
| 8 | # Therefore need to know the request host ahead of time. |
| 9 | if "PUBLIC_HOST" not in osscip-python python python-stdlib 3.11 os/__init__:.environscip-python python python-stdlib 3.11 os/environ.environ.: |
| 10 | msgscip-python python jupyterhub 5.2.1 `examples.service-fastapi.jupyterhub_config`/msg. = ( |
| 11 | "env PUBLIC_HOST is not set, defaulting to http://127.0.0.1:8000. " |
| 12 | "This can cause problems with OAuth. " |
| 13 | "Set PUBLIC_HOST to your public (browser accessible) host." |
| 14 | ) |
| 15 | warningsscip-python python python-stdlib 3.11 warnings/__init__:.warnscip-python python python-stdlib 3.11 _warnings/warn().(msgscip-python python jupyterhub 5.2.1 `examples.service-fastapi.jupyterhub_config`/msg.) |
| 16 | public_hostscip-python python jupyterhub 5.2.1 `examples.service-fastapi.jupyterhub_config`/public_host. = "http://127.0.0.1:8000" |
| 17 | else: |
| 18 | public_hostscip-python python jupyterhub 5.2.1 `examples.service-fastapi.jupyterhub_config`/public_host. = osscip-python python python-stdlib 3.11 os/__init__:.environscip-python python python-stdlib 3.11 os/environ.environ.["PUBLIC_HOST"].rstripscip-python python python-stdlib 3.11 builtins/str#rstrip().('/') |
| 19 | service_namescip-python python jupyterhub 5.2.1 `examples.service-fastapi.jupyterhub_config`/service_name. = "fastapi" |
| 20 | oauth_redirect_uriscip-python python jupyterhub 5.2.1 `examples.service-fastapi.jupyterhub_config`/oauth_redirect_uri. = f"{public_hostscip-python python jupyterhub 5.2.1 `examples.service-fastapi.jupyterhub_config`/public_host.}/services/{service_namescip-python python jupyterhub 5.2.1 `examples.service-fastapi.jupyterhub_config`/service_name.}/oauth_callback" |
| 21 | |
| 22 | |
| 23 | cscip-python python jupyterhub 5.2.1 `examples.service-fastapi.jupyterhub_config`/c. = get_config() # noqa |
| 24 | cscip-python python jupyterhub 5.2.1 `examples.service-fastapi.jupyterhub_config`/c..JupyterHub.services = [ |
| 25 | { |
| 26 | "name": service_namescip-python python jupyterhub 5.2.1 `examples.service-fastapi.jupyterhub_config`/service_name., |
| 27 | "url": "http://127.0.0.1:10202", |
| 28 | "command": ["uvicorn", "app:app", "--port", "10202"], |
| 29 | "oauth_redirect_uri": oauth_redirect_uriscip-python python jupyterhub 5.2.1 `examples.service-fastapi.jupyterhub_config`/oauth_redirect_uri., |
| 30 | "environment": {"PUBLIC_HOST": public_hostscip-python python jupyterhub 5.2.1 `examples.service-fastapi.jupyterhub_config`/public_host.}, |
| 31 | } |
| 32 | ] |
| 33 | |
| 34 | cscip-python python jupyterhub 5.2.1 `examples.service-fastapi.jupyterhub_config`/c..JupyterHub.load_roles = [ |
| 35 | { |
| 36 | "name": "user", |
| 37 | # grant all users access to services |
| 38 | "scopes": ["self", "access:services"], |
| 39 | }, |
| 40 | ] |
| 41 | |
| 42 | |
| 43 | # dummy for testing, create test-user |
| 44 | cscip-python python jupyterhub 5.2.1 `examples.service-fastapi.jupyterhub_config`/c..Authenticator.allowed_users = {"test-user"} |
| 45 | cscip-python python jupyterhub 5.2.1 `examples.service-fastapi.jupyterhub_config`/c..JupyterHub.authenticator_class = "dummy" |
| 46 | cscip-python python jupyterhub 5.2.1 `examples.service-fastapi.jupyterhub_config`/c..JupyterHub.spawner_class = "simple" |