store cached metadata in settings
This commit is contained in:
parent
4f77ee0e24
commit
bd216c7ab7
|
@ -17,11 +17,11 @@ import lasso
|
||||||
|
|
||||||
from . import app_settings
|
from . import app_settings
|
||||||
|
|
||||||
METADATA = {}
|
|
||||||
|
|
||||||
def create_metadata(request):
|
def create_metadata(request):
|
||||||
entity_id = reverse('mellon_metadata')
|
entity_id = reverse('mellon_metadata')
|
||||||
if entity_id not in METADATA:
|
cache = getattr(settings, '_MELLON_METADATA_CACHE', {})
|
||||||
|
if not entity_id in cache:
|
||||||
login_url = reverse('mellon_login')
|
login_url = reverse('mellon_login')
|
||||||
logout_url = reverse('mellon_logout')
|
logout_url = reverse('mellon_logout')
|
||||||
public_keys = []
|
public_keys = []
|
||||||
|
@ -31,15 +31,16 @@ def create_metadata(request):
|
||||||
public_key = ''.join(file(public_key).read().splitlines()[1:-1])
|
public_key = ''.join(file(public_key).read().splitlines()[1:-1])
|
||||||
public_keys.append(public_key)
|
public_keys.append(public_key)
|
||||||
name_id_formats = app_settings.NAME_ID_FORMATS
|
name_id_formats = app_settings.NAME_ID_FORMATS
|
||||||
return render_to_string('mellon/metadata.xml', {
|
cache[entity_id] = render_to_string('mellon/metadata.xml', {
|
||||||
'entity_id': request.build_absolute_uri(entity_id),
|
'entity_id': request.build_absolute_uri(entity_id),
|
||||||
'login_url': request.build_absolute_uri(login_url),
|
'login_url': request.build_absolute_uri(login_url),
|
||||||
'logout_url': request.build_absolute_uri(logout_url),
|
'logout_url': request.build_absolute_uri(logout_url),
|
||||||
'public_keys': public_keys,
|
'public_keys': public_keys,
|
||||||
'name_id_formats': name_id_formats,
|
'name_id_formats': name_id_formats,
|
||||||
'default_assertion_consumer_binding': app_settings.DEFAULT_ASSERTION_CONSUMER_BINDING,
|
'default_assertion_consumer_binding': app_settings.DEFAULT_ASSERTION_CONSUMER_BINDING,
|
||||||
})
|
})
|
||||||
return METADATA[entity_id]
|
settings._MELLON_METADATA_CACHE = cache
|
||||||
|
return settings._MELLON_METADATA_CACHE[entity_id]
|
||||||
|
|
||||||
SERVERS = {}
|
SERVERS = {}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue