plugin: only logout if the cookie is present in the request

This commit is contained in:
Benjamin Dauvergne 2014-04-11 07:44:37 +02:00
parent 6716551565
commit d4321be93f
1 changed files with 20 additions and 11 deletions

View File

@ -1,5 +1,9 @@
import logging
__version__ = '1.0'
logger = logging.getLogger(__name__)
class Plugin(object):
def get_before_urls(self):
from . import urls
@ -12,17 +16,22 @@ class Plugin(object):
return ['authentic2_idp_ltpa.middleware.LTPAMiddleware']
def logout_list(self, request):
if request.session.get('ltpa', False):
url = resolve('ltpa-logout')
ctx = {
'needs_iframe': False,
'name': 'Domino',
'url': url,
'iframe_timeout': 0,
}
content = render_to_string('idp/saml/logout_fragment.html', ctx)
return [content]
return []
from django.template.loader import render_to_string
from django.core.urlresolvers import reverse
from . import app_settings
if app_settings.COOKIE_NAME not in request.COOKIES:
return []
url = reverse('ltpa-logout')
ctx = {
'needs_iframe': False,
'name': 'Domino',
'url': url,
'iframe_timeout': 0,
}
content = render_to_string('idp/saml/logout_fragment.html', ctx)
logging.debug('logout %r', content)
return [content]
from django.utils.six.moves import http_cookies