This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
authentic2-idp-oauth2/authentic2_idp_oauth2/__init__.py

36 lines
1.2 KiB
Python

from django.utils.timezone import now
from django.template.loader import render_to_string
class Plugin(object):
def get_before_urls(self):
from . import urls
return urls.urlpatterns
def get_apps(self):
return ['rest_framework', 'provider', 'provider.oauth2', __name__]
def logout_list(self, request):
from provider.oauth2.models import Client
if not request.user.is_authenticated():
return []
qs = Client.objects.filter(accesstoken__user=request.user,
accesstoken__expires__gt=now(), logout_url__isnull=False) \
.distinct()
l = []
for client in qs:
for logout_url in client.logout_url.all():
name = client.name
url = logout_url.get_url()
content = render_to_string('idp/saml/logout_fragment.html',
{
'needs_iframe': logout_url.use_iframe,
'name': name,
'url': url,
'iframe_timeout': 2,
})
l.append(content)
return l