Skip to content

remove user auth for query in list filters #1294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/handlers/http/users/filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::{
parseable::PARSEABLE,
storage::{object_storage::filter_path, ObjectStorageError},
users::filters::{Filter, CURRENT_FILTER_VERSION, FILTERS},
utils::{actix::extract_session_key_from_req, get_hash, get_user_from_request},
utils::{get_hash, get_user_from_request},
};
use actix_web::{
http::header::ContentType,
Expand All @@ -33,10 +33,8 @@ use chrono::Utc;
use http::StatusCode;
use serde_json::Error as SerdeError;

pub async fn list(req: HttpRequest) -> Result<impl Responder, FiltersError> {
let key =
extract_session_key_from_req(&req).map_err(|e| FiltersError::Custom(e.to_string()))?;
let filters = FILTERS.list_filters(&key).await;
pub async fn list() -> Result<impl Responder, FiltersError> {
let filters = FILTERS.list_filters().await;
Ok((web::Json(filters), StatusCode::OK))
}

Expand Down
6 changes: 3 additions & 3 deletions src/prism/home/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub async fn generate_home_response(key: &SessionKey) -> Result<HomeResponse, Pr
get_alert_titles(key),
get_correlation_titles(key),
get_dashboard_titles(key),
get_filter_titles(key),
get_filter_titles(),
get_alerts_info()
);

Expand Down Expand Up @@ -258,9 +258,9 @@ async fn get_dashboard_titles(key: &SessionKey) -> Result<Vec<TitleAndId>, Prism
Ok(dashboard_titles)
}

async fn get_filter_titles(key: &SessionKey) -> Result<Vec<TitleAndId>, PrismHomeError> {
async fn get_filter_titles() -> Result<Vec<TitleAndId>, PrismHomeError> {
let filter_titles = FILTERS
.list_filters(key)
.list_filters()
.await
.iter()
.map(|filter| TitleAndId {
Expand Down
23 changes: 4 additions & 19 deletions src/users/filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ use tokio::sync::RwLock;

use super::TimeFilter;
use crate::{
alerts::alerts_utils::user_auth_for_query, migration::to_bytes, parseable::PARSEABLE,
rbac::map::SessionKey, storage::object_storage::filter_path, utils::get_hash,
migration::to_bytes, parseable::PARSEABLE, storage::object_storage::filter_path,
utils::get_hash,
};

pub static FILTERS: Lazy<Filters> = Lazy::new(Filters::default);
Expand Down Expand Up @@ -152,23 +152,8 @@ impl Filters {
.cloned()
}

pub async fn list_filters(&self, key: &SessionKey) -> Vec<Filter> {
let read = self.0.read().await;

let mut filters = Vec::new();

for f in read.iter() {
let query = if let Some(q) = &f.query.filter_query {
q
} else {
continue;
};

if (user_auth_for_query(key, query).await).is_ok() {
filters.push(f.clone())
}
}
filters
pub async fn list_filters(&self) -> Vec<Filter> {
self.0.read().await.iter().cloned().collect()
}
}

Expand Down
Loading