def get_saml_client():
 if settings.SAML_CALLBACK_SERVER_NAME:
  acs_url = (settings.SAML_CALLBACK_SERVER_NAME + url_for('saml_auth.idp_initiated'))
 else:
  acs_url = url_for('saml_auth.idp_initiated', _external=True)
 if (settings.SAML_METADATA_URL != ''):
  rv = requests.get(settings.SAML_METADATA_URL)
  import tempfile
  tmp = tempfile.NamedTemporaryFile()
  f = open(tmp.name, 'w')
  f.write(rv.text)
  f.close()
  metadata_path = tmp.name
 else:
  metadata_path = settings.SAML_LOCAL_METADATA_PATH
 saml_settings = {'metadata': {'local': [metadata_path]}, 'service': {'sp': {'endpoints': {'assertion_consumer_service': [(acs_url, BINDING_HTTP_REDIRECT), (acs_url, BINDING_HTTP_POST)]}, 'allow_unsolicited': True, 'authn_requests_signed': False, 'logout_requests_signed': True, 'want_assertions_signed': True, 'want_response_signed': False}}}
 if (settings.SAML_ENTITY_ID != ''):
  saml_settings['entityid'] = settings.SAML_ENTITY_ID
 spConfig = Saml2Config()
 spConfig.load(saml_settings)
 spConfig.allow_unknown_attributes = True
 saml_client = Saml2Client(config=spConfig)
 if (settings.SAML_METADATA_URL != ''):
  tmp.close()
 return saml_client

def get_saml_client ( ) : if settings . SAML_CALLBACK_SERVER_NAME : acs_url = ( settings . SAML_CALLBACK_SERVER_NAME + url_for ( 'saml_auth.idp_initiated' ) ) else : acs_url = url_for ( 'saml_auth.idp_initiated' , _external = True ) if ( settings . SAML_METADATA_URL != '' ) : rv = requests . get ( settings . SAML_METADATA_URL ) import tempfile tmp = tempfile . NamedTemporaryFile ( ) f = open ( tmp . name , 'w' ) f . write ( rv . text ) f . close ( ) metadata_path = tmp . name else : metadata_path = settings . SAML_LOCAL_METADATA_PATH saml_settings = { 'metadata' : { 'local' : [ metadata_path ] } , 'service' : { 'sp' : { 'endpoints' : { 'assertion_consumer_service' : [ ( acs_url , BINDING_HTTP_REDIRECT ) , ( acs_url , BINDING_HTTP_POST ) ] } , 'allow_unsolicited' : True , 'authn_requests_signed' : False , 'logout_requests_signed' : True , 'want_assertions_signed' : True , 'want_response_signed' : False } } } if ( settings . SAML_ENTITY_ID != '' ) : saml_settings [ 'entityid' ] = settings . SAML_ENTITY_ID spConfig = Saml2Config ( ) spConfig . load ( saml_settings ) spConfig . allow_unknown_attributes = True saml_client = Saml2Client ( config = spConfig ) if ( settings . SAML_METADATA_URL != '' ) : tmp . close ( ) return saml_client
return saml configuration .