diff --git a/opds.py b/opds.py index 1d17487eaa..c8d6dbc240 100644 --- a/opds.py +++ b/opds.py @@ -18,14 +18,11 @@ Pagination, SearchFacets, ) -from .lcp.credential import LCPCredentialFactory -from .lcp.exceptions import LCPError from .model import ( CachedFeed, Contributor, DataSource, Edition, - ExternalIntegration, Hyperlink, Identifier, Measurement, @@ -1690,33 +1687,6 @@ def acquisition_link(cls, rel, href, types, active_loan=None): link = cls.link(rel, href, initial_type) indirect = cls.indirect_acquisition(indirect_types) - # In the case of LCP we have to include a patron's hashed passphrase - # inside the acquisition link so client applications can use it to bypass authentication - # and will not ask patrons to enter their passphrases - # For more information please look here: - # https://readium.org/lcp-specs/notes/lcp-key-retrieval.html#including-a-hashed-passphrase-in-an-opds-1-catalog - if active_loan and active_loan.license_pool.collection.protocol in [ - ExternalIntegration.LCP, - ExternalIntegration.ODL, - ExternalIntegration.ODL2, - ]: - db = Session.object_session(active_loan) - lcp_credential_factory = LCPCredentialFactory() - - try: - hashed_passphrase = lcp_credential_factory.get_hashed_passphrase( - db, active_loan.patron - ) - hashed_passphrase_element = AtomFeed.makeelement( - "{%s}hashed_passphrase" % AtomFeed.LCP_NS - ) - hashed_passphrase_element.text = hashed_passphrase - - link.append(hashed_passphrase_element) - except LCPError: - # The patron's passphrase wasn't generated yet and not present in the database. - pass - if indirect is not None: link.append(indirect) return link diff --git a/tests/test_opds.py b/tests/test_opds.py index d880cc4b10..e41efd1a66 100644 --- a/tests/test_opds.py +++ b/tests/test_opds.py @@ -1,6 +1,5 @@ import datetime import logging -import re import xml.etree.ElementTree as ET from io import StringIO @@ -26,7 +25,6 @@ from ..external_search import MockExternalSearchIndex from ..facets import FacetConstants from ..lane import Facets, FeaturedFacets, Pagination, SearchFacets, WorkList -from ..lcp.credential import LCPCredentialFactory from ..model import ( CachedFeed, Contributor, @@ -545,38 +543,6 @@ def test_acquisition_feed_includes_permanent_work_id(self): entry = parsed["entries"][0] assert work.presentation_edition.permanent_work_id == entry["simplified_pwid"] - def test_lcp_acquisition_link_contains_hashed_passphrase(self): - # Arrange - lcp_collection = self._collection(protocol=ExternalIntegration.LCP) - data_source = DataSource.lookup(self._db, DataSource.LCP, autocreate=True) - data_source_name = data_source.name - license_pool = self._licensepool( - edition=None, data_source_name=data_source_name, collection=lcp_collection - ) - hashed_passphrase = "12345" - patron = self._patron() - lcp_credential_factory = LCPCredentialFactory() - loan, _ = license_pool.loan_to(patron) - rel = AcquisitionFeed.ACQUISITION_REL - href = self._url - types = [DeliveryMechanism.LCP_DRM, Representation.EPUB_MEDIA_TYPE] - expected_result = ( - '' - '{1}' - '' - "" - ).format(href, hashed_passphrase) - - # Act - lcp_credential_factory.set_hashed_passphrase( - self._db, patron, hashed_passphrase - ) - acquisition_link = AcquisitionFeed.acquisition_link(rel, href, types, loan) - - # Assert - self._assert_xml_equal(acquisition_link, expected_result) - def test_lane_feed_contains_facet_links(self): work = self._work(with_open_access_download=True) @@ -2261,7 +2227,7 @@ def feed(self, annotator=VerboseAnnotator, **kwargs): "http://whatever.io", [], annotator=annotator, - **kwargs + **kwargs, ) def entry(self, identifier, work, annotator=VerboseAnnotator, **kwargs):