mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-07-03 22:45:01 +00:00
Add support for admin routes
This commit is contained in:
@ -51,6 +51,7 @@ pub struct Config {
|
||||
pub independent_push_service: Option<IndependentPushService>,
|
||||
pub database: DatabaseConfig,
|
||||
pub rtc_relay: Option<RtcRelayConfig>,
|
||||
pub admin_url: String,
|
||||
pub forez_groups: Vec<GroupID>,
|
||||
}
|
||||
|
||||
@ -152,6 +153,8 @@ impl Config {
|
||||
|
||||
rtc_relay: rtc_config,
|
||||
|
||||
admin_url: Self::yaml_str(parsed, "admin-url"),
|
||||
|
||||
forez_groups: parsed["forez_groups"]
|
||||
.as_vec()
|
||||
.unwrap_or(&vec![])
|
||||
|
@ -129,6 +129,17 @@ impl HttpRequestHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Check admin origin
|
||||
pub fn check_admin_origin(&mut self) -> Res {
|
||||
if let Some(header) = self.request.headers().get("Origin") {
|
||||
if header.to_str()?.eq(&conf().admin_url) {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
self.bad_request("Invalid origin for admin requests!".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl BaseRequestHandler for HttpRequestHandler {
|
||||
|
Reference in New Issue
Block a user