Beispiel #1
0
 def metadata(self):
     cert_file = self._config.idp_certificate_file_path
     with open(cert_file, 'r') as fp:
         cert = fp.readlines()[1:-1]
         cert = ''.join(cert)
     sso_list = []
     slo_list = []
     sso_list.append(
         Sso(binding=BINDING_HTTP_POST,
             location=self._config.absolute_sso_url))
     sso_list.append(
         Sso(binding=BINDING_HTTP_REDIRECT,
             location=self._config.absolute_sso_url))
     slo_list.append(
         Slo(binding=BINDING_HTTP_POST,
             location=self._config.absolute_slo_url))
     slo_list.append(
         Slo(binding=BINDING_HTTP_REDIRECT,
             location=self._config.absolute_slo_url))
     metadata = create_idp_metadata(
         entity_id=self._config.entity_id,
         want_authn_requests_signed='true',
         keys=[Key(use='signing', value=cert)],
         single_sign_on_services=sso_list,
         single_logout_services=slo_list).to_xml()
     return Response(metadata, mimetype='text/xml')
Beispiel #2
0
 def metadata(self):
     cert_file = self.server.config.cert_file
     with open(cert_file, 'r') as fp:
         cert = fp.readlines()[1:-1]
         cert = ''.join(cert)
     endpoints = getattr(self.server.config, '_idp_endpoints')
     sso = endpoints.get('single_sign_on_service')
     slo = endpoints.get('single_logout_service')
     sso = [Sso(*_sso) for _sso in sso]
     slo = [Slo(*_slo) for _slo in slo]
     metadata = create_idp_metadata(
         entity_id=self.server.config.entityid,
         want_authn_requests_signed='true',
         keys=[Key(use='signing', value=cert)],
         single_sign_on_services=sso,
         single_logout_services=slo
     ).to_xml()
     return Response(metadata, mimetype='text/xml')
Beispiel #3
0
 def test_idp_metadata(self):
     ssos = [Sso(binding=BINDING_HTTP_POST, location='http://sso.sso')]
     slos = [Slo(binding=BINDING_HTTP_REDIRECT, location='http://slo.slo')]
     metadata = create_idp_metadata(
         entity_id='test_id123',
         want_authn_requests_signed='true',
         keys=[Key(use='signing', value='CERTCERTCERT')],
         single_sign_on_services=ssos,
         single_logout_services=slos)
     x509_cert = metadata._element.findall('.//{%s}X509Certificate' % DS)
     self.assertEqual(len(x509_cert), 1)
     self.assertEqual(x509_cert[0].text, 'CERTCERTCERT')
     ssos = metadata._element.findall('.//{%s}SingleSignOnService' % MD)
     self.assertEqual(ssos[0].attrib['Binding'], BINDING_HTTP_POST)
     self.assertEqual(ssos[0].attrib['Location'], 'http://sso.sso')
     self.assertEqual(len(ssos), 1)
     slos = metadata._element.findall('.//{%s}SingleLogoutService' % MD)
     self.assertEqual(len(slos), 1)
     self.assertEqual(slos[0].attrib['Binding'], BINDING_HTTP_REDIRECT)
     self.assertEqual(slos[0].attrib['Location'], 'http://slo.slo')