don't cache local metadata anymore (#13881)
This commit is contained in:
parent
d026ce40e1
commit
a1fa7d36df
|
@ -18,18 +18,16 @@ from . import app_settings
|
||||||
|
|
||||||
def create_metadata(request):
|
def create_metadata(request):
|
||||||
entity_id = reverse('mellon_metadata')
|
entity_id = reverse('mellon_metadata')
|
||||||
cache = getattr(settings, '_MELLON_METADATA_CACHE', {})
|
login_url = reverse(app_settings.LOGIN_URL)
|
||||||
if not entity_id in cache:
|
logout_url = reverse(app_settings.LOGOUT_URL)
|
||||||
login_url = reverse(app_settings.LOGIN_URL)
|
public_keys = []
|
||||||
logout_url = reverse(app_settings.LOGOUT_URL)
|
for public_key in app_settings.PUBLIC_KEYS:
|
||||||
public_keys = []
|
if public_key.startswith('/'):
|
||||||
for public_key in app_settings.PUBLIC_KEYS:
|
# clean PEM file
|
||||||
if public_key.startswith('/'):
|
public_key = ''.join(open(public_key).read().splitlines()[1:-1])
|
||||||
# clean PEM file
|
public_keys.append(public_key)
|
||||||
public_key = ''.join(open(public_key).read().splitlines()[1:-1])
|
name_id_formats = app_settings.NAME_ID_FORMATS
|
||||||
public_keys.append(public_key)
|
return render_to_string('mellon/metadata.xml', {
|
||||||
name_id_formats = app_settings.NAME_ID_FORMATS
|
|
||||||
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),
|
||||||
|
@ -40,10 +38,6 @@ def create_metadata(request):
|
||||||
'contact_persons': app_settings.CONTACT_PERSONS,
|
'contact_persons': app_settings.CONTACT_PERSONS,
|
||||||
'discovery_endpoint_url': request.build_absolute_uri(reverse('mellon_login')),
|
'discovery_endpoint_url': request.build_absolute_uri(reverse('mellon_login')),
|
||||||
})
|
})
|
||||||
settings._MELLON_METADATA_CACHE = cache
|
|
||||||
return settings._MELLON_METADATA_CACHE[entity_id]
|
|
||||||
|
|
||||||
SERVERS = {}
|
|
||||||
|
|
||||||
|
|
||||||
def create_server(request):
|
def create_server(request):
|
||||||
|
|
|
@ -153,7 +153,6 @@ def test_create_metadata(rf, private_settings, caplog):
|
||||||
('/ds:X509Certificate[text()=\'xxx\']', 1),
|
('/ds:X509Certificate[text()=\'xxx\']', 1),
|
||||||
('/ds:X509Certificate[text()=\'yyy\']', 1)))),
|
('/ds:X509Certificate[text()=\'yyy\']', 1)))),
|
||||||
namespaces=ns)
|
namespaces=ns)
|
||||||
assert metadata is create_metadata(request)
|
|
||||||
|
|
||||||
|
|
||||||
def test_iso8601_to_datetime(private_settings):
|
def test_iso8601_to_datetime(private_settings):
|
||||||
|
|
Loading…
Reference in New Issue