def _update_data(entity_id, public_key, sso_url, expires_at): """ Update/Create the SAMLProviderData for the given entity ID. Return value: False if nothing has changed and existing data's "fetched at" timestamp is just updated. True if a new record was created. (Either this is a new provider or something changed.) """ data_obj = SAMLProviderData.current(entity_id) fetched_at = datetime.datetime.now() if data_obj and (data_obj.public_key == public_key and data_obj.sso_url == sso_url): data_obj.expires_at = expires_at data_obj.fetched_at = fetched_at data_obj.save() return False else: SAMLProviderData.objects.create( entity_id=entity_id, fetched_at=fetched_at, expires_at=expires_at, sso_url=sso_url, public_key=public_key ) return True
def _update_data(entity_id, public_key, sso_url, expires_at): """ Update/Create the SAMLProviderData for the given entity ID. Return value: False if nothing has changed and existing data's "fetched at" timestamp is just updated. True if a new record was created. (Either this is a new provider or something changed.) """ data_obj = SAMLProviderData.current(entity_id) fetched_at = datetime.datetime.now() if data_obj and (data_obj.public_key == public_key and data_obj.sso_url == sso_url): data_obj.expires_at = expires_at data_obj.fetched_at = fetched_at data_obj.save() return False else: SAMLProviderData.objects.create( entity_id=entity_id, fetched_at=fetched_at, expires_at=expires_at, sso_url=sso_url, public_key=public_key, ) return True
def configure_saml_provider_data(**kwargs): """ Update the SAML IdP data """ obj = SAMLProviderData(**kwargs) obj.save() return obj