diff --git a/authentic2_idp_ltpa/__init__.py b/authentic2_idp_ltpa/__init__.py index 618304a..49d1aa8 100644 --- a/authentic2_idp_ltpa/__init__.py +++ b/authentic2_idp_ltpa/__init__.py @@ -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