Skip to content
Merged
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
4 changes: 2 additions & 2 deletions central/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "central"
version = "0.1.0"
version = "0.2.0"
edition = "2021"
license = "Apache-2.0"

Expand All @@ -19,6 +19,6 @@ anyhow = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
urlencoding = "2.1.3"
chrono = "0.4"
icinga-client = { git = "https://github.com/samply/icinga-client.git", tag = "v0.1.0", version = "0.1.0" }
toml = "0.8.20"
time = { version = "0.3.41", features = ["serde", "parsing", "macros", "formatting"] }
4 changes: 2 additions & 2 deletions central/src/auth/authentik/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ pub async fn validate_application(

pub async fn create_app_provider(
name: &str,
oidc_client_config: OIDCConfig,
oidc_client_config: &OIDCConfig,
conf: &AuthentikConfig,
) -> anyhow::Result<SecretResult> {
let token = get_access_token(conf).await?;
combine_app_provider(&token, name, &oidc_client_config, conf).await
combine_app_provider(&token, name, oidc_client_config, conf).await
}

pub async fn combine_app_provider(
Expand Down
2 changes: 1 addition & 1 deletion central/src/auth/keycloak/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub struct KeyCloakConfig {

pub async fn create_client(
name: &str,
oidc_client_config: OIDCConfig,
oidc_client_config: &OIDCConfig,
conf: &KeyCloakConfig,
) -> anyhow::Result<SecretResult> {
let token = get_access_token(conf).await?;
Expand Down
22 changes: 20 additions & 2 deletions central/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{convert::Infallible, path::PathBuf};

use beam_lib::{reqwest::Url, AppId};
use clap::Parser;
use shared::{OIDCConfig, SecretResult};
use shared::{OIDCConfig, RequestType, SecretResult};

use crate::auth::{
authentik::{self, AuthentikConfig},
Expand Down Expand Up @@ -47,10 +47,28 @@ impl OIDCProvider {
}
}

pub async fn handle_secret_request(
&self,
request_type: RequestType,
oidc_client_config: &OIDCConfig,
from: &AppId,
) -> Result<SecretResult, String> {
let name = from.as_ref().split('.').nth(1).unwrap();
match request_type {
RequestType::ValidateOrCreate(current) if self.validate_client(
name,
&current,
oidc_client_config,
).await? =>
Ok(SecretResult::AlreadyValid),
_ => self.create_client(name, oidc_client_config).await,
}
}

pub async fn create_client(
&self,
name: &str,
oidc_client_config: OIDCConfig,
oidc_client_config: &OIDCConfig,
) -> Result<SecretResult, String> {
match self {
OIDCProvider::Keycloak(conf) => {
Expand Down
Loading