[Twisted-Python] How to do basic authentication on twisted web

Chris Adams chris at stemcel.co.uk
Mon Aug 17 06:42:49 MDT 2009


Wow, thanks fo the quick replies guys.

I've tried to combine this with the example earlier, with some
annotations as to what I think is going on, but I'm on somewhat shaky
ground here.

Do these annotations sum up roughly what is going on here?

My annotated example is also up on github - http://gist.github.com/169102


The original on twisted matrix
http://twistedmatrix.com/projects/web/documentation/examples/webguard.py




2009/8/17 Reza Lotun <rlotun at gmail.com>:
> Hi Colin,
>
>> Where is Portal and SimpleRealm in your example? Those are actually quite
>> large constructs which are crucial to guard doing anything useful at all.
>
> Sorry, this snippet of code I wrote tracked the webguard.py example
> that I linked to.
>
> from twisted.cred.portal import IRealm, Portal
>
> class SimpleRealm(object):
>    """
>    A realm which gives out L{GuardedResource} instances for authenticated
>    users.
>    """
>    implements(IRealm)
>
>    def requestAvatar(self, avatarId, mind, *interfaces):
>        if resource.IResource in interfaces:
>            return resource.IResource, GuardedResource(), lambda: None
>        raise NotImplementedError()
>
> Does that make sense now?
>
>> Since there are numerous circumstances that people need Htauth, it is
>> implemented as follows
>
> Ok, of course you can do that if you want. But you still need to be
> able to *verify* credentials.
>
> Anyway, to each their own.
>
> Reza
>
>
>
> --
> Reza Lotun
> mobile: +44 (0)7521 310 763
> email:  rlotun at gmail.com
> work:   reza at tweetdeck.com
> twitter: @rlotun
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>



-- 
---
I'm currently only checking my email at 9am, midday and at 4pm.
If you need a response from me urgently, please call or text my
mobile, or contact me via Skype (chris.d.adams).
---
Chris Adams
Stemcel Studios
The Hub
5 Torrens Street
London
EC1V 1NQ

email: chris at stemcel.co.uk
web:  www.stemcel.co.uk
twitter:chris_d_adams
skype: chris.d.adams
mob: 07974 368 229
tel: 0207 558 8971




More information about the Twisted-Python mailing list