diff --git a/backend/src/ee_oss.rs b/backend/src/ee_oss.rs index 4bbcd4e53b..d210e0118d 100644 --- a/backend/src/ee_oss.rs +++ b/backend/src/ee_oss.rs @@ -1,8 +1 @@ -pub async fn set_license_key(license_key: String) -> () { - crate::ee::set_license_key(license_key).await -} - -#[cfg(feature = "enterprise")] -pub async fn verify_license_key() -> () { - crate::ee::verify_license_key().await -} +pub use crate::ee::*; diff --git a/backend/windmill-api/src/agent_workers_oss.rs b/backend/windmill-api/src/agent_workers_oss.rs index 1b5a210d13..ff7809e022 100644 --- a/backend/windmill-api/src/agent_workers_oss.rs +++ b/backend/windmill-api/src/agent_workers_oss.rs @@ -1,52 +1 @@ -/* - * Author: Ruben Fiszel - * Copyright: Windmill Labs, Inc 2042 - * This file and its contents are licensed under the AGPLv3 License. - * Please see the included NOTICE for copyright information and - * LICENSE-AGPL for a copy of the license. - */ - -use crate::db::DB; - -use axum::Router; - -use serde::{Deserialize, Serialize}; - -pub fn global_service() -> Router { - Router::new() -} - -pub fn workspaced_service( - db: DB, - _base_internal_url: String, -) -> ( - Router, - Vec>, - Option, -) { - use windmill_common::worker::Connection; - use windmill_worker::JobCompletedSender; - - let (job_completed_tx, _job_completed_rx) = - JobCompletedSender::new(&Connection::Sql(db.clone()), 10); - - let router = Router::new(); - - (router, vec![], Some(job_completed_tx)) -} - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct AgentAuth { - pub worker_group: String, - pub suffix: Option, - pub tags: Vec, - pub exp: Option, -} - -pub struct AgentCache {} - -impl AgentCache { - pub fn new() -> Self { - AgentCache {} - } -} +pub use crate::agent_workers_ee::*; diff --git a/backend/windmill-api/src/apps_oss.rs b/backend/windmill-api/src/apps_oss.rs index a7737664b9..1dc9afd308 100644 --- a/backend/windmill-api/src/apps_oss.rs +++ b/backend/windmill-api/src/apps_oss.rs @@ -1,5 +1 @@ -use axum::Router; - -pub fn global_unauthed_service() -> Router { - Router::new() -} +pub use crate::apps_ee::*; diff --git a/backend/windmill-api/src/ee_oss.rs b/backend/windmill-api/src/ee_oss.rs index cddb639e95..d210e0118d 100644 --- a/backend/windmill-api/src/ee_oss.rs +++ b/backend/windmill-api/src/ee_oss.rs @@ -1,32 +1 @@ -use anyhow::anyhow; -#[cfg(feature = "enterprise")] -use std::sync::Arc; -#[cfg(feature = "enterprise")] -use tokio::sync::RwLock; - -pub async fn validate_license_key(_license_key: String) -> anyhow::Result<(String, bool)> { - // Implementation is not open source - Err(anyhow!("License can't be validated in Windmill CE")) -} - -#[cfg(feature = "enterprise")] -pub async fn jwt_ext_auth( - _w_id: Option<&String>, - _token: &str, - _external_jwks: Option>>, -) -> anyhow::Result<(crate::db::ApiAuthed, usize)> { - // Implementation is not open source - - Err(anyhow!("External JWT auth is not open source")) -} - -#[cfg(feature = "enterprise")] -pub struct ExternalJwks; - -#[cfg(feature = "enterprise")] -impl ExternalJwks { - pub async fn load() -> Option>> { - // Implementation is not open source - None - } -} +pub use crate::ee::*; diff --git a/backend/windmill-api/src/gcp_triggers_oss.rs b/backend/windmill-api/src/gcp_triggers_oss.rs index 0dc672580c..80ac28a154 100644 --- a/backend/windmill-api/src/gcp_triggers_oss.rs +++ b/backend/windmill-api/src/gcp_triggers_oss.rs @@ -1,147 +1 @@ -use crate::db::{ApiAuthed, DB}; -use crate::trigger_helpers::TriggerJobArgs; -use axum::{extract::Request, Router}; -use http::HeaderMap; -use serde::{Deserialize, Serialize}; -use serde_json::value::RawValue; -use sqlx::prelude::FromRow; -use sqlx::types::Json as SqlxJson; -use std::collections::HashMap; -use windmill_common::db::UserDB; -use windmill_common::worker::to_raw_value; -use windmill_common::{ - error::{Error as WindmillError, Result as WindmillResult}, - triggers::TriggerKind, - utils::empty_as_none, -}; - -#[derive(sqlx::Type, Debug, Deserialize, Serialize)] -#[serde(rename_all(serialize = "lowercase", deserialize = "lowercase"))] -#[sqlx(type_name = "DELIVERY_MODE", rename_all = "lowercase")] -#[allow(unused)] -pub enum DeliveryType { - Pull, - Push, -} - -impl Default for DeliveryType { - fn default() -> Self { - Self::Pull - } -} - -#[derive(FromRow, Deserialize, Serialize, Debug)] -#[allow(unused)] -pub struct PushConfig { - #[serde(deserialize_with = "empty_as_none")] - route_path: Option, - #[serde(deserialize_with = "empty_as_none")] - audience: Option, - authenticate: bool, - base_endpoint: String, -} -#[derive(Default, Debug, Serialize, Deserialize)] -#[allow(unused)] -pub struct CreateUpdateConfig { - pub delivery_type: DeliveryType, - #[serde(default, deserialize_with = "empty_as_none")] - pub subscription_id: Option, - pub delivery_config: Option>, -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct ExistingGcpSubscription { - pub subscription_id: String, - pub base_endpoint: String, -} - -#[derive(Debug, Deserialize, Serialize, sqlx::Type)] -#[serde(rename_all = "snake_case")] -#[sqlx(type_name = "GCP_SUBSCRIPTION_MODE", rename_all = "snake_case")] -pub enum SubscriptionMode { - Existing, - CreateUpdate, -} - -pub fn workspaced_service() -> Router { - Router::new() -} - -pub fn start_consuming_gcp_pubsub_event( - _db: DB, - mut _killpill_rx: tokio::sync::broadcast::Receiver<()>, -) -> () { - // implementation is not open source -} - -pub async fn manage_google_subscription( - _authed: ApiAuthed, - _db: &DB, - _workspace_id: &str, - _gcp_resource_path: &str, - _path: &str, - _topic_id: &str, - _subscription_id: &mut Option, - _base_endpoint: &mut Option, - _subscription_mode: SubscriptionMode, - _create_update_config: Option, - _trigger_mode: bool, - _is_flow: bool, -) -> WindmillResult { - Ok(CreateUpdateConfig::default()) -} - -pub async fn process_google_push_request( - _headers: HeaderMap, - _request: Request, -) -> Result<(String, HashMap>), WindmillError> { - Ok((String::new(), HashMap::new())) -} - -pub async fn validate_jwt_token( - _db: &DB, - _user_db: UserDB, - _authed: ApiAuthed, - _headers: &HeaderMap, - _gcp_resource_path: &str, - _workspace_id: &str, - _delivery_config: &PushConfig, -) -> Result<(), windmill_common::error::Error> { - Ok(()) -} - -pub fn gcp_push_route_handler() -> Router { - Router::new() -} - -#[derive(FromRow, Deserialize, Serialize, Debug)] -pub struct GcpTrigger { - pub gcp_resource_path: String, - pub subscription_id: String, - pub delivery_type: DeliveryType, - pub delivery_config: Option>, - pub subscription_mode: SubscriptionMode, - pub topic_id: String, - pub path: String, - pub script_path: String, - pub is_flow: bool, - pub workspace_id: String, - pub edited_by: String, - pub email: String, - pub edited_at: chrono::DateTime, - pub extra_perms: Option, - pub error: Option, - pub server_id: Option, - pub last_server_ping: Option>, - pub enabled: bool, -} - -impl TriggerJobArgs for GcpTrigger { - fn v1_payload_fn(payload: String) -> HashMap> { - HashMap::from([("payload".to_string(), to_raw_value(&payload))]) - } - - fn trigger_kind() -> TriggerKind { - TriggerKind::Gcp - } -} +pub use crate::gcp_triggers_ee::*; diff --git a/backend/windmill-api/src/git_sync_oss.rs b/backend/windmill-api/src/git_sync_oss.rs index b72afac189..bd27983851 100644 --- a/backend/windmill-api/src/git_sync_oss.rs +++ b/backend/windmill-api/src/git_sync_oss.rs @@ -1,9 +1 @@ -use axum::routing::Router; - -pub fn workspaced_service() -> Router { - Router::new() -} - -pub fn global_service() -> Router { - Router::new() -} \ No newline at end of file +pub use crate::git_sync_ee::*; diff --git a/backend/windmill-api/src/indexer_oss.rs b/backend/windmill-api/src/indexer_oss.rs index 2ccca92c27..1dedecf39c 100644 --- a/backend/windmill-api/src/indexer_oss.rs +++ b/backend/windmill-api/src/indexer_oss.rs @@ -1,9 +1 @@ -use axum::Router; - -pub fn workspaced_service() -> Router { - Router::new() -} - -pub fn global_service() -> Router { - Router::new() -} +pub use crate::indexer_ee::*; diff --git a/backend/windmill-api/src/job_helpers_oss.rs b/backend/windmill-api/src/job_helpers_oss.rs index 4e14d16c5f..37f84fc48d 100644 --- a/backend/windmill-api/src/job_helpers_oss.rs +++ b/backend/windmill-api/src/job_helpers_oss.rs @@ -1,121 +1 @@ -use axum::Router; -use serde::Serialize; -use uuid::Uuid; -use windmill_common::s3_helpers::StorageResourceType; - -#[cfg(feature = "parquet")] -use crate::db::{ApiAuthed, DB}; -#[cfg(feature = "parquet")] -use object_store::{ObjectStore, PutMultipartOpts}; -#[cfg(feature = "parquet")] -use std::sync::Arc; -use windmill_common::error; -#[cfg(feature = "parquet")] -use windmill_common::{db::UserDB, s3_helpers::ObjectStoreResource}; - -#[cfg(feature = "parquet")] -use bytes::Bytes; -#[cfg(feature = "parquet")] -use futures::Stream; - -#[cfg(feature = "parquet")] -use axum::response::Response; -#[cfg(feature = "parquet")] -use serde::Deserialize; - -#[derive(Serialize)] -pub struct UploadFileResponse { - pub file_key: String, -} - -#[derive(Deserialize)] -pub struct LoadImagePreviewQuery { - #[allow(dead_code)] - pub file_key: String, - #[allow(dead_code)] - pub storage: Option, -} - -#[derive(Deserialize)] -pub struct DownloadFileQuery { - #[allow(dead_code)] - pub file_key: String, - #[allow(dead_code)] - pub storage: Option, - #[allow(dead_code)] - pub s3_resource_path: Option, -} - -pub fn workspaced_service() -> Router { - Router::new() -} - -#[cfg(feature = "parquet")] -pub async fn get_workspace_s3_resource<'c>( - _authed: &ApiAuthed, - _db: &DB, - _user_db: Option, - _token: &str, - _w_id: &str, - _storage: Option, -) -> windmill_common::error::Result<(Option, Option)> { - // implementation is not open source - Ok((None, None)) -} - -pub fn get_random_file_name(_file_extension: Option) -> String { - unimplemented!("Not implemented in Windmill's Open Source repository") -} - -pub async fn get_s3_resource<'c>( - _authed: &ApiAuthed, - _db: &DB, - _user_db: Option, - _token: &str, - _w_id: &str, - _resource_path: &str, - _resource_type: Option, - _job_id: Option, -) -> error::Result { - Err(error::Error::internal_err( - "Not implemented in Windmill's Open Source repository".to_string(), - )) -} - -#[cfg(feature = "parquet")] -pub async fn upload_file_from_req( - _s3_client: Arc, - _file_key: &str, - _req: axum::extract::Request, - _options: PutMultipartOpts, -) -> error::Result<()> { - Err(error::Error::internal_err( - "Not implemented in Windmill's Open Source repository".to_string(), - )) -} - -#[cfg(feature = "parquet")] -pub async fn upload_file_internal( - _s3_client: Arc, - _file_key: &str, - _stream: impl Stream> + Unpin, - _options: PutMultipartOpts, -) -> error::Result<()> { - Err(error::Error::internal_err( - "Not implemented in Windmill's Open Source repository".to_string(), - )) -} - -#[cfg(feature = "parquet")] -pub async fn download_s3_file_internal( - _authed: ApiAuthed, - _db: &DB, - _user_db: Option, - _token: &str, - _w_id: &str, - _query: DownloadFileQuery, -) -> error::Result { - Err(error::Error::internal_err( - "Not implemented in Windmill's Open Source repository".to_string(), - )) -} +pub use crate::job_helpers_ee::*; diff --git a/backend/windmill-api/src/kafka_triggers_oss.rs b/backend/windmill-api/src/kafka_triggers_oss.rs index 0a24151ae3..9e0d40ba13 100644 --- a/backend/windmill-api/src/kafka_triggers_oss.rs +++ b/backend/windmill-api/src/kafka_triggers_oss.rs @@ -1,42 +1 @@ -use crate::db::DB; -use axum::Router; -use serde::{Deserialize, Serialize}; - -#[derive(Serialize, Deserialize)] -pub struct KafkaResourceSecurity {} - -pub fn workspaced_service() -> Router { - Router::new() -} - -pub fn start_kafka_consumers( - _db: DB, - mut _killpill_rx: tokio::sync::broadcast::Receiver<()>, -) -> () { - // implementation is not open source -} - -#[derive(Serialize, Deserialize)] -pub enum KafkaTriggerConfigConnection {} - -#[derive(Serialize, Clone)] -pub struct KafkaTrigger { - pub workspace_id: String, - pub path: String, - pub kafka_resource_path: String, - pub group_id: String, - pub topics: Vec, - pub script_path: String, - pub is_flow: bool, - pub edited_by: String, - pub email: String, - pub edited_at: chrono::DateTime, - #[serde(skip_serializing_if = "Option::is_none")] - pub server_id: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub last_server_ping: Option>, - pub extra_perms: serde_json::Value, - #[serde(skip_serializing_if = "Option::is_none")] - pub error: Option, - pub enabled: bool, -} \ No newline at end of file +pub use crate::kafka_triggers_ee::*; diff --git a/backend/windmill-api/src/nats_triggers_oss.rs b/backend/windmill-api/src/nats_triggers_oss.rs index 649d3a3837..a661ea44d8 100644 --- a/backend/windmill-api/src/nats_triggers_oss.rs +++ b/backend/windmill-api/src/nats_triggers_oss.rs @@ -1,43 +1 @@ -use crate::db::DB; -use axum::Router; -use serde::{Deserialize, Serialize}; - -#[derive(Serialize, Deserialize)] -pub struct NatsResourceAuth {} - -pub fn workspaced_service() -> Router { - Router::new() -} - -pub fn start_nats_consumers(_db: DB, mut _killpill_rx: tokio::sync::broadcast::Receiver<()>) -> () { - // implementation is not open source -} - -#[derive(Serialize, Deserialize)] -pub enum NatsTriggerConfigConnection {} - -#[derive(Serialize, Clone)] -pub struct NatsTrigger { - pub workspace_id: String, - pub path: String, - pub nats_resource_path: String, - pub subjects: Vec, - #[serde(skip_serializing_if = "Option::is_none")] - pub stream_name: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub consumer_name: Option, - pub use_jetstream: bool, - pub script_path: String, - pub is_flow: bool, - pub edited_by: String, - pub email: String, - pub edited_at: chrono::DateTime, - #[serde(skip_serializing_if = "Option::is_none")] - pub server_id: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub last_server_ping: Option>, - pub extra_perms: serde_json::Value, - #[serde(skip_serializing_if = "Option::is_none")] - pub error: Option, - pub enabled: bool, -} \ No newline at end of file +pub use crate::nats_triggers_ee::*; diff --git a/backend/windmill-api/src/oauth2_oss.rs b/backend/windmill-api/src/oauth2_oss.rs index 49d2155cf3..e1ad5ad52b 100644 --- a/backend/windmill-api/src/oauth2_oss.rs +++ b/backend/windmill-api/src/oauth2_oss.rs @@ -1,184 +1 @@ -/* - * Author: Ruben Fiszel - * Copyright: Windmill Labs, Inc 2022 - * This file and its contents are licensed under the AGPLv3 License. - * Please see the included NOTICE for copyright information and - * LICENSE-AGPL for a copy of the license. - */ - -use std::{collections::HashMap, fmt::Debug}; - -use axum::{routing::get, Json, Router}; -use hmac::Mac; - -#[cfg(feature = "oauth2")] -use itertools::Itertools; -#[cfg(feature = "oauth2")] -use oauth2::{Client as OClient, *}; -use serde::{Deserialize, Serialize}; -use sqlx::{Postgres, Transaction}; -#[cfg(feature = "oauth2")] -use windmill_common::more_serde::maybe_number_opt; - -#[cfg(feature = "oauth2")] -use crate::OAUTH_CLIENTS; -use windmill_common::error; -use windmill_common::oauth2::*; - -use crate::db::DB; -use std::str; - -pub fn global_service() -> Router { - Router::new() - .route("/list_logins", get(list_logins)) - .route("/list_connects", get(list_connects)) -} - -pub fn workspaced_service() -> Router { - Router::new() -} - -#[cfg(feature = "oauth2")] -#[derive(Debug, Clone)] -pub struct ClientWithScopes { - _client: OClient, - _scopes: Vec, - _extra_params: Option>, - _extra_params_callback: Option>, - _allowed_domains: Option>, - _userinfo_url: Option, -} -#[cfg(feature = "oauth2")] -pub type BasicClientsMap = HashMap; - -#[derive(Clone, Debug, Serialize, Deserialize)] -pub struct OAuthConfig { - auth_url: String, - token_url: String, - userinfo_url: Option, - scopes: Option>, - extra_params: Option>, - extra_params_callback: Option>, - req_body_auth: Option, -} - -#[derive(Clone, Debug, Serialize, Deserialize)] -pub struct OAuthClient { - id: String, - secret: String, - allowed_domains: Option>, - connect_config: Option, - login_config: Option, -} - -#[cfg(feature = "oauth2")] -#[derive(Debug)] -pub struct AllClients { - pub logins: BasicClientsMap, - pub connects: BasicClientsMap, - pub slack: Option, -} - -#[cfg(feature = "oauth2")] -pub async fn build_oauth_clients( - _base_url: &str, - _oauths_from_config: Option>, - _db: &DB, -) -> anyhow::Result { - // Implementation is not open source - return Ok(AllClients { - logins: HashMap::default(), - connects: HashMap::default(), - slack: None, - }); -} - -#[cfg(feature = "oauth2")] -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct TokenResponse { - access_token: AccessToken, - #[serde(deserialize_with = "maybe_number_opt")] - #[serde(default)] - expires_in: Option, - refresh_token: Option, - #[serde(deserialize_with = "helpers::deserialize_space_delimited_vec")] - #[serde(serialize_with = "helpers::serialize_space_delimited_vec")] - #[serde(default)] - scope: Option>, -} - -#[derive(Serialize)] -struct Logins { - oauth: Vec, - saml: Option, -} -async fn list_logins() -> error::JsonResult { - // Implementation is not open source - return Ok(Json(Logins { oauth: vec![], saml: None })); -} - -#[cfg(feature = "oauth2")] -async fn list_connects() -> error::JsonResult> { - Ok(Json( - (&OAUTH_CLIENTS.read().await.connects) - .keys() - .map(|x| x.to_owned()) - .collect_vec(), - )) -} - -#[cfg(not(feature = "oauth2"))] -async fn list_connects() -> error::JsonResult> { - // Implementation is not open source - return Ok(Json(vec![])); -} - -pub async fn _refresh_token<'c>( - _tx: Transaction<'c, Postgres>, - _path: &str, - _w_id: &str, - _id: i32, - _db: &DB, -) -> error::Result { - // Implementation is not open source - Err(error::Error::BadRequest( - "Not implemented in Windmill's Open Source repository".to_string(), - )) -} - -pub async fn check_nb_of_user(db: &DB) -> error::Result<()> { - let nb_users_sso = - sqlx::query_scalar!("SELECT COUNT(*) FROM password WHERE login_type != 'password'",) - .fetch_one(db) - .await?; - if nb_users_sso.unwrap_or(0) >= 10 { - return Err(error::Error::BadRequest( - "You have reached the maximum number of oauth users accounts (10) without an enterprise license" - .to_string(), - )); - } - - let nb_users = sqlx::query_scalar!("SELECT COUNT(*) FROM password",) - .fetch_one(db) - .await?; - if nb_users.unwrap_or(0) >= 50 { - return Err(error::Error::BadRequest( - "You have reached the maximum number of accounts (50) without an enterprise license" - .to_string(), - )); - } - return Ok(()); -} - -#[derive(Clone, Debug)] -pub struct SlackVerifier { - _mac: HmacSha256, -} - -impl SlackVerifier { - pub fn new>(secret: S) -> anyhow::Result { - HmacSha256::new_from_slice(secret.as_ref()) - .map(|mac| SlackVerifier { _mac: mac }) - .map_err(|_| anyhow::anyhow!("invalid secret")) - } -} +pub use crate::oauth2_ee::*; diff --git a/backend/windmill-api/src/oidc_oss.rs b/backend/windmill-api/src/oidc_oss.rs index 248b990f54..1139c3ca6f 100644 --- a/backend/windmill-api/src/oidc_oss.rs +++ b/backend/windmill-api/src/oidc_oss.rs @@ -1,17 +1 @@ -/* - * Author: Ruben Fiszel - * Copyright: Windmill Labs, Inc 2023 - * This file and its contents are licensed under the AGPLv3 License. - * Please see the included NOTICE for copyright information and - * LICENSE-AGPL for a copy of the license. - */ - -use axum::Router; - -pub fn global_service() -> Router { - Router::new() -} - -pub fn workspaced_service() -> Router { - Router::new() -} +pub use crate::oidc_ee::*; diff --git a/backend/windmill-api/src/saml_oss.rs b/backend/windmill-api/src/saml_oss.rs index b3f1d4653c..3838a22fdc 100644 --- a/backend/windmill-api/src/saml_oss.rs +++ b/backend/windmill-api/src/saml_oss.rs @@ -1,25 +1 @@ -/* - * Author: Ruben Fiszel - * Copyright: Windmill Labs, Inc 2023 - * This file and its contents are licensed under the AGPLv3 License. - * Please see the included NOTICE for copyright information and - * LICENSE-AGPL for a copy of the license. - */ -#![allow(non_snake_case)] - -use axum::{routing::post, Router}; - -pub struct ServiceProviderExt(); - -pub async fn build_sp_extension() -> anyhow::Result { - return Ok(ServiceProviderExt()); -} - -pub fn global_service() -> Router { - Router::new().route("/acs", post(acs)) -} - -pub async fn acs() -> String { - // Implementation is not open source as it is a Windmill Enterprise Edition feature - "SAML available only in enterprise version".to_string() -} +pub use crate::saml_ee::*; diff --git a/backend/windmill-api/src/scim_oss.rs b/backend/windmill-api/src/scim_oss.rs index f11097f874..813439ecca 100644 --- a/backend/windmill-api/src/scim_oss.rs +++ b/backend/windmill-api/src/scim_oss.rs @@ -1,23 +1 @@ -/* - * Author: Ruben Fiszel - * Copyright: Windmill Labs, Inc 2023 - * This file and its contents are licensed under the AGPLv3 License. - * Please see the included NOTICE for copyright information and - * LICENSE-AGPL for a copy of the license. - */ - -use axum::{middleware::Next, response::Response, routing::get, Router}; -use hyper::Request; - -pub fn global_service() -> Router { - Router::new().route("/ee", get(ee)) -} - -pub async fn ee() -> String { - return "Enterprise Edition".to_string(); -} - -pub async fn has_scim_token(_request: Request, _next: Next) -> Response { - //Not implemented in open-source version - todo!() -} +pub use crate::scim_ee::*; diff --git a/backend/windmill-api/src/smtp_server_oss.rs b/backend/windmill-api/src/smtp_server_oss.rs index 48e274f6a1..39de7bae5e 100644 --- a/backend/windmill-api/src/smtp_server_oss.rs +++ b/backend/windmill-api/src/smtp_server_oss.rs @@ -1,20 +1 @@ -use crate::{auth::AuthCache, db::DB}; -use std::{net::SocketAddr, sync::Arc}; -use windmill_common::db::UserDB; - -pub struct SmtpServer { - pub auth_cache: Arc, - pub db: DB, - pub user_db: UserDB, - pub base_internal_url: String, -} - -impl SmtpServer { - pub async fn start_listener_thread(self: Arc, _addr: SocketAddr) -> anyhow::Result<()> { - let _ = self.auth_cache; - let _ = self.db; - let _ = self.user_db; - let _ = self.base_internal_url; - Err(anyhow::anyhow!("Implementation not open source")) - } -} +pub use crate::smtp_server_ee::*; diff --git a/backend/windmill-api/src/sqs_triggers_oss.rs b/backend/windmill-api/src/sqs_triggers_oss.rs index da9b288f6b..02b2e84466 100644 --- a/backend/windmill-api/src/sqs_triggers_oss.rs +++ b/backend/windmill-api/src/sqs_triggers_oss.rs @@ -1,33 +1 @@ -use crate::db::DB; -use axum::Router; -use serde::{Deserialize, Serialize}; -use windmill_common::auth::aws::AwsAuthResourceType; - - -pub fn workspaced_service() -> Router { - Router::new() -} - -pub fn start_sqs(_db: DB, mut _killpill_rx: tokio::sync::broadcast::Receiver<()>) -> () { - // implementation is not open source -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct SqsTrigger { - pub queue_url: String, - pub aws_auth_resource_type: AwsAuthResourceType, - pub aws_resource_path: String, - pub message_attributes: Option>, - pub path: String, - pub script_path: String, - pub is_flow: bool, - pub workspace_id: String, - pub edited_by: String, - pub email: String, - pub edited_at: chrono::DateTime, - pub extra_perms: Option, - pub error: Option, - pub server_id: Option, - pub last_server_ping: Option>, - pub enabled: bool, -} \ No newline at end of file +pub use crate::sqs_triggers_ee::*; diff --git a/backend/windmill-api/src/stripe_oss.rs b/backend/windmill-api/src/stripe_oss.rs index 6934cad3bc..35d2305c76 100644 --- a/backend/windmill-api/src/stripe_oss.rs +++ b/backend/windmill-api/src/stripe_oss.rs @@ -1,5 +1 @@ -use axum::Router; - -pub fn add_stripe_routes(router: Router) -> Router { - return router; -} +pub use crate::stripe_ee::*; diff --git a/backend/windmill-api/src/teams_approvals_oss.rs b/backend/windmill-api/src/teams_approvals_oss.rs index 05698b98e3..fed0548387 100644 --- a/backend/windmill-api/src/teams_approvals_oss.rs +++ b/backend/windmill-api/src/teams_approvals_oss.rs @@ -1,7 +1 @@ -use hyper::StatusCode; - -use windmill_common::error::Error; - -pub async fn request_teams_approval() -> Result { - Err(Error::InternalErr("enterprise feature only".to_string())) -} \ No newline at end of file +pub use crate::teams_approvals_ee::*; diff --git a/backend/windmill-api/src/teams_oss.rs b/backend/windmill-api/src/teams_oss.rs index 46cbe72059..f29cc15d35 100644 --- a/backend/windmill-api/src/teams_oss.rs +++ b/backend/windmill-api/src/teams_oss.rs @@ -1,39 +1 @@ -use http::status::StatusCode; -#[cfg(feature = "enterprise")] -use axum::Router; -use windmill_common::error::Error; - -pub async fn edit_teams_command() -> Result { - return Err(Error::BadRequest( - "Teams only available on enterprise".to_string(), - )); -} - -pub async fn workspaces_list_available_teams_ids() -> Result { - return Err(Error::BadRequest( - "Teams only available on enterprise".to_string(), - )); -} - -pub async fn connect_teams() -> Result { - return Err(Error::BadRequest( - "Teams only available on enterprise".to_string(), - )); -} - -pub async fn run_teams_message_test_job() -> Result { - return Err(Error::BadRequest( - "Teams only available on enterprise".to_string(), - )); -} - -pub async fn workspaces_list_available_teams_channels() -> Result { - return Err(Error::BadRequest( - "Teams only available on enterprise".to_string(), - )); -} - -#[cfg(feature = "enterprise")] -pub fn teams_service() -> Router { - Router::new() -} \ No newline at end of file +pub use crate::teams_ee::*; diff --git a/backend/windmill-api/src/users_oss.rs b/backend/windmill-api/src/users_oss.rs index 7a11239a2f..9183992615 100644 --- a/backend/windmill-api/src/users_oss.rs +++ b/backend/windmill-api/src/users_oss.rs @@ -1,41 +1 @@ -use std::sync::Arc; - -use crate::db::ApiAuthed; - -use crate::users::{EditPassword, NewUser}; -use crate::{db::DB, webhook_util::WebhookShared}; -use argon2::Argon2; - -use http::StatusCode; - -use windmill_common::error::{Error, Result}; - -pub async fn create_user( - _authed: ApiAuthed, - _db: DB, - _webhook: WebhookShared, - _argon2: Arc>, - mut _nu: NewUser, -) -> Result<(StatusCode, String)> { - Err(Error::internal_err( - "Not implemented in Windmill's Open Source repository".to_string(), - )) -} - -pub async fn set_password( - _db: DB, - _argon2: Arc>, - _authed: ApiAuthed, - _user_email: &str, - _ep: EditPassword, -) -> Result { - Err(Error::internal_err( - "Not implemented in Windmill's Open Source repository".to_string(), - )) -} - -pub fn send_email_if_possible(_subject: &str, _content: &str, _to: &str) { - tracing::warn!( - "send_email_if_possible is not implemented in Windmill's Open Source repository" - ); -} +pub use crate::users_ee::*; diff --git a/backend/windmill-api/src/workspaces_oss.rs b/backend/windmill-api/src/workspaces_oss.rs index aa8799e233..49cfc27250 100644 --- a/backend/windmill-api/src/workspaces_oss.rs +++ b/backend/windmill-api/src/workspaces_oss.rs @@ -1,15 +1 @@ -use crate::{ - db::{ApiAuthed, DB}, - workspaces::EditAutoInvite, -}; - -pub async fn edit_auto_invite( - _authed: ApiAuthed, - _db: DB, - _w_id: String, - _ea: EditAutoInvite, -) -> windmill_common::error::Result { - Err(windmill_common::error::Error::internal_err( - "Not implemented on OSS".to_string(), - )) -} +pub use crate::workspaces_ee::*; diff --git a/backend/windmill-audit/src/audit_oss.rs b/backend/windmill-audit/src/audit_oss.rs index 027688f568..5b42e75cda 100644 --- a/backend/windmill-audit/src/audit_oss.rs +++ b/backend/windmill-audit/src/audit_oss.rs @@ -1,74 +1 @@ -/* - * Author: Ruben Fiszel - * Copyright: Windmill Labs, Inc 2022 - * This file and its contents are licensed under the AGPLv3 License. - * Please see the included NOTICE for copyright information and - * LICENSE-AGPL for a copy of the license. - */ -use std::collections::HashMap; -use windmill_common::{ - error::{Error, Result}, - utils::Pagination, -}; - -use crate::{ActionKind, AuditLog, ListAuditLogQuery}; -use sqlx::{Postgres, Transaction}; - -#[derive(Clone)] -pub struct AuditAuthor { - pub username: String, - pub email: String, - pub username_override: Option, -} - -impl AuditAuthorable for AuditAuthor { - fn email(&self) -> &str { - &self.email - } - - fn username(&self) -> &str { - &self.username - } - - fn username_override(&self) -> Option<&str> { - self.username_override.as_deref() - } -} - -pub trait AuditAuthorable { - fn username(&self) -> &str; - fn email(&self) -> &str; - fn username_override(&self) -> Option<&str>; -} - -#[tracing::instrument(level = "trace", skip_all)] -pub async fn audit_log<'c, E: sqlx::Executor<'c, Database = Postgres>>( - _db: E, - _author: &impl AuditAuthorable, - mut _operation: &str, - _action_kind: ActionKind, - _w_id: &str, - mut _resource: Option<&str>, - _parameters: Option>, -) -> Result<()> { - // Implementation is not open source as Audit logs is a Windmill Enterprise Edition feature - Ok(()) -} - -pub async fn list_audit( - _tx: Transaction<'_, Postgres>, - _w_id: String, - _pagination: Pagination, - _lq: ListAuditLogQuery, -) -> Result> { - // Implementation is not open source as Audit logs is a Windmill Enterprise Edition feature - return Ok(vec![]); -} - -pub async fn get_audit(tx: Transaction<'_, Postgres>, _id: i32, _w_id: &str) -> Result { - // Implementation is not open source as Audit logs is a Windmill Enterprise Edition feature - tx.commit().await?; - Err(Error::NotFound( - "Audit log not not available in Windmill Community edition".to_string(), - )) -} +pub use crate::audit_ee::*; diff --git a/backend/windmill-autoscaling/src/autoscaling_oss.rs b/backend/windmill-autoscaling/src/autoscaling_oss.rs index 1c9defbede..c78018c5f1 100644 --- a/backend/windmill-autoscaling/src/autoscaling_oss.rs +++ b/backend/windmill-autoscaling/src/autoscaling_oss.rs @@ -1,6 +1 @@ -use windmill_common::DB; - -pub async fn apply_all_autoscaling(_db: &DB) -> anyhow::Result<()> { - // Autoscaling is an ee feature - Ok(()) -} +pub use crate::autoscaling_ee::*; diff --git a/backend/windmill-common/src/ee.rs b/backend/windmill-common/src/ee.rs index a7d5503a86..f80b395406 100644 --- a/backend/windmill-common/src/ee.rs +++ b/backend/windmill-common/src/ee.rs @@ -1,6 +1,6 @@ #[cfg(feature = "enterprise")] use crate::db::DB; -use crate::ee_oss::LicensePlan::{self, Community}; +use crate::ee::LicensePlan::Community; #[cfg(feature = "enterprise")] use crate::error; use serde::Deserialize; @@ -13,6 +13,12 @@ lazy_static::lazy_static! { pub static ref LICENSE_KEY: Arc> = Arc::new(RwLock::new("".to_string())); } +pub enum LicensePlan { + Community, + Pro, + Enterprise, +} + pub async fn get_license_plan() -> LicensePlan { // Implementation is not open source return Community; diff --git a/backend/windmill-common/src/ee_oss.rs b/backend/windmill-common/src/ee_oss.rs index 40d0377f80..d210e0118d 100644 --- a/backend/windmill-common/src/ee_oss.rs +++ b/backend/windmill-common/src/ee_oss.rs @@ -1,110 +1 @@ -#[cfg(feature = "enterprise")] -use crate::db::DB; -use crate::ee_oss::LicensePlan::Community; -#[cfg(feature = "enterprise")] -use crate::error; -use serde::Deserialize; -use std::sync::Arc; -use tokio::sync::RwLock; - -lazy_static::lazy_static! { - pub static ref LICENSE_KEY_VALID: Arc> = Arc::new(RwLock::new(true)); - pub static ref LICENSE_KEY_ID: Arc> = Arc::new(RwLock::new("".to_string())); - pub static ref LICENSE_KEY: Arc> = Arc::new(RwLock::new("".to_string())); -} - -pub enum LicensePlan { - Community, - Pro, - Enterprise, -} - -pub async fn get_license_plan() -> LicensePlan { - // Implementation is not open source - return Community; -} - -#[derive(Deserialize)] -#[serde(untagged)] -pub enum CriticalErrorChannel { - Email { email: String }, - Slack { slack_channel: String }, - Teams { teams_channel: TeamsChannel }, -} - -#[derive(Deserialize)] -pub struct TeamsChannel { - pub team_id: String, - pub team_name: String, - pub channel_id: String, - pub channel_name: String, -} - -pub enum CriticalAlertKind { - #[cfg(feature = "enterprise")] - CriticalError, - #[cfg(feature = "enterprise")] - RecoveredCriticalError, -} - -#[cfg(feature = "enterprise")] -pub async fn send_critical_alert( - _error_message: String, - _db: &DB, - _kind: CriticalAlertKind, - _channels: Option>, -) { -} - -#[cfg(feature = "enterprise")] -pub async fn maybe_renew_license_key_on_start( - _http_client: &reqwest::Client, - _db: &crate::db::DB, - force_renew_now: bool, -) -> bool { - // Implementation is not open source - force_renew_now -} - -#[cfg(feature = "enterprise")] -pub enum RenewReason { - Manual, - Schedule, - OnStart, -} - -#[cfg(feature = "enterprise")] -pub async fn renew_license_key( - _http_client: &reqwest::Client, - _db: &crate::db::DB, - _key: Option, - _reason: RenewReason, -) -> String { - // Implementation is not open source - "".to_string() -} - -#[cfg(feature = "enterprise")] -pub async fn create_customer_portal_session( - _http_client: &reqwest::Client, - _key: Option, -) -> error::Result { - // Implementation is not open source - Ok("".to_string()) -} - -#[cfg(feature = "enterprise")] -pub async fn worker_groups_alerts(_db: &DB) {} - -#[cfg(feature = "enterprise")] -pub async fn jobs_waiting_alerts(_db: &DB) {} - -#[cfg(feature = "enterprise")] -pub async fn low_disk_alerts( - _db: &DB, - _server_mode: bool, - _worker_mode: bool, - _workers: Vec, -) { - // Implementation is not open source -} +pub use crate::ee::*; diff --git a/backend/windmill-common/src/email_oss.rs b/backend/windmill-common/src/email_oss.rs index 42aebbeec3..c68bb00f95 100644 --- a/backend/windmill-common/src/email_oss.rs +++ b/backend/windmill-common/src/email_oss.rs @@ -1,11 +1 @@ -use crate::server::Smtp; - -pub async fn send_email( - _subject: &str, - _content: &str, - _to: Vec, - _smtp: Smtp, - _client_timeout: Option, -) -> crate::error::Result<()> { - Ok(()) -} +pub use crate::email_ee::*; diff --git a/backend/windmill-common/src/job_s3_helpers_oss.rs b/backend/windmill-common/src/job_s3_helpers_oss.rs index d5d6ac4052..9f00f3ef47 100644 --- a/backend/windmill-common/src/job_s3_helpers_oss.rs +++ b/backend/windmill-common/src/job_s3_helpers_oss.rs @@ -1,34 +1 @@ -use crate::s3_helpers::{ObjectStoreResource, StorageResourceType}; - -pub async fn get_s3_resource_internal<'c>( - _resource_type: StorageResourceType, - _s3_resource_value_raw: serde_json::Value, - _gen_token: TokenGenerator<'c>, - _db: &crate::DB, -) -> crate::error::Result { - todo!() -} - -pub enum TokenGenerator<'c> { - AsClient(&'c crate::client::AuthedClient), - AsServerInstance(), -} - -impl<'c> TokenGenerator<'c> { - pub async fn gen_token( - &self, - _audience: &str, - _db: Option<&crate::DB>, - ) -> anyhow::Result { - todo!() - } -} - -#[cfg(feature = "parquet")] -pub(crate) async fn generate_s3_aws_oidc_resource<'c>( - _clone: crate::s3_helpers::S3AwsOidcResource, - _token_generator: TokenGenerator<'c>, - _init_private_key: Option<&sqlx::Pool>, -) -> crate::error::Result { - todo!() -} +pub use crate::job_s3_helpers_ee::*; diff --git a/backend/windmill-common/src/oidc_oss.rs b/backend/windmill-common/src/oidc_oss.rs index e7a157b04d..1139c3ca6f 100644 --- a/backend/windmill-common/src/oidc_oss.rs +++ b/backend/windmill-common/src/oidc_oss.rs @@ -1,198 +1 @@ -/* - * Author: Ruben Fiszel - * Copyright: Windmill Labs, Inc 2023 - * This file and its contents are licensed under the AGPLv3 License. - * Please see the included NOTICE for copyright information and - * LICENSE-AGPL for a copy of the license. - */ - -use serde::{Deserialize, Serialize}; -use tokio::sync::RwLock; -#[cfg(all(feature = "enterprise", feature = "openidconnect"))] -use { - crate::db::DB, - crate::{auth::IdToken as WindmillIdToken, error::Result}, - anyhow, - openidconnect::{ - core::{CoreJwsSigningAlgorithm, CoreRsaPrivateSigningKey}, - IssuerUrl, JsonWebKeyId, - }, - std::process::Command, -}; - -#[cfg(feature = "openidconnect")] -use openidconnect::AdditionalClaims; - -#[cfg(feature = "openidconnect")] -impl AdditionalClaims for JobClaim {} - -#[cfg(feature = "openidconnect")] -impl AdditionalClaims for WorkspaceClaim {} - -#[cfg(feature = "openidconnect")] -impl AdditionalClaims for InstanceClaim {} - -#[derive(Clone, Debug, Default, Deserialize, PartialEq, Eq, Serialize)] -pub struct WorkspaceClaim { - pub workspace: String, -} - -#[derive(Clone, Debug, Default, Deserialize, PartialEq, Eq, Serialize)] -pub struct InstanceClaim {} - -#[derive(Clone, Debug, Default, Deserialize, PartialEq, Eq, Serialize)] -pub struct JobClaim { - pub job_id: String, - pub path: Option, - pub flow_path: Option, - pub groups: Vec, - pub username: String, - pub email: String, - pub workspace: String, -} - -lazy_static::lazy_static! { - static ref PRIVATE_KEY: RwLock> = RwLock::new(None); -} - -pub async fn generate_id_token( - db: Option<&DB>, - claim: T, - audience: &str, - identifier: String, - email: Option, -) -> Result { - use chrono::{Duration, Utc}; - use openidconnect::{ - core::{CoreGenderClaim, CoreJweContentEncryptionAlgorithm}, - Audience, EndUserEmail, IdToken, IdTokenClaims, StandardClaims, SubjectIdentifier, - }; - - let private_key = get_private_key(db).await?; - - let issue_url = format!("{}/api/oidc/", crate::BASE_URL.read().await.clone()); - let issue_time = Utc::now(); - let expiration = issue_time + Duration::try_hours(48).unwrap(); - let id_token = IdToken::< - T, - CoreGenderClaim, - CoreJweContentEncryptionAlgorithm, - CoreJwsSigningAlgorithm, - >::new( - IdTokenClaims::::new( - // Specify the issuer URL for the OpenID Connect Provider. - IssuerUrl::new(issue_url) - .map_err(|e| anyhow::anyhow!("Failed to generate IssueUrl: {}", e))?, - // The audience is usually a single entry with the client ID of the client for whom - // the ID token is intended. This is a required claim. - vec![Audience::new(audience.to_string())], - // The ID token expiration is usually much shorter than that of the access or refresh - // tokens issued to clients. - expiration, - // The issue time is usually the current time. - issue_time, - // Set the standard claims defined by the OpenID Connect Core spec. - StandardClaims::new( - // Stable subject identifiers are recommended in place of e-mail addresses or other - // potentially unstable identifiers. This is the only required claim. - SubjectIdentifier::new(identifier), - ) - // Optional: specify the user's e-mail address. This should only be provided if the - // client has been granted the 'profile' or 'email' scopes. - .set_email(email.map(|x| EndUserEmail::new(x))) - // Optional: specify whether the provider has verified the user's e-mail address. - .set_email_verified(Some(true)), - // OpenID Connect Providers may supply custom claims by providing a struct that - // implements the AdditionalClaims trait. This requires manually using the - // generic IdTokenClaims struct rather than the CoreIdTokenClaims type alias, - // however. - claim, - ), - // The private key used for signing the ID token. For confidential clients (those able - // to maintain a client secret), a CoreHmacKey can also be used, in conjunction - // with one of the CoreJwsSigningAlgorithm::HmacSha* signing algorithms. When using an - // HMAC-based signing algorithm, the UTF-8 representation of the client secret should - // be used as the HMAC key. - &CoreRsaPrivateSigningKey::from_pem( - &private_key, - Some(JsonWebKeyId::new("windmill".to_string())), - ) - .map_err(|e| anyhow::anyhow!("Invalid private key: {}", e))?, - // Uses the RS256 signature algorithm. This crate supports any RS*, PS*, or HS* - // signature algorithm. - CoreJwsSigningAlgorithm::RsaSsaPkcs1V15Sha256, - // When returning the ID token alongside an access token (e.g., in the Authorization Code - // flow), it is recommended to pass the access token here to set the `at_hash` claim - // automatically. - None, - // When returning the ID token alongside an authorization code (e.g., in the implicit - // flow), it is recommended to pass the authorization code here to set the `c_hash` claim - // automatically. - None, - ) - .map_err(|e| anyhow::anyhow!("Failed to generate token: {}", e))?; - - Ok(WindmillIdToken::new(id_token.to_string(), expiration)) -} - -#[cfg(all(feature = "enterprise", feature = "openidconnect"))] -pub async fn get_private_key(db: Option<&DB>) -> anyhow::Result { - if let Some(key) = PRIVATE_KEY.read().await.clone() { - return Ok(key); - } else if let Some(db) = db { - let key = sqlx::query_scalar!( - "SELECT value->>'private_key' FROM global_settings WHERE name = 'rsa_keys'", - ) - .fetch_optional(db) - .await? - .flatten(); - - let key = key.filter(|s| !s.is_empty()); - - if let Some(key) = key { - return Ok(key); - } else { - let keys = gen_pems(db).await?; - return Ok(keys.private_key); - } - } else { - return Err(anyhow::anyhow!("Private key not found and no db provided")); - } -} - -#[cfg(all(feature = "enterprise", feature = "openidconnect"))] -#[derive(Debug, Clone, serde::Serialize)] -struct Keys { - private_key: String, -} - -#[cfg(all(feature = "enterprise", feature = "openidconnect"))] -async fn gen_pems(db: &DB) -> anyhow::Result { - use anyhow::anyhow; - - let private_key_cmd = Command::new("openssl") - .arg("genrsa") - .arg("--traditional") - .arg("2048") - .output() - .expect("failed to execute process"); - - let private_key = String::from_utf8(private_key_cmd.stdout)?; - - tracing::debug!("Generated private key: {}", private_key); - - if private_key.is_empty() { - return Err(anyhow!("Failed to generate RSA key: key is empty")); - } - - let keys = Keys { private_key }; - - sqlx::query!( - r#"INSERT INTO global_settings (name, value) VALUES ('rsa_keys', $1)"#, - serde_json::to_value(&keys).unwrap() - ) - .execute(db) - .await?; - - Ok(keys) -} +pub use crate::oidc_ee::*; diff --git a/backend/windmill-common/src/otel_oss.rs b/backend/windmill-common/src/otel_oss.rs index f3ada162f6..9dd5f654c4 100644 --- a/backend/windmill-common/src/otel_oss.rs +++ b/backend/windmill-common/src/otel_oss.rs @@ -1,58 +1 @@ -/* - * Author: Ruben Fiszel - * Copyright: Windmill Labs, Inc 2022 - * This file and its contents are licensed under the AGPLv3 License. - * Please see the included NOTICE for copyright information and - * LICENSE-AGPL for a copy of the license. - */ - -use crate::{jobs::QueuedJob, utils::Mode}; -use uuid::Uuid; - -pub fn set_span_parent(_span: &tracing::Span, _rj: &Uuid) {} - -#[cfg(not(all(feature = "otel", feature = "enterprise")))] -pub(crate) type OtelProvider = Option<()>; - -#[cfg(all(feature = "otel", feature = "enterprise"))] -pub(crate) type OtelProvider = Option; - -#[cfg(not(feature = "otel"))] -pub fn otel_ctx() -> () {} - -#[cfg(feature = "otel")] -#[inline(always)] -pub fn otel_ctx() -> opentelemetry::Context { - opentelemetry::Context::current() -} - -#[cfg(not(feature = "otel"))] -impl FutureExt for T {} - -#[cfg(not(feature = "otel"))] -pub trait FutureExt: Sized { - fn with_context(self, _otel_cx: ()) -> Self { - self - } -} - -use tracing_subscriber::EnvFilter; - -pub(crate) fn init_logs_bridge(_mode: &Mode, _hostname: &str, _env: &str) -> Option { - None -} - -#[cfg(all(feature = "otel", feature = "enterprise"))] -pub(crate) fn init_otlp_tracer( - _mode: &Mode, - _hostname: &str, - _env: &str, -) -> Option { - None -} - -pub(crate) fn init_meter_provider(_mode: &Mode, _hostname: &str, _env: &str) -> OtelProvider { - None -} - -pub fn add_root_flow_job_to_otlp(_queued_job: &QueuedJob, _success: bool) {} +pub use crate::otel_ee::*; diff --git a/backend/windmill-common/src/stats_oss.rs b/backend/windmill-common/src/stats_oss.rs index 5d2dc82b82..647b3ed6ea 100644 --- a/backend/windmill-common/src/stats_oss.rs +++ b/backend/windmill-common/src/stats_oss.rs @@ -1,47 +1 @@ -use sqlx::Postgres; - -use crate::{error::Result, scripts::ScriptLang, DB}; - -pub async fn get_disable_stats_setting(_db: &DB) -> bool { - // stats details are closed source - - false -} - -pub async fn schedule_stats(_db: &DB, _http_client: &reqwest::Client) -> () { - // stats details are closed source -} - -#[derive(Debug, sqlx::FromRow, serde::Serialize)] -struct JobsUsage { - language: Option, - total_duration: i64, - count: i64, -} - -pub enum SendStatsReason { - Manual, - Schedule, - OnStart, -} - -pub async fn send_stats( - _http_client: &reqwest::Client, - _db: &DB, - _reason: SendStatsReason, -) -> Result<()> { - // stats details are closed source - Ok(()) -} - -pub struct ActiveUserUsage { - pub author_count: Option, - pub operator_count: Option, -} - -pub async fn get_user_usage<'c, E: sqlx::Executor<'c, Database = Postgres>>( - _db: E, -) -> Result { - let usage = ActiveUserUsage { author_count: None, operator_count: None }; - Ok(usage) -} +pub use crate::stats_ee::*; diff --git a/backend/windmill-common/src/teams_oss.rs b/backend/windmill-common/src/teams_oss.rs index e69de29bb2..f29cc15d35 100644 --- a/backend/windmill-common/src/teams_oss.rs +++ b/backend/windmill-common/src/teams_oss.rs @@ -0,0 +1 @@ +pub use crate::teams_ee::*; diff --git a/backend/windmill-git-sync/src/git_sync_oss.rs b/backend/windmill-git-sync/src/git_sync_oss.rs index cc245d3d0c..bd27983851 100644 --- a/backend/windmill-git-sync/src/git_sync_oss.rs +++ b/backend/windmill-git-sync/src/git_sync_oss.rs @@ -1,16 +1 @@ -use windmill_common::error::Result; - -use crate::{DeployedObject, DB}; - -pub async fn handle_deployment_metadata<'c>( - _email: &str, - _created_by: &str, - _db: &DB, - _w_id: &str, - _obj: DeployedObject, - _deployment_message: Option, - _skip_db_insert: bool, -) -> Result<()> { - // Git sync is an enterprise feature and not part of the open-source version - return Ok(()); -} +pub use crate::git_sync_ee::*; diff --git a/backend/windmill-indexer/src/completed_runs_oss.rs b/backend/windmill-indexer/src/completed_runs_oss.rs index f5c6c98cf8..eb5784953d 100644 --- a/backend/windmill-indexer/src/completed_runs_oss.rs +++ b/backend/windmill-indexer/src/completed_runs_oss.rs @@ -1,22 +1 @@ -use anyhow::anyhow; -use sqlx::{Pool, Postgres}; -use windmill_common::error::Error; - -#[derive(Clone)] -pub struct IndexReader; - -#[derive(Clone)] -pub struct IndexWriter; - -pub async fn init_index(_db: &Pool) -> Result<(IndexReader, IndexWriter), Error> { - Err(anyhow!("Cannot initialize index: not in EE").into()) -} - -pub async fn run_indexer( - _db: Pool, - mut _index_writer: IndexWriter, - mut _killpill_rx: tokio::sync::broadcast::Receiver<()>, -) -> Result<(), Error> { - tracing::error!("Cannot run indexer: not in EE"); - Err(anyhow!("Cannot run indexer: not in EE").into()) -} +pub use crate::completed_runs_ee::*; diff --git a/backend/windmill-indexer/src/indexer_oss.rs b/backend/windmill-indexer/src/indexer_oss.rs index 8b13789179..1dedecf39c 100644 --- a/backend/windmill-indexer/src/indexer_oss.rs +++ b/backend/windmill-indexer/src/indexer_oss.rs @@ -1 +1 @@ - +pub use crate::indexer_ee::*; diff --git a/backend/windmill-indexer/src/service_logs_oss.rs b/backend/windmill-indexer/src/service_logs_oss.rs index e04575d3f5..83f012cf0e 100644 --- a/backend/windmill-indexer/src/service_logs_oss.rs +++ b/backend/windmill-indexer/src/service_logs_oss.rs @@ -1,25 +1 @@ -use anyhow::anyhow; -use sqlx::{Pool, Postgres}; -use windmill_common::error::Error; -use windmill_common::KillpillSender; -#[derive(Clone)] -pub struct ServiceLogIndexReader; - -#[derive(Clone)] -pub struct ServiceLogIndexWriter; - -pub async fn init_index( - _db: &Pool, - mut _killpill_tx: KillpillSender, -) -> Result<(ServiceLogIndexReader, ServiceLogIndexWriter), Error> { - Err(anyhow!("Cannot initialize index: not in EE").into()) -} - -pub async fn run_indexer( - _db: Pool, - mut _index_writer: ServiceLogIndexWriter, - mut _killpill_rx: tokio::sync::broadcast::Receiver<()>, -) -> Result<(), Error> { - tracing::error!("Cannot run indexer: not in EE"); - Err(anyhow!("Cannot run indexer: not in EE").into()) -} +pub use crate::service_logs_ee::*; diff --git a/backend/windmill-queue/src/jobs_oss.rs b/backend/windmill-queue/src/jobs_oss.rs index ea1f86b529..8b1ac582ce 100644 --- a/backend/windmill-queue/src/jobs_oss.rs +++ b/backend/windmill-queue/src/jobs_oss.rs @@ -1,16 +1 @@ -use chrono::{DateTime, Utc}; -use uuid::Uuid; -use windmill_common::DB; - -#[allow(dead_code)] -pub(crate) async fn update_concurrency_counter( - _db: &DB, - _job_id: &Uuid, - _job_concurrency_key: String, - _jobs_uuids_init_json_value: serde_json::Value, - _pulled_job_id: String, - _job_custom_concurrency_time_window_s: i32, - _limit: i32, -) -> anyhow::Result<(bool, Option>)> { - Ok((true, None)) -} +pub use crate::jobs_ee::*; diff --git a/backend/windmill-worker/src/job_logger_oss.rs b/backend/windmill-worker/src/job_logger_oss.rs index 22772878ee..3fd4445d9d 100644 --- a/backend/windmill-worker/src/job_logger_oss.rs +++ b/backend/windmill-worker/src/job_logger_oss.rs @@ -1,42 +1 @@ -use std::io; -use std::sync::atomic::AtomicU32; -use std::sync::Arc; - -use uuid::Uuid; -use windmill_common::DB; - -use crate::job_logger::CompactLogs; - -#[cfg(all(feature = "enterprise", feature = "parquet"))] -pub(crate) async fn s3_storage( - _job_id: &Uuid, - _w_id: &str, - _db: &sqlx::Pool, - _logs: &str, - _total_size: Arc, - _worker_name: &str, -) { - tracing::info!("Logs length of {_job_id} has exceeded a threshold. Implementation to store excess on s3 in not OSS"); -} - -#[allow(dead_code)] -pub(crate) async fn default_disk_log_storage( - job_id: &Uuid, - _w_id: &str, - _db: &DB, - _logs: &str, - _total_size: Arc, - _compact_kind: CompactLogs, - _worker_name: &str, -) { - tracing::info!("Logs length of {job_id} has exceeded a threshold. Implementation to store excess on disk in not OSS"); -} - -pub(crate) fn process_streaming_log_lines( - r: Result, io::Error>, - _stderr: bool, - _job_id: &Uuid, - _w_id: &str, -) -> Option> { - r.transpose() -} +pub use crate::job_logger_ee::*; diff --git a/backend/windmill-worker/src/otel_oss.rs b/backend/windmill-worker/src/otel_oss.rs index 311ffd6355..9dd5f654c4 100644 --- a/backend/windmill-worker/src/otel_oss.rs +++ b/backend/windmill-worker/src/otel_oss.rs @@ -1,3 +1 @@ -use windmill_queue::MiniPulledJob; - -pub fn add_root_flow_job_to_otlp(_queued_job: &MiniPulledJob, _success: bool) {} +pub use crate::otel_ee::*;