Skip to content

Commit

Permalink
Make OIDC an optional feature
Browse files Browse the repository at this point in the history
  • Loading branch information
pka committed Jun 22, 2023
1 parent 81a81ec commit 240bc3d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
5 changes: 3 additions & 2 deletions bbox-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edition = "2018"

[features]
html = []
oidc = ["openidconnect", "reqwest"]

[dependencies]
actix-session = { version = "0.7", features = ["cookie-session"] }
Expand All @@ -24,12 +25,12 @@ mime_guess = "2.0.3"
minijinja = { workspace = true }
num_cpus = { workspace = true }
once_cell = "1.8.0"
openidconnect = "3.2.0"
openidconnect = { version = "3.2.0", optional = true }
opentelemetry = { workspace = true }
opentelemetry-jaeger = { version = "0.17", features = ["rt-tokio"] }
opentelemetry-prometheus = { version = "0.11" }
prometheus = { workspace = true }
reqwest = { workspace = true }
reqwest = { workspace = true, optional = true }
rust-embed = { workspace = true }
rustls = "0.20.8" # Same as actix-tls -> tokio-rustls
rustls-pemfile = "1.0.2"
Expand Down
32 changes: 32 additions & 0 deletions bbox-common/src/auth/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
#[cfg(feature = "oidc")]
pub mod oidc;

pub struct Identity {
pub username: String,
pub groups: Vec<String>,
}

#[cfg(not(feature = "oidc"))]
pub mod oidc {
use super::Identity;
use serde::Deserialize;

type AuthError = std::io::Error;

#[derive(Deserialize, Default, Clone, Debug)]
pub struct OidcAuthCfg;

#[derive(Default, Clone)]
pub struct OidcClient {
pub authorize_url: String,
}

impl OidcClient {
pub async fn from_config(_cfg: &OidcAuthCfg) -> Self {
Self::default()
}
}

#[derive(Deserialize)]
pub struct AuthRequest;

impl AuthRequest {
pub async fn auth(&self, _oidc: &OidcClient) -> Result<Identity, AuthError> {
unimplemented!()
}
}
}

0 comments on commit 240bc3d

Please sign in to comment.