need example for multiple auth for resource

64 views
Skip to first unread message

ydjango

unread,
Jul 9, 2011, 12:21:49 AM7/9/11
to django-piston
I believe Django-Piston directly support multiple authentication
methods for a resource.

Any examples on how to use it?

I need to support basic and my own authentication method.

I can easily roll out my own but if piston already supports it I would
prefer using its.

Jorge Cardona

unread,
Jul 9, 2011, 5:09:51 AM7/9/11
to django...@googlegroups.com
Piston has a Basic authentication method with
piston.authentication.HttpBasicAuthentication look at
http://stackoverflow.com/questions/3297125/basic-http-authentication-with-django-piston

But you can define your own class, with two methods: challenge and
is_authenticated, look the class HttpBasicAuthentication at
https://bitbucket.org/jespern/django-piston/src/c4b2d21db51a/piston/authentication.py#cl-26

A different examplo could be the code in
https://github.com/jorgeecardona/django-apikey/blob/master/apikey/auth.py
and there is a way to authenticate request by a temporal token, with
the is_authenticated and challenge methods defined.

Everything is explained here:
https://bitbucket.org/jespern/django-piston/wiki/Documentation#!authentication

> --
> You received this message because you are subscribed to the Google Groups "django-piston" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-pisto...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-piston?hl=en.
>
>

--
Jorge Eduardo Cardona
jorgee...@gmail.com
jorgeecardona.blogspot.com
github.com/jorgeecardona
------------------------------------------------
Linux registered user  #391186
Registered machine    #291871
------------------------------------------------

ydjango

unread,
Jul 9, 2011, 10:39:00 AM7/9/11
to django-piston
Thank you Jorge. That is very useful and I will create my own auth
method based on examples given.

I also wanted to allow users to use any one of the multiple auth
methods to access same api. Thats multiple ways auth for same
resource.

I will just create a simple delegator auth class which will tie to the
resource. This delegator auth class will check the header and call the
appropriate basicAuth or tokenAuth based on the header in the request
and authenticate the user.



On Jul 9, 2:09 am, Jorge Cardona <jorgeecard...@gmail.com> wrote:
> Piston has a Basic authentication method with
> piston.authentication.HttpBasicAuthentication look athttp://stackoverflow.com/questions/3297125/basic-http-authentication-...
>
> But you can define your own class, with two methods: challenge and
> is_authenticated, look the class HttpBasicAuthentication athttps://bitbucket.org/jespern/django-piston/src/c4b2d21db51a/piston/a...
>
> A different examplo could be the code inhttps://github.com/jorgeecardona/django-apikey/blob/master/apikey/aut...
> and there is a way to authenticate request by a temporal token, with
> the is_authenticated and challenge methods defined.
>
> Everything is explained here:https://bitbucket.org/jespern/django-piston/wiki/Documentation#!authe...
>
>
>
> On Fri, Jul 8, 2011 at 11:21 PM, ydjango <traderash...@gmail.com> wrote:
> > I believe Django-Piston directly support multiple authentication
> > methods for a resource.
>
> > Any examples on how to use it?
>
> > I need to support basic and my own authentication method.
>
> > I can easily roll out my own but if piston already supports it I would
> > prefer using its.
>
> > --
> > You received this message because you are subscribed to the Google Groups "django-piston" group.
> > To post to this group, send email to django...@googlegroups.com.
> > To unsubscribe from this group, send email to django-pisto...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/django-piston?hl=en.
>
> --
> Jorge Eduardo Cardona
> jorgeecard...@gmail.com
Reply all
Reply to author
Forward
0 new messages