provide modified session authentication plugin with correct 'camefrom' setting
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@1250 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
f4eebb5967
commit
caac5d81df
2 changed files with 37 additions and 3 deletions
|
@ -24,12 +24,30 @@ $Id$
|
||||||
|
|
||||||
import urllib
|
import urllib
|
||||||
from zope.app import zapi
|
from zope.app import zapi
|
||||||
|
from zope.app.authentication.session import SessionCredentialsPlugin
|
||||||
|
from zope.app.component import hooks
|
||||||
|
from zope.app.i18n import ZopeMessageFactory as _
|
||||||
from zope.app.security.browser.auth import LoginLogout as BaseLoginLogout
|
from zope.app.security.browser.auth import LoginLogout as BaseLoginLogout
|
||||||
from zope.cachedescriptors.property import Lazy
|
|
||||||
from zope.i18n import translate
|
|
||||||
from zope.app.security.interfaces import IUnauthenticatedPrincipal
|
from zope.app.security.interfaces import IUnauthenticatedPrincipal
|
||||||
from zope.app.security.interfaces import ILogoutSupported
|
from zope.app.security.interfaces import ILogoutSupported
|
||||||
from zope.app.i18n import ZopeMessageFactory as _
|
from zope.cachedescriptors.property import Lazy
|
||||||
|
from zope.i18n import translate
|
||||||
|
from zope.publisher.interfaces.http import IHTTPRequest
|
||||||
|
|
||||||
|
|
||||||
|
class LoopsSessionCredentialsPlugin(SessionCredentialsPlugin):
|
||||||
|
|
||||||
|
def challenge(self, request):
|
||||||
|
if not IHTTPRequest.providedBy(request):
|
||||||
|
return False
|
||||||
|
site = hooks.getSite()
|
||||||
|
#camefrom = request.getURL() # wrong when object is not viewable
|
||||||
|
camefrom = request.getApplicationURL() + request['PATH_INFO']
|
||||||
|
url = '%s/@@%s?%s' % (zapi.absoluteURL(site, request),
|
||||||
|
self.loginpagename,
|
||||||
|
urllib.urlencode({'camefrom': camefrom}))
|
||||||
|
request.response.redirect(url)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
class LoginLogout(BaseLoginLogout):
|
class LoginLogout(BaseLoginLogout):
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
layer="loops"
|
layer="loops"
|
||||||
allowed_interface="zope.app.publisher.interfaces.browser.IMenuAccessView"
|
allowed_interface="zope.app.publisher.interfaces.browser.IMenuAccessView"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- login/logout stuff -->
|
<!-- login/logout stuff -->
|
||||||
|
|
||||||
<zope:adapter factory="zope.app.security.LogoutSupported" />
|
<zope:adapter factory="zope.app.security.LogoutSupported" />
|
||||||
|
@ -44,4 +45,19 @@
|
||||||
layer="loops"
|
layer="loops"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<zope:utility
|
||||||
|
name="Loops Session Credentials"
|
||||||
|
provides="zope.app.authentication.interfaces.ICredentialsPlugin"
|
||||||
|
factory=".auth.LoopsSessionCredentialsPlugin"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<zope:localUtility class=".auth.LoopsSessionCredentialsPlugin">
|
||||||
|
|
||||||
|
<zope:require
|
||||||
|
permission="zope.ManageServices"
|
||||||
|
interface="zope.app.authentication.session.IBrowserFormChallenger"
|
||||||
|
set_schema="zope.app.authentication.session.IBrowserFormChallenger" />
|
||||||
|
|
||||||
|
</zope:localUtility>
|
||||||
|
|
||||||
</configure>
|
</configure>
|
||||||
|
|
Loading…
Add table
Reference in a new issue