Skip to content
Snippets Groups Projects
Commit a934a7f6 authored by Jason Volk's avatar Jason Volk
Browse files

freeze remote media via legacy endpoints


Signed-off-by: default avatarJason Volk <jason@zemos.net>
parent 1638be03
No related branches found
No related tags found
2 merge requests!561morguldir/sliding sync fixes,!559Auth Media
...@@ -292,6 +292,8 @@ pub struct Config { ...@@ -292,6 +292,8 @@ pub struct Config {
#[serde(default = "true_fn")] #[serde(default = "true_fn")]
pub allow_legacy_media: bool, pub allow_legacy_media: bool,
#[serde(default = "true_fn")] #[serde(default = "true_fn")]
pub freeze_legacy_media: bool,
#[serde(default = "true_fn")]
pub media_startup_check: bool, pub media_startup_check: bool,
#[serde(default)] #[serde(default)]
pub media_compat_file_link: bool, pub media_compat_file_link: bool,
...@@ -748,6 +750,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ...@@ -748,6 +750,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
line("Media compatibility filesystem links", &self.media_compat_file_link.to_string()); line("Media compatibility filesystem links", &self.media_compat_file_link.to_string());
line("Prune missing media from database", &self.prune_missing_media.to_string()); line("Prune missing media from database", &self.prune_missing_media.to_string());
line("Allow legacy (unauthenticated) media", &self.allow_legacy_media.to_string()); line("Allow legacy (unauthenticated) media", &self.allow_legacy_media.to_string());
line("Freeze legacy (unauthenticated) media", &self.freeze_legacy_media.to_string());
line("Prevent Media Downloads From", { line("Prevent Media Downloads From", {
let mut lst = vec![]; let mut lst = vec![];
for domain in &self.prevent_media_downloads_from { for domain in &self.prevent_media_downloads_from {
......
...@@ -310,6 +310,7 @@ pub async fn fetch_remote_thumbnail_legacy( ...@@ -310,6 +310,7 @@ pub async fn fetch_remote_thumbnail_legacy(
media_id: &body.media_id, media_id: &body.media_id,
}; };
self.check_legacy_freeze()?;
self.check_fetch_authorized(&mxc)?; self.check_fetch_authorized(&mxc)?;
let reponse = self let reponse = self
.services .services
...@@ -342,6 +343,7 @@ pub async fn fetch_remote_thumbnail_legacy( ...@@ -342,6 +343,7 @@ pub async fn fetch_remote_thumbnail_legacy(
pub async fn fetch_remote_content_legacy( pub async fn fetch_remote_content_legacy(
&self, mxc: &Mxc<'_>, allow_redirect: bool, timeout_ms: Duration, &self, mxc: &Mxc<'_>, allow_redirect: bool, timeout_ms: Duration,
) -> Result<media::get_content::v3::Response, Error> { ) -> Result<media::get_content::v3::Response, Error> {
self.check_legacy_freeze()?;
self.check_fetch_authorized(mxc)?; self.check_fetch_authorized(mxc)?;
let response = self let response = self
.services .services
...@@ -391,3 +393,13 @@ fn check_fetch_authorized(&self, mxc: &Mxc<'_>) -> Result<()> { ...@@ -391,3 +393,13 @@ fn check_fetch_authorized(&self, mxc: &Mxc<'_>) -> Result<()> {
Ok(()) Ok(())
} }
#[implement(super::Service)]
fn check_legacy_freeze(&self) -> Result<()> {
self.services
.server
.config
.freeze_legacy_media
.then_some(())
.ok_or(err!(Request(NotFound("Remote media is frozen."))))
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment