Hi, Christoph. On Wednesday January 28, 2009 17:38:55 Christoph Zwerschke wrote: > In TG1 it was very easy to implement IP-based authentication using the > identity.from_host predicate. Is there something similar in TG2? Or do I > need to write a repoze.who plugin? I think TG2 should provide something > for IP-based authentication out of the box.
TurboGears itself doesn't deal with authentication and authorization as of version 2. By default, it uses the repoze.who and repoze.what frameworks for authentication/identification and authorization, respectively: http://turbogears.org/2.0/docs/main/Auth/index.html Eventually there will be a repoze.what network plugin, which will provide predicates for IP-based authorization, among other things. In the mean time, you can use the following repoze.what predicate (not tested): from repoze.what.predicates import Predicate class from_ip(Predicate): message = 'The user must have the IP address "%(ip_address)s"' def __init__(self, ip_address, **kwargs): super(from_ip, self).__init__(**kwargs) self.ip_address = ip_address def evaluate(self, environ, credentials): if self.ip_address != environ.get('REMOTE_ADDR'): self.unmet() HTH. -- Gustavo Narea <http://gustavonarea.net/>. Get rid of unethical constraints! Get freedomware: http://www.getgnulinux.org/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears Trunk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/turbogears-trunk?hl=en -~----------~----~----~----~------~----~------~--~---
