I wrote a forms authentication plugin for CherryPy

87 views
Skip to first unread message

DarrylA

unread,
Sep 10, 2011, 10:38:32 PM9/10/11
to cherrypy-devel
How do I go about submitting a tool for review to be included into the
code base?

I wrote a first-class forms authentication plugin for CherryPy.
Here's how it works:

In your config, you'd add these lines:

tools.auth_forms.on = True
tools.auth_forms.login_url = "/path/to/my/login"
tools.auth_forms.session_key = "STARTREKISGREAT"

In your login page handler, you'd do something like this:

@cherrypy.expose
def login(self, username=None, password=None, returnUrl="/"):

if username is None or password is None:
return .... login screen template .render(returnUrl = returnUrl)

error_msg = AuthenticationDB.check_credentials(username, password)
if error_msg:
return .... login screen template .render(returnUrl = returnUrl,
errorMsg = error_msg, username = username)
else:
HTTPFormsAuthentication.login_and_redirect(username, returnUrl)

@cherrypy.expose
def logout(self, returnUrl="/"):
HTTPFormsAuthentication.logout()
raise cherrypy.HTTPRedirect(returnUrl)

That's it! I can send the plugin to whomever.

-DarrylA

Sylvain Hellegouarch

unread,
Sep 14, 2011, 2:39:44 AM9/14/11
to cherryp...@googlegroups.com
Hi Darry,

We seldom add new tools to the core because this means more maintaining and we are too few. Usually we advise contributors to add their code to the tools wiki http://tools.cherrypy.org/ which acts as a more central point for those contributions.

Thanks, 
--
- Sylvain
http://www.defuze.org
http://twitter.com/lawouach
Reply all
Reply to author
Forward
0 new messages