mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-20 00:02:19 +00:00
add ee_license endpoint
This commit is contained in:
+3
-3
@@ -19,6 +19,7 @@ use tokio::{
|
||||
join,
|
||||
sync::RwLock,
|
||||
};
|
||||
use windmill_api::LICENSE_KEY;
|
||||
use windmill_common::{utils::rd_string, METRICS_ADDR};
|
||||
use windmill_worker::{
|
||||
DENO_CACHE_DIR, DENO_TMP_CACHE_DIR, GO_CACHE_DIR, GO_TMP_CACHE_DIR, HUB_CACHE_DIR,
|
||||
@@ -270,12 +271,11 @@ pub async fn run_workers<R: rsmq_async::RsmqConnection + Send + Sync + Clone + '
|
||||
base_internal_url: String,
|
||||
rsmq: Option<R>,
|
||||
) -> anyhow::Result<()> {
|
||||
let license_key = std::env::var("LICENSE_KEY").ok();
|
||||
#[cfg(feature = "enterprise")]
|
||||
ee::verify_license_key(license_key)?;
|
||||
ee::verify_license_key(LICENSE_KEY.clone())?;
|
||||
|
||||
#[cfg(not(feature = "enterprise"))]
|
||||
if license_key.is_some() {
|
||||
if LICENSE_KEY.is_some() {
|
||||
panic!("License key is required ONLY for the enterprise edition");
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,20 @@ paths:
|
||||
schema:
|
||||
type: string
|
||||
|
||||
/ee_license:
|
||||
get:
|
||||
summary: get license id
|
||||
operationId: getLicenseId
|
||||
tags:
|
||||
- settings
|
||||
responses:
|
||||
"200":
|
||||
description: get license id (empty if not ee)
|
||||
content:
|
||||
text/plain:
|
||||
schema:
|
||||
type: string
|
||||
|
||||
/openapi.yaml:
|
||||
get:
|
||||
summary: get openapi yaml spec
|
||||
|
||||
@@ -86,6 +86,8 @@ lazy_static::lazy_static! {
|
||||
pub static ref OAUTH_CLIENTS: AllClients = build_oauth_clients(&BASE_URL)
|
||||
.map_err(|e| tracing::error!("Error building oauth clients: {}", e))
|
||||
.unwrap();
|
||||
|
||||
pub static ref LICENSE_KEY: Option<String> = std::env::var("LICENSE_KEY").ok();
|
||||
}
|
||||
|
||||
pub async fn run_server(
|
||||
@@ -186,6 +188,7 @@ pub async fn run_server(
|
||||
)
|
||||
.nest("/oauth", oauth2::global_service())
|
||||
.route("/version", get(git_v))
|
||||
.route("/ee_license", get(ee_license))
|
||||
.route("/openapi.yaml", get(openapi)),
|
||||
)
|
||||
.fallback(static_assets::static_handler)
|
||||
@@ -207,8 +210,30 @@ pub async fn run_server(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn git_v() -> &'static str {
|
||||
GIT_VERSION
|
||||
#[cfg(feature = "enterprise")]
|
||||
async fn git_v() -> String {
|
||||
format!("EE {GIT_VERSION}")
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "enterprise"))]
|
||||
async fn git_v() -> String {
|
||||
format!("CE {GIT_VERSION}")
|
||||
}
|
||||
|
||||
#[cfg(feature = "enterprise")]
|
||||
async fn ee_license() -> &'static str {
|
||||
""
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "enterprise"))]
|
||||
async fn ee_license() -> String {
|
||||
LICENSE_KEY
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.split(".")
|
||||
.next()
|
||||
.unwrap()
|
||||
.to_string()
|
||||
}
|
||||
|
||||
async fn openapi() -> &'static str {
|
||||
|
||||
Reference in New Issue
Block a user