Well that was easy =D (not as easy as writing restul instead
of
restFul... twice =P)! Thanks for your help Robert!
On Jun 15, 10:50 pm, fumanchu <fuman... amor.org> wrote:
> On Jun 15, 5:38 pm, Guolber <lgpan... gmail.com> wrote:
>
>
>
> > I'm developing a restul service with CP3 and
trying to add digest
> > authentication for some resources. I've seen a few
examples of how to
> > set the app config to require digest
authentication for a certain
> > realm, but how can I tell CP3 to require the
digest authentication for
> > a specific HTTP VERB (mostly POST) of a specific
resource?
>
> > I mean, if i use the normal configuration like:
>
> > conf = {'/myResource': {'tools.digest_auth.on':
True,
> > 'tools.digest_auth.realm':
'localhost',
> > 'tools.digest_auth.users':
get_users }
> > }
>
> > It will check for every http verb, am i right? So
is there a direct
> > way to configurate the app to require the digest
auth for a certain
> > http_verb?
>
> The easiest way is to leave the digest_auth tool off in
config and
> turn it on conditionally:
>
> import cherrypy
>
> def conditional_digest_auth(verbs=['POST', 'PUT',
'DELETE']):
> """Turn on Digest auth based on
various criteria."""
> if cherrypy.request.method in verbs:
> cherrypy.tools.digest_auth._setup()
>
> cherrypy.tools.conditional_digest_auth =
> cherrypy.Tool('on_start_resource',
conditional_digest_auth)
>
> conf = {'/myResource': {
> 'tools.conditional_digest_auth.on':
True,
>
'tools.conditional_digest_auth.verbs': ['POST'],
> 'tools.digest_auth.realm':
'localhost',
> 'tools.digest_auth.users': get_users
}
> }
>
> Add further conditions to your heart's content by
modifying the
> argument list for conditional_digest_auth, or by
creating additional
> Tools. Override their defaults in config (as I have
done above) if
> needed.
>
> Robert Brewer
> System Architect
> Amor Ministries
> fuman... amor.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|