Skip to content

Commit 98a2dac

Browse files
committed
crate api-ui #1, almost there
1 parent a5dd462 commit 98a2dac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+464
-360
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ axum-macros = "0.5"
3535
dashmap = "6.1.0"
3636
regex = "1.11"
3737
indexmap = "2.7.1"
38+
time = "0.3.37"
39+
tower-sessions = { version = "0.14.0" }
3840
url = "2.5"
3941
tokio = { version = "1", features = ["full"] }
4042
async-trait = { version = "0.1.84" }

crates/api-sessions/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ core-executor = { path = "../core-executor" }
99

1010
async-trait = { workspace = true }
1111
axum = { workspace = true }
12-
tower-sessions = "0.14"
12+
tower-sessions = { workspace = true }
1313
tokio = { workspace = true }
14-
time = "0.3.37"
14+
time = { workspace = true }
1515
http = { workspace = true }
1616
serde = { workspace = true }
1717
serde_json = { workspace = true }

crates/api-ui/Cargo.toml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,40 @@ edition = "2024"
55
license-file.workspace = true
66

77
[dependencies]
8+
api-sessions = { path = "../api-sessions" }
9+
core-metastore = { path = "../core-metastore" }
10+
core-utils = { path = "../core-utils" }
11+
core-executor = { path = "../core-executor" }
12+
core-history = { path = "../core-history" }
13+
14+
axum = { workspace = true }
15+
chrono = { workspace = true }
16+
datafusion = { workspace = true }
17+
indexmap = { workspace = true }
18+
jsonwebtoken = { workspace = true }
19+
http = { workspace = true }
20+
mime_guess = "2"
21+
serde = { workspace = true }
22+
serde_json = { workspace = true }
23+
snafu = { workspace = true }
24+
tar = { workspace = true }
25+
tokio = { workspace = true }
26+
tracing = { workspace = true }
27+
tower-http = { version = "0.6.1", features = [
28+
"catch-panic",
29+
"timeout",
30+
"sensitive-headers",
31+
"cors",
32+
"trace",
33+
] }
34+
tower-sessions = { workspace = true }
35+
time = { workspace = true }
36+
utoipa = { workspace = true }
37+
uuid = { workspace = true }
38+
validator = { workspace = true }
39+
40+
[dev-dependencies]
41+
reqwest = "0.12.14"
842

943
[lints]
1044
workspace = true
File renamed without changes.

crates/runtime/src/http/auth/handlers.rs renamed to crates/api-ui/src/auth/handlers.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
use crate::http::auth::models::{AccountResponse, RefreshTokenResponse};
1+
use crate::auth::models::{AccountResponse, RefreshTokenResponse};
22
use std::collections::HashMap;
33

44
use super::error::AuthErrorResponse;
55
use super::error::CreateJwtSnafu;
6-
use crate::http::auth::error::{
6+
use crate::auth::error::{
77
AuthError, AuthResult, BadRefreshTokenSnafu, ResponseHeaderSnafu, SetCookieSnafu,
88
TokenErrorKind,
99
};
10-
use crate::http::auth::models::{AuthResponse, Claims, LoginPayload};
11-
use crate::http::state::AppState;
10+
use crate::auth::models::{AuthResponse, Claims, LoginPayload};
11+
use crate::state::AppState;
12+
use axum::Json;
1213
use axum::extract::State;
1314
use axum::response::IntoResponse;
14-
use axum::Json;
1515
use chrono::offset::Local;
16-
use http::header::SET_COOKIE;
1716
use http::HeaderMap;
18-
use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, Validation};
17+
use http::header::SET_COOKIE;
18+
use jsonwebtoken::{DecodingKey, EncodingKey, Header, Validation, decode, encode};
1919
use serde::Serialize;
2020
use snafu::ResultExt;
2121
use time::Duration;

crates/runtime/src/http/auth/layer.rs renamed to crates/api-ui/src/auth/layer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::error::{AuthError, AuthResult, BadAuthTokenSnafu};
22
use super::handlers::get_claims_validate_jwt_token;
3-
use crate::http::state::AppState;
3+
use crate::state::AppState;
44
use axum::{
55
extract::{Request, State},
66
middleware::Next,
File renamed without changes.
File renamed without changes.

crates/runtime/src/http/auth/router.rs renamed to crates/api-ui/src/auth/router.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use crate::http::state::AppState;
2-
use axum::routing::{get, post};
1+
use crate::state::AppState;
32
use axum::Router;
3+
use axum::routing::{get, post};
44

55
use super::handlers::{account, login, logout, refresh_access_token};
66

crates/api-ui/src/config.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
pub use crate::web_assets::config::StaticWebConfig;
2+
use serde::{Deserialize, Serialize};
3+
4+
#[derive(Debug, Clone, Serialize, Deserialize)]
5+
pub struct WebConfig {
6+
pub host: String,
7+
pub port: u16,
8+
pub allow_origin: Option<String>,
9+
}
10+
11+
// Non serializable, no Clone, Copy, Debug traits
12+
#[derive(Default)]
13+
pub struct AuthConfig {
14+
jwt_secret: String,
15+
demo_user: String,
16+
demo_password: String,
17+
}
18+
19+
impl AuthConfig {
20+
#[must_use]
21+
pub fn new(jwt_secret: String) -> Self {
22+
Self {
23+
jwt_secret,
24+
..Self::default()
25+
}
26+
}
27+
28+
pub fn with_demo_credentials(&mut self, demo_user: String, demo_password: String) {
29+
self.demo_user = demo_user;
30+
self.demo_password = demo_password;
31+
}
32+
33+
#[must_use]
34+
pub fn jwt_secret(&self) -> &str {
35+
&self.jwt_secret
36+
}
37+
38+
#[must_use]
39+
pub fn demo_user(&self) -> &str {
40+
&self.demo_user
41+
}
42+
43+
#[must_use]
44+
pub fn demo_password(&self) -> &str {
45+
&self.demo_password
46+
}
47+
}

0 commit comments

Comments
 (0)