Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,14 @@ pub struct Options {
)]
pub querier_endpoint: String,

#[arg(
long,
env = "P_PRISM_ENDPOINT",
default_value = "",
help = "URL to connect to the prism node. Default is the address of the server"
)]
pub prism_endpoint: String,

#[command(flatten)]
pub oidc: Option<OidcConfig>,

Expand Down Expand Up @@ -593,6 +601,7 @@ impl Options {
Mode::Ingest => self.get_endpoint(&self.ingestor_endpoint, "P_INGESTOR_ENDPOINT"),
Mode::Index => self.get_endpoint(&self.indexer_endpoint, "P_INDEXER_ENDPOINT"),
Mode::Query => self.get_endpoint(&self.querier_endpoint, "P_QUERIER_ENDPOINT"),
Mode::Prism => self.get_endpoint(&self.prism_endpoint, "P_PRISM_ENDPOINT"),
_ => return self.build_url(&self.address),
};

Expand Down
8 changes: 5 additions & 3 deletions src/handlers/http/oidc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use tokio::sync::RwLock;
use ulid::Ulid;
use url::Url;

use crate::utils::login_sync;
use crate::utils::{login_sync, logout_sync};
use crate::{
handlers::{
COOKIE_AGE_DAYS, SESSION_COOKIE_NAME, USER_COOKIE_NAME, USER_ID_COOKIE_NAME,
Expand Down Expand Up @@ -176,14 +176,16 @@ pub async fn logout(req: HttpRequest, query: web::Query<RedirectAfterLogin>) ->
None
};

match (user, logout_endpoint) {
let res = match (user, logout_endpoint) {
(Some(username), Some(logout_endpoint))
if Users.is_oauth(&username, &tenant_id).unwrap_or_default() =>
{
redirect_to_oidc_logout(logout_endpoint, &query.redirect)
}
_ => redirect_to_client(query.redirect.as_str(), None),
}
};
let _ = logout_sync(session, &tenant_id).await;
res
}

/// Handler for code callback
Expand Down
1 change: 0 additions & 1 deletion src/rbac/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,6 @@ impl UserGroup {
// validate that the users exist and no protected user is included
if let Some(tenant_users) = users().get(tenant) {
for group_user in &self.users {
tracing::warn!(group_user=?group_user);
if let Some(user) = tenant_users.get(group_user.userid())
&& !user.protected
&& user.tenant.eq(tenant_id)
Expand Down
44 changes: 38 additions & 6 deletions src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ pub async fn user_auth_for_datasets(
Some(ParseableResourceType::Stream(stream)),
) => {
if !PARSEABLE.check_or_load_stream(stream, tenant_id).await {
tracing::warn!("unable to find stream");
return Err(actix_web::error::ErrorUnauthorized(format!(
"Stream not found: {table_name}"
)));
Expand Down Expand Up @@ -254,11 +253,14 @@ pub fn create_intracluster_auth_headermap(
reqwest::header::AUTHORIZATION,
reqwest::header::HeaderValue::from_bytes(auth.as_bytes()).unwrap(),
);
} else if let Some(auth) = req.get(actix_web::http::header::COOKIE) {
map.insert(
reqwest::header::COOKIE,
reqwest::header::HeaderValue::from_bytes(auth.as_bytes()).unwrap(),
);
} else if req.contains_key(actix_web::http::header::COOKIE) {
// multiple cookies
for cookie in req.get_all(actix_web::http::header::COOKIE) {
map.insert(
reqwest::header::COOKIE,
reqwest::header::HeaderValue::from_bytes(cookie.as_bytes()).unwrap(),
);
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
} else {
map.insert(
reqwest::header::AUTHORIZATION,
Expand Down Expand Up @@ -303,3 +305,33 @@ pub async fn login_sync(
})
.await
}

pub async fn logout_sync(
session: SessionKey,
tenant_id: &Option<String>,
) -> Result<(), anyhow::Error> {
for_each_live_node(tenant_id, move |node| {
let url = format!(
"{}{}/o/logout/sync",
node.domain_name,
base_path_without_preceding_slash(),
);
let _session = session.clone();

async move {
INTRA_CLUSTER_CLIENT
.post(url)
.header(header::AUTHORIZATION, node.token)
.header(header::CONTENT_TYPE, "application/json")
.json(&json!(
{
"sessionKey": _session
}
))
.send()
.await?;
Ok::<(), anyhow::Error>(())
}
})
.await
}
Loading