feat: more federation policies
also allow to prevent access via http signatures or straight out reject all fetches. note that this last option is rather ineffective as remotes can just fetch public objects anonimously
This commit is contained in:
parent
95d1ab948f
commit
e600fbed0f
2 changed files with 16 additions and 4 deletions
|
@ -136,6 +136,12 @@ pub struct RejectConfig {
|
||||||
|
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub delivery: Vec<String>,
|
pub delivery: Vec<String>,
|
||||||
|
|
||||||
|
#[serde(default)]
|
||||||
|
pub fetch: Vec<String>,
|
||||||
|
|
||||||
|
#[serde(default)]
|
||||||
|
pub access: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
|
|
|
@ -150,10 +150,16 @@ where
|
||||||
return Err(ApiError::unauthorized());
|
return Err(ApiError::unauthorized());
|
||||||
}
|
}
|
||||||
|
|
||||||
let internal = upub::model::instance::Entity::domain_to_internal(&user.domain, ctx.db())
|
if ctx.cfg().reject.fetch.contains(&user.domain) {
|
||||||
.await?
|
return Err(ApiError::Status(axum::http::StatusCode::UNAVAILABLE_FOR_LEGAL_REASONS));
|
||||||
.ok_or_else(ApiError::internal_server_error)?; // user but not their domain???
|
}
|
||||||
identity = Identity::Remote { user: user.id, domain: user.domain, internal };
|
|
||||||
|
if !ctx.cfg().reject.access.contains(&user.domain) {
|
||||||
|
let internal = upub::model::instance::Entity::domain_to_internal(&user.domain, ctx.db())
|
||||||
|
.await?
|
||||||
|
.ok_or_else(ApiError::internal_server_error)?; // user but not their domain???
|
||||||
|
identity = Identity::Remote { user: user.id, domain: user.domain, internal };
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue