forked from forks/microblog.pub
Enable authenticated fetches
This commit is contained in:
parent
6bb619d6ad
commit
9768e673d7
2 changed files with 6 additions and 4 deletions
|
@ -10,13 +10,13 @@ from little_boxes import activitypub as ap
|
|||
from little_boxes.errors import ActivityGoneError
|
||||
from little_boxes.errors import ActivityNotFoundError
|
||||
from little_boxes.errors import NotAnActivityError
|
||||
from little_boxes.httpsig import HTTPSigAuth
|
||||
from requests.exceptions import HTTPError
|
||||
|
||||
import config
|
||||
from config import DB
|
||||
from config import MEDIA_CACHE
|
||||
from core import gc
|
||||
from core.activitypub import SIG_AUTH
|
||||
from core.activitypub import Box
|
||||
from core.activitypub import _actor_hash
|
||||
from core.activitypub import _add_answers_to_question
|
||||
|
@ -41,8 +41,6 @@ from core.tasks import Tasks
|
|||
from utils import now
|
||||
from utils import opengraph
|
||||
|
||||
SIG_AUTH = HTTPSigAuth(config.KEY)
|
||||
|
||||
blueprint = flask.Blueprint("tasks", __name__)
|
||||
|
||||
|
||||
|
|
|
@ -23,11 +23,13 @@ from little_boxes.activitypub import clean_activity
|
|||
from little_boxes.activitypub import format_datetime
|
||||
from little_boxes.backend import Backend
|
||||
from little_boxes.errors import ActivityGoneError
|
||||
from little_boxes.httpsig import HTTPSigAuth
|
||||
|
||||
from config import BASE_URL
|
||||
from config import DB
|
||||
from config import EXTRA_INBOXES
|
||||
from config import ID
|
||||
from config import KEY
|
||||
from config import ME
|
||||
from config import USER_AGENT
|
||||
from core.db import update_many_activities
|
||||
|
@ -41,6 +43,7 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
_NewMeta = Dict[str, Any]
|
||||
|
||||
SIG_AUTH = HTTPSigAuth(KEY)
|
||||
|
||||
_ACTIVITY_CACHE_ENABLED = True
|
||||
ACTORS_CACHE = LRUCache(maxsize=256)
|
||||
|
@ -364,7 +367,8 @@ class MicroblogPubBackend(Backend):
|
|||
data = self._fetch_iri(iri)
|
||||
logger.debug(f"_fetch_iri({iri!r}) == {data!r}")
|
||||
else:
|
||||
data = super().fetch_iri(iri)
|
||||
# Pass the SIG_AUTH to enable "authenticated fetch"
|
||||
data = super().fetch_iri(iri, auth=SIG_AUTH)
|
||||
logger.debug(f"fetch_iri({iri!r}) == {data!r}")
|
||||
|
||||
return data
|
||||
|
|
Loading…
Reference in a new issue