spyre icon indicating copy to clipboard operation
spyre copied to clipboard

added authentication to spyre

Open Dana-Farber opened this issue 7 years ago • 0 comments

The following is a working example

from spyre import server

class SimpleApp(server.App):
	title = "Simple App"
	inputs = [{
		"type": "text",
		"key": "words",
		"label": "write words here",
		"value": "hello world",
		"action_id": "simple_html_output"
	}]

	outputs = [{
		"type": "html",
		"id": "simple_html_output"
	}]

	def getHTML(self, params):
		words = params["words"]
		return "Here's what you wrote in the textbox: <b>%s</b>" % 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(config=digest_auth)

Dana-Farber avatar Feb 07 '18 14:02 Dana-Farber