mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-10 00:05:27 +00:00
fix: guests are gated on the Enterprise plan server-side; pin ee-repo-ref
This commit is contained in:
@@ -1 +1 @@
|
||||
9623e36c58c51e085739636efd44dd5cecfd24af
|
||||
f7853642aba08173dba3fc38c5c8a4036efa9bde
|
||||
@@ -4621,6 +4621,11 @@ async fn edit_guest_access(
|
||||
Json(EditGuestAccess { guest_access_enabled }): Json<EditGuestAccess>,
|
||||
) -> Result<String> {
|
||||
require_admin(authed.is_admin, &authed.username)?;
|
||||
if guest_access_enabled && !windmill_common::workspaces::guest_access_licensed().await {
|
||||
return Err(Error::BadRequest(
|
||||
"Guest access requires an Enterprise license".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
let mut tx = db.begin().await?;
|
||||
sqlx::query!(
|
||||
|
||||
@@ -775,6 +775,24 @@ pub struct BillableSeats {
|
||||
pub seats: i64,
|
||||
}
|
||||
|
||||
/// Guests are an Enterprise-plan feature, so a Pro key refuses them at every gate —
|
||||
/// the workspace switch, the mint, the door — not only in the UI that hides them. A
|
||||
/// build without `enterprise` has no plan to consult and cannot mint a guest session
|
||||
/// at all (the mint lives in EE code), so nothing is gated there.
|
||||
pub async fn guest_access_licensed() -> bool {
|
||||
#[cfg(feature = "enterprise")]
|
||||
{
|
||||
matches!(
|
||||
crate::ee_oss::get_license_plan().await,
|
||||
crate::ee_oss::LicensePlan::Enterprise
|
||||
)
|
||||
}
|
||||
#[cfg(not(feature = "enterprise"))]
|
||||
{
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether `w_id` admits guest sessions — someone the identity provider authenticated
|
||||
/// who is a member of no workspace, and who therefore takes no seat.
|
||||
///
|
||||
@@ -784,6 +802,9 @@ pub struct BillableSeats {
|
||||
/// push `guest` past every deploy-time gate; the per-request read is what makes
|
||||
/// turning the switch off take effect on sessions already issued.
|
||||
pub async fn is_guest_access_enabled(db: &crate::DB, w_id: &str) -> Result<bool> {
|
||||
if !guest_access_licensed().await {
|
||||
return Ok(false);
|
||||
}
|
||||
Ok(sqlx::query_scalar!(
|
||||
"SELECT guest_access_enabled FROM workspace_settings WHERE workspace_id = $1",
|
||||
w_id
|
||||
@@ -803,6 +824,9 @@ pub async fn guest_app_admits<'c, E: sqlx::Executor<'c, Database = sqlx::Postgre
|
||||
w_id: &str,
|
||||
app_path: &str,
|
||||
) -> Result<bool> {
|
||||
if !guest_access_licensed().await {
|
||||
return Ok(false);
|
||||
}
|
||||
let admits: Option<bool> = sqlx::query_scalar(
|
||||
"SELECT COALESCE(ws.guest_access_enabled AND app.policy->>'execution_mode' = 'guest', false)
|
||||
FROM app JOIN workspace_settings ws ON ws.workspace_id = app.workspace_id
|
||||
|
||||
Reference in New Issue
Block a user