List Info

Thread: digest_auth and restul services




digest_auth and restul services
country flaguser name
United States
2007-06-15 19:38:35
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?

I'll keep on working in this, but I'm asking because maybe
someone has
already worked with something like this.

Thanks!


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: digest_auth and restul services
country flaguser name
United States
2007-06-15 20:50:10
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
fumanchuamor.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-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: digest_auth and restul services
country flaguser name
United States
2007-06-17 13:42:21
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-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )