Skip to content

Commit

Permalink
remove api keys validation module (#6277)
Browse files Browse the repository at this point in the history
Co-authored-by: Henry Fontanier <[email protected]>
  • Loading branch information
fontanierh and Henry Fontanier authored Jul 17, 2024
1 parent d8c57fc commit 8010595
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
6 changes: 3 additions & 3 deletions core/bin/dust_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::{anyhow, Result};
use axum::{
extract::{DefaultBodyLimit, Path, Query, State},
http::header::HeaderMap,
middleware::from_fn,
// middleware::from_fn,
response::{
sse::{Event, KeepAlive, Sse},
Json,
Expand All @@ -11,7 +11,7 @@ use axum::{
Router,
};
use dust::{
api_keys::validate_api_key,
// api_keys::validate_api_key,
app,
blocks::block::BlockType,
data_sources::{
Expand Down Expand Up @@ -2689,7 +2689,7 @@ fn main() {

let sqlite_heartbeat_router = Router::new()
.route("/sqlite_workers", post(sqlite_workers_heartbeat))
.layer(from_fn(validate_api_key))
// .layer(from_fn(validate_api_key))
.with_state(state.clone());

let health_check_router = Router::new().route("/", get(index));
Expand Down
11 changes: 8 additions & 3 deletions core/src/api_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use lazy_static::lazy_static;
use serde::Deserialize;
use std::{collections::HashMap, env, sync::Arc};
use tokio::{fs, sync::OnceCell};
use tracing::error;
use tracing::{error, warn};

lazy_static! {
static ref DISABLE_API_KEY_CHECK: bool = env::var("DISABLE_API_KEY_CHECK")
Expand All @@ -31,8 +31,13 @@ async fn init_api_keys() -> Result<ApiKeyMap> {
Err(_) => "[]".to_string(),
};

let api_keys: Vec<ApiKeyEntry> = serde_json::from_str(&api_keys_json)
.map_err(|e| anyhow!("Failed to parse API keys JSON: {}", e))?;
let api_keys: Vec<ApiKeyEntry> = match serde_json::from_str(&api_keys_json) {
Ok(keys) => keys,
Err(e) => {
warn!("Failed to parse API keys: {}", e);
return Err(anyhow!("Failed to parse API keys"));
}
};

let mut map = HashMap::new();
for entry in api_keys {
Expand Down
2 changes: 1 addition & 1 deletion core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ pub mod oauth {
}
}

pub mod api_keys;
// pub mod api_keys;

0 comments on commit 8010595

Please sign in to comment.