Skip to content
This repository has been archived by the owner on May 9, 2022. It is now read-only.

Commit

Permalink
Merge pull request #279 from bfabio/sp_metadata
Browse files Browse the repository at this point in the history
Refactor the SP metadata loading logic.
  • Loading branch information
bfabio authored Jan 15, 2021
2 parents 8e9da3e + f3fd0b1 commit 583dd52
Show file tree
Hide file tree
Showing 6 changed files with 251 additions and 84 deletions.
9 changes: 6 additions & 3 deletions templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ <h3 class="border-bottom mt-2 mb-2 border-italia">Service Provider configurati</
<tbody>
{% for item in sp_list %}
<tr>
<td >
{{ item['entityID'] }}
<td>
{{ item['entityID'] }}
<small class="float-right">
<mark>loaded from {{ item['location'] }}</mark>
</small>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}
{% endblock %}
15 changes: 8 additions & 7 deletions testenv/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def _handle_http_post(self, action):

def _get_certificates_by_issuer(self, issuer):
try:
return self._registry.get(issuer).certs()
return self._registry.load(issuer).certs()
except KeyError:
self._raise_error(
'entity ID {} non registrato, impossibile ricavare'
Expand Down Expand Up @@ -357,7 +357,7 @@ def users(self):
'primary_attributes': spid_main_fields,
'secondary_attributes': spid_secondary_fields,
'users': self.user_manager.all(),
'sp_list': self._registry.all(),
'sp_list': self._registry.load_all().keys(),
'can_add_user': can_add_user
}
)
Expand Down Expand Up @@ -393,8 +393,9 @@ def index(self):
**{
'sp_list': [
{
"entityID": sp
} for sp in self._registry.all()
"entityID": entity_id,
"location": sp_metadata.location,
} for (entity_id, sp_metadata) in self._registry.load_all().items()
],
}
)
Expand All @@ -405,7 +406,7 @@ def get_destination(self, req, sp_id):
acs_index = getattr(req, 'assertion_consumer_service_index', None)
protocol_binding = getattr(req, 'protocol_binding', None)
if acs_index is not None:
acss = self._registry.get(
acss = self._registry.load(
sp_id).assertion_consumer_service(index=acs_index)
if acss:
destination = acss[0].get('Location')
Expand Down Expand Up @@ -590,7 +591,7 @@ def login(self):
atcs_idx
)
)
sp_metadata = self._registry.get(sp_id)
sp_metadata = self._registry.load(sp_id)
required = []
optional = []
if atcs_idx and sp_metadata:
Expand Down Expand Up @@ -791,7 +792,7 @@ def continue_response(self):
def _sp_single_logout_service(self, issuer_name):
_slo = None
try:
_slo = self._registry.get(issuer_name).single_logout_services[0]
_slo = self._registry.load(issuer_name).single_logout_services[0]
except Exception:
pass
return _slo
Expand Down
Loading

0 comments on commit 583dd52

Please sign in to comment.