add slo support
This commit is contained in:
parent
42fa36551b
commit
60ad3b099d
|
@ -1,7 +1,35 @@
|
|||
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 [__name__, 'rest_framework', 'provider', 'provider.oauth2']
|
||||
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
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
try:
|
||||
from django.contrib.contenttypes.fields import GenericRelation
|
||||
django_17 = True
|
||||
except ImportError:
|
||||
django_17 = False
|
||||
from django.contrib.contenttypes.generic import GenericRelation
|
||||
|
||||
from provider.oauth2.models import Client
|
||||
from authentic2.models import LogoutUrl
|
||||
|
||||
if django_17:
|
||||
GenericRelation(LogoutUrl, related_query_name='oauth2_clients')\
|
||||
.contribute_to_class(Client, 'logout_url')
|
||||
else:
|
||||
GenericRelation(LogoutUrl).contribute_to_class(Client, 'logout_url')
|
Reference in New Issue