{ "info": { "author": "Giovanni Pizzi", "author_email": "", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5" ], "description": "# jhproxy\n\nA port proxy for JupyterHub when using the DockerSpawner, optionally with \nauthentication.\n\nThis code is hosted at https://github.com/aiidalab/jhproxy.\n\nIf you use JupyterHub, and some app inside the docker spawned by Jupyter \nopens a port (e.g. it exposes a REST API), these are not accessible outside the\ndocker container, in general.\n\nA nice Jupyter server exension, [nbserverproxy](https://github.com/jupyterhub/nbserverproxy), exists to proxy a given port\nthrough the notebook server.\nThis would work, but requires that anybody performing a request has access to \nthe JupyterHub token. This could be extracted from the browser and passed to an\nexternal app that wants to use the API (command line, or throgh AJAX requests\nfrom a different site), but:\n- this is cumbersome\n- if someone gets the token, they get access to the whole docker container of the\n user\n\nTo alleviate this, we wrote `jhproxy`.\nThis needs to be installed by the person maintaining the JupyterHub installation,\nbut allows to:\n- decide which ports can be forwarded (more can be forwarded, but they need to \n be specified, see documentation below)\n- allow for (optional) authentication of the proxy requests (via a \n `X-Proxy-Token` that should be passed in the HTTP Request Headers) \n- Allow a logged-in JupyterHub user to enable, disable or regenerate a token\n- Add an API endpoint to obtain the current token for the currently logged-in\n JupyterHub user (so this can be given to a client performing the API requests\n via the proxy).\n\nNote that this proxy only works currently for a DockerSpawner (to use \ntoken authentication you need to use the provided `jhproxy.spawners.TokenizedDockerSpawner`, that extends the image).\n\n## Documentation\n\nIn order to install and use this extension, you need to do the following on\nthe machine where JupyterHub is installed:\n\n- install `jhproxy`: \n ```\n pip instal jhproxy\n ```\n\n- configure properly your `jupyterhub_config.py` to decide which ports to \n proxy, under which address, etc.\n We provide a fully documented working example inside `examples/jupyterhub_config.py`. Feel free to copy, reuse and edit to your needs.\n\nWe provide below just a few additional notes on how to configure it\n\n### Authorization setup\nIf you don't need authorization, you can just use the standard `DockerSpawner` spawner; ports will simply be proxied.\n\nIf you instead want authorization, use `jbproxy.spawners.TokenizedDockerSpawner`\nas in the configuration example. As shown there, there are also a few options\nto decide the default token to be generated the first time the spawner is\ncreate (disabled, allow all, generate new random token).\n\n# How to use it\n\nThe user (once logged in JupyterHub) can use the `ProxyTokenHandler` (under the\nurl `http(s)://JUPYTERHUBHOST/hub/proxytoken/`) to get the current token (via GET requests) or to ask to change it (via POST requests).\nThis endpoint requires to be authenticated.\n\nTo see an example, load inside your jupyter the notebook provided under `examples/Proxy token manager.ipynb`.\nRun it and then press the buttons to get the current token, or change it (disabling all access, enabling it for everybody, or generating a new random token).\n\n**NOTE**: this needs to be done inside the jupyter provided by JupyterHub,\notherwise the JupyterHub authorization cookies will not be passed and you\nwill not be able to access these endpoints.\n\nTo use it:\n- Login in JupyterHub\n- (Optional, if you did not choose the option in the `jupyterhub_config.py` to generate a random token at startup) Upload the `examples/Proxy token manager.ipynb`, run it and create a new token\n- Open a terminal and start a server serving on one of the ports you chose (e.g.: `python -m SimpleHTTPServer 5000`)\n- Try to connect to it. If you set it without token check (allow all), you can \n just go to the correct URL in your browser (e.g. `http://localhost:8000/hub/proxy5000/YOURJUPYTERHUBUSERNAME`). Otherwise, to check using a proxy\n via a AJAX request (that checks that also the CORS headers are properly\n set in the server), use the simple example under `examples/client_ajax_CORS_example.html`: put the correct URL (change the string `USERNAMEHERE`, and possibly change the token, that you can get as\n described above via the Jupyter notebook, or via the link provided in the \n page, if you have already logged into JupyterHub in the same browser and you have not changed the URL of the `/proxytoken/` endpoint).\n\n### Notes\n- If the Docker host is a Mac, you need to start the server to be proxied \n inside docker on the 0.0.0.0 interface, otherwise Docker will not allow to \n forward it due to the way networking is configured by default on Docker \n on the Mac. Note that this is a Docker configuration and not a jhproxy issue.\n\n## License\nThis code is released under a MIT license.\nWe acknowledge [nbserverproxy](https://github.com/jupyterhub/nbserverproxy) from\nwhich we have taken free inspiration for the proxy part.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/aiidalab/jhproxy", "keywords": "jupyterhub,proxy,authorization,token", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "jhproxy", "package_url": "https://pypi.org/project/jhproxy/", "platform": "", "project_url": "https://pypi.org/project/jhproxy/", "project_urls": { "Homepage": "https://github.com/aiidalab/jhproxy" }, "release_url": "https://pypi.org/project/jhproxy/0.1.1/", "requires_dist": [ "jupyterhub", "dockerspawner", "traitlets" ], "requires_python": "", "summary": "A port proxy for JupyterHub when using the DockerSpawner, optionally with (token-based) authorization.", "version": "0.1.1" }, "last_serial": 4444043, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "7a8fd836e01009136dc6b065e327a40e", "sha256": "7b4b194edcadbc41cb7ff47d323a81660f201045a597746116859665233e8983" }, "downloads": -1, "filename": "jhproxy-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "7a8fd836e01009136dc6b065e327a40e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8646, "upload_time": "2018-11-02T10:33:25", "url": "https://files.pythonhosted.org/packages/7a/e0/fb82b25cd8e8b3392d71d6b0241d6e803cb8ae27f1fea0c8592dbcc3f5fa/jhproxy-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d4c1a7d5dd58dbcc502ec3279b9b0c8f", "sha256": "9bfbd384d92361f43ccfe3926ed184be5d5006df6221cab0dace95cb34085b09" }, "downloads": -1, "filename": "jhproxy-0.1.0.tar.gz", "has_sig": false, "md5_digest": "d4c1a7d5dd58dbcc502ec3279b9b0c8f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8312, "upload_time": "2018-11-02T10:33:27", "url": "https://files.pythonhosted.org/packages/85/41/dc909204bf03b7b823a295d76b68bae708aab7fcc1a07aa9a6328d26f27f/jhproxy-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "2b80da3e63f7f87f475c17ace7a53ce3", "sha256": "c63932692021234dc44d8d3a88dadaf59ead3a1d44af29e7beb6cfe41f5f6eb5" }, "downloads": -1, "filename": "jhproxy-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2b80da3e63f7f87f475c17ace7a53ce3", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8661, "upload_time": "2018-11-02T10:36:44", "url": "https://files.pythonhosted.org/packages/9e/3c/ef9b705052d081668bdff90433540b85c46fd61e923fd7a93d65d1f85622/jhproxy-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e1be515a109f43c3e49de66cbd389683", "sha256": "31164053cf29e6709ca58e8e2f89cc5eaa1890b1f73cce984516bd912c79d59a" }, "downloads": -1, "filename": "jhproxy-0.1.1.tar.gz", "has_sig": false, "md5_digest": "e1be515a109f43c3e49de66cbd389683", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8331, "upload_time": "2018-11-02T10:36:46", "url": "https://files.pythonhosted.org/packages/56/3a/00866279d2f1c8168b4684f31ab906b9fcd2920b2d1fbdf4cd85bf30a469/jhproxy-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2b80da3e63f7f87f475c17ace7a53ce3", "sha256": "c63932692021234dc44d8d3a88dadaf59ead3a1d44af29e7beb6cfe41f5f6eb5" }, "downloads": -1, "filename": "jhproxy-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2b80da3e63f7f87f475c17ace7a53ce3", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8661, "upload_time": "2018-11-02T10:36:44", "url": "https://files.pythonhosted.org/packages/9e/3c/ef9b705052d081668bdff90433540b85c46fd61e923fd7a93d65d1f85622/jhproxy-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e1be515a109f43c3e49de66cbd389683", "sha256": "31164053cf29e6709ca58e8e2f89cc5eaa1890b1f73cce984516bd912c79d59a" }, "downloads": -1, "filename": "jhproxy-0.1.1.tar.gz", "has_sig": false, "md5_digest": "e1be515a109f43c3e49de66cbd389683", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8331, "upload_time": "2018-11-02T10:36:46", "url": "https://files.pythonhosted.org/packages/56/3a/00866279d2f1c8168b4684f31ab906b9fcd2920b2d1fbdf4cd85bf30a469/jhproxy-0.1.1.tar.gz" } ] }