From 177fa4685f759c49162465d232eee24a2e8f83f1 Mon Sep 17 00:00:00 2001 From: Dana-Farber Date: Tue, 6 Feb 2018 13:37:18 -0500 Subject: [PATCH 1/5] added auth pass to cherrypy --- spyre/server.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spyre/server.py b/spyre/server.py index 28232e9..4d29dc4 100755 --- a/spyre/server.py +++ b/spyre/server.py @@ -14,6 +14,9 @@ from cherrypy.lib.static import serve_file from cherrypy.lib.static import serve_fileobj +#password auth +from cherrypy.lib import auth_digest + try: import StringIO as io # python2 except Exception: @@ -478,14 +481,14 @@ def getCustomHead(self): """ return "" - def launch(self, host="local", port=8080, prefix='/'): + def launch(self, host="local", port=8080, prefix='/', config=None): self.prefix = prefix webapp = self.getRoot() if host != "local": cherrypy.server.socket_host = '0.0.0.0' cherrypy.server.socket_port = port cherrypy.tree.mount(webapp, prefix) - cherrypy.quickstart(webapp) + cherrypy.quickstart(webapp, config=config) def launch_in_notebook(self, port=9095, width=900, height=600): """launch the app within an iframe in ipython notebook""" From 5b65e48e696ac61e732c857f29789da354482907 Mon Sep 17 00:00:00 2001 From: Dana-Farber Date: Wed, 7 Feb 2018 09:55:35 -0500 Subject: [PATCH 2/5] Update README.md --- README.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 99d7ba4..79bc991 100755 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Spyre runs on the minimalist python web framework, **[cherrypy]**, with **[jinja Installation ---- ```bash - $ pip install dataspyre + $ pip install git+https://github.com/Dana-Farber/spyre ``` @@ -28,7 +28,7 @@ class SimpleApp(server.App): "type": "text", "key": "words", "label": "write words here", - "value": "hello world", + "value": "hello world", "action_id": "simple_html_output" }] @@ -41,8 +41,17 @@ class SimpleApp(server.App): words = params["words"] return "Here's what you wrote in the textbox: %s" % words +USERS={"alice":"secret"} + +from cherrypy.lib import auth_digest #must import this to compute ha1 digest +digest_auth = {'/': {'tools.auth_digest.on': True, + 'tools.auth_digest.realm': 'wonderland', + 'tools.auth_digest.get_ha1': auth_digest.get_ha1_dict_plain(USERS), + 'tools.auth_digest.key': 'a565c27146791cfb', +}} + app = SimpleApp() -app.launch() +app.launch(config=digest_auth) ``` The SimpleApp class inherits server.App which includes a few methods that you can override to generate outputs. In this case we want our app to display HTML (just text for now) so we'll overide the getHTML method. This method should return a string. From 52dc3c85e43b1e8b9c526b676fe59864465b1575 Mon Sep 17 00:00:00 2001 From: Dana-Farber Date: Wed, 7 Feb 2018 09:56:41 -0500 Subject: [PATCH 3/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 79bc991..d568d47 100755 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Installation ``` -The Simplest of Examples +The Simplest of Examples, with User Authentication (Login) ---- Here's a very simple spyre example that shows the primary components of a spyre app ```python From 000cd221016011c5f1335d2edc372bada42a4cc7 Mon Sep 17 00:00:00 2001 From: Dana-Farber Date: Wed, 7 Feb 2018 09:56:53 -0500 Subject: [PATCH 4/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d568d47..58a5a12 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Spyre +Secure Spyre ========= Spyre is a Web Application Framework for providing a simple user interface for Python data projects. From f424ff34f309b004bba1b5b5b518dd53af7b6abb Mon Sep 17 00:00:00 2001 From: Dana-Farber Date: Wed, 14 Mar 2018 12:27:33 -0400 Subject: [PATCH 5/5] fixed auth code --- spyre/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spyre/server.py b/spyre/server.py index 4d29dc4..d64c12b 100755 --- a/spyre/server.py +++ b/spyre/server.py @@ -14,7 +14,6 @@ from cherrypy.lib.static import serve_file from cherrypy.lib.static import serve_fileobj -#password auth from cherrypy.lib import auth_digest try: @@ -482,6 +481,7 @@ def getCustomHead(self): return "" def launch(self, host="local", port=8080, prefix='/', config=None): + """launch""" self.prefix = prefix webapp = self.getRoot() if host != "local":