saml: implement a2_hook_good_next_url for SAML 2.0 SPs (#21769)
This commit is contained in:
parent
06c37bec0a
commit
09dab1b45d
|
@ -0,0 +1,11 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
default_app_config = 'authentic2.saml.A2SAMLAppConfig'
|
||||
|
||||
|
||||
class A2SAMLAppConfig(AppConfig):
|
||||
name = 'authentic2.saml'
|
||||
|
||||
def a2_hook_good_next_url(self, next_url):
|
||||
from .utils import saml_good_next_url
|
||||
return saml_good_next_url(next_url)
|
|
@ -0,0 +1,21 @@
|
|||
from authentic2.decorators import GlobalCache
|
||||
|
||||
|
||||
@GlobalCache(timeout=60)
|
||||
def get_entity_ids():
|
||||
from .models import LibertyProvider
|
||||
|
||||
return LibertyProvider.objects.values_list('entity_id', flat=True)
|
||||
|
||||
|
||||
@GlobalCache(timeout=60)
|
||||
def saml_good_next_url(next_url):
|
||||
from authentic2.utils import same_origin
|
||||
|
||||
entity_ids = get_entity_ids()
|
||||
for entity_id in entity_ids:
|
||||
if same_origin(entity_id, next_url):
|
||||
return True
|
||||
return None
|
||||
|
||||
|
Loading…
Reference in New Issue