18 |
18 |
|
19 |
19 |
def create_metadata(request):
|
20 |
20 |
entity_id = reverse('mellon_metadata')
|
21 |
|
cache = getattr(settings, '_MELLON_METADATA_CACHE', {})
|
22 |
|
if not entity_id in cache:
|
23 |
|
login_url = reverse(app_settings.LOGIN_URL)
|
24 |
|
logout_url = reverse(app_settings.LOGOUT_URL)
|
25 |
|
public_keys = []
|
26 |
|
for public_key in app_settings.PUBLIC_KEYS:
|
27 |
|
if public_key.startswith('/'):
|
28 |
|
# clean PEM file
|
29 |
|
public_key = ''.join(open(public_key).read().splitlines()[1:-1])
|
30 |
|
public_keys.append(public_key)
|
31 |
|
name_id_formats = app_settings.NAME_ID_FORMATS
|
32 |
|
cache[entity_id] = render_to_string('mellon/metadata.xml', {
|
|
21 |
login_url = reverse(app_settings.LOGIN_URL)
|
|
22 |
logout_url = reverse(app_settings.LOGOUT_URL)
|
|
23 |
public_keys = []
|
|
24 |
for public_key in app_settings.PUBLIC_KEYS:
|
|
25 |
if public_key.startswith('/'):
|
|
26 |
# clean PEM file
|
|
27 |
public_key = ''.join(open(public_key).read().splitlines()[1:-1])
|
|
28 |
public_keys.append(public_key)
|
|
29 |
name_id_formats = app_settings.NAME_ID_FORMATS
|
|
30 |
return render_to_string('mellon/metadata.xml', {
|
33 |
31 |
'entity_id': request.build_absolute_uri(entity_id),
|
34 |
32 |
'login_url': request.build_absolute_uri(login_url),
|
35 |
33 |
'logout_url': request.build_absolute_uri(logout_url),
|
... | ... | |
40 |
38 |
'contact_persons': app_settings.CONTACT_PERSONS,
|
41 |
39 |
'discovery_endpoint_url': request.build_absolute_uri(reverse('mellon_login')),
|
42 |
40 |
})
|
43 |
|
settings._MELLON_METADATA_CACHE = cache
|
44 |
|
return settings._MELLON_METADATA_CACHE[entity_id]
|
45 |
|
|
46 |
|
SERVERS = {}
|
47 |
41 |
|
48 |
42 |
|
49 |
43 |
def create_server(request):
|