python:grok-1.4-ldapauth
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
| python:grok-1.4-ldapauth [2011/10/19 09:14] – angelegt jenad | python:grok-1.4-ldapauth [2017/11/15 08:08] (aktuell) – gelöscht jenad | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| - | app.py | ||
| - | <code python> | ||
| - | import grok | ||
| - | import rolesAndPerms | ||
| - | import ldapauth | ||
| - | |||
| - | from demo import resource | ||
| - | |||
| - | from zope.pluggableauth.authentication import PluggableAuthentication | ||
| - | from zope.authentication.interfaces import IAuthentication | ||
| - | |||
| - | |||
| - | class Demo(grok.Application, | ||
| - | grok.local_utility( | ||
| - | | ||
| - | setup=ldapauth.setup_authentication, | ||
| - | ) | ||
| - | |||
| - | class Index(grok.View): | ||
| - | grok.require(" | ||
| - | def update(self): | ||
| - | resource.style.need() | ||
| - | |||
| - | |||
| - | from zope.interface import Interface | ||
| - | from zope import schema | ||
| - | |||
| - | class ILoginForm(Interface): | ||
| - | login = schema.BytesLine(title=u' | ||
| - | password = schema.Password(title=u' | ||
| - | |||
| - | class MyLogin(grok.Form): | ||
| - | grok.context(Interface) | ||
| - | grok.require(' | ||
| - | |||
| - | form_fields = grok.Fields(ILoginForm) | ||
| - | |||
| - | @grok.action(' | ||
| - | def handle_login(self, | ||
| - | uid=self.request.get(' | ||
| - | self.redirect(self.request.form.get(' | ||
| - | | ||
| - | from zope.pluggableauth.interfaces import ILogout | ||
| - | from zope.authentication.interfaces import IUnauthenticatedPrincipal | ||
| - | |||
| - | from zope.component import getUtility | ||
| - | class Logout(grok.View): | ||
| - | grok.context(Interface) | ||
| - | grok.require(' | ||
| - | |||
| - | def update(self): | ||
| - | if not IUnauthenticatedPrincipal.providedBy(self.request.principal): | ||
| - | auth = getUtility(IAuthentication) | ||
| - | ILogout(auth).logout(self.request) | ||
| - | def render(self): | ||
| - | return " | ||
| - | |||
| - | </ | ||
| - | |||
| - | rolesAndPerms.py | ||
| - | <code python> | ||
| - | import grok | ||
| - | from zope.pluggableauth.interfaces import IAuthenticatedPrincipalCreated | ||
| - | from zope.securitypolicy.interfaces import IRolePermissionManager, | ||
| - | |||
| - | @grok.subscribe(IAuthenticatedPrincipalCreated) | ||
| - | def update_principal_info_from_ldap(event): | ||
| - | | ||
| - | app = grok.getSite() | ||
| - | prm = IPrincipalRoleManager(app) | ||
| - | | ||
| - | |||
| - | |||
| - | class ViewDemo(grok.Permission): | ||
| - | grok.name(' | ||
| - | grok.title(' | ||
| - | |||
| - | class Viewer(grok.Role): | ||
| - | """ | ||
| - | A Viewer can view. | ||
| - | """ | ||
| - | grok.name(' | ||
| - | grok.title(' | ||
| - | grok.description(' | ||
| - | grok.permissions(' | ||
| - | # alternatively, | ||
| - | # grok.permissions( | ||
| - | # ' | ||
| - | |||
| - | </ | ||
python/grok-1.4-ldapauth.1319015648.txt.gz · Zuletzt geändert: (Externe Bearbeitung)
