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
2 changes: 1 addition & 1 deletion crates/defguard_core/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
&["src/enterprise/proto/license.proto"],
&["src/enterprise/proto"],
)?;
println!("cargo:rerun-if-changed=src/enterprise");
println!("cargo:rerun-if-changed=src/enterprise/proto");
Ok(())
}
4 changes: 2 additions & 2 deletions crates/defguard_core/src/auth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::{
Group, OAuth2Token, Session, SessionState, User,
models::{group::Permission, oauth2client::OAuth2Client},
},
enterprise::{db::models::api_tokens::ApiToken, is_enterprise_enabled},
enterprise::{db::models::api_tokens::ApiToken, is_business_license_active},
error::WebError,
handlers::SESSION_COOKIE_NAME,
};
Expand All @@ -38,7 +38,7 @@ where
let appstate = AppState::from_ref(state);

// first try to authenticate by API token if one is found in header
if is_enterprise_enabled() {
if is_business_license_active() {
let maybe_auth_header: Option<TypedHeader<Authorization<Bearer>>> =
<TypedHeader<_> as OptionalFromRequestParts<S>>::from_request_parts(parts, state)
.await
Expand Down
5 changes: 3 additions & 2 deletions crates/defguard_core/src/db/models/wireguard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use super::{
wireguard_peer_stats::WireguardPeerStats,
};
use crate::{
enterprise::{firewall::FirewallError, is_enterprise_enabled},
enterprise::{firewall::FirewallError, is_enterprise_license_active},
grpc::gateway::{send_multiple_wireguard_events, state::GatewayState},
wg_config::ImportedDevice,
};
Expand Down Expand Up @@ -1335,7 +1335,8 @@ impl WireguardNetwork<Id> {
/// - Enterprise is enabled
#[must_use]
pub fn should_prevent_service_location_usage(&self) -> bool {
self.service_location_mode != ServiceLocationMode::Disabled && !is_enterprise_enabled()
self.service_location_mode != ServiceLocationMode::Disabled
&& !is_enterprise_license_active()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use super::ActivityLogStreamReconfigurationNotification;
use crate::enterprise::{
activity_log_stream::http_stream::{HttpActivityLogStreamConfig, run_http_stream_task},
db::models::activity_log_stream::{ActivityLogStream, ActivityLogStreamConfig},
is_enterprise_enabled,
is_business_license_active,
};

// check if enterprise features are enabled every minute
Expand All @@ -27,7 +27,7 @@ pub async fn run_activity_log_stream_manager(
let mut enterprise_check_timer = interval(Duration::from_secs(ENTERPRISE_CHECK_PERIOD_SECS));

// initialize enterprise features status
let mut enterprise_features_enabled = is_enterprise_enabled();
let mut enterprise_features_enabled = is_business_license_active();

loop {
let mut handles = JoinSet::<()>::new();
Expand Down Expand Up @@ -94,7 +94,7 @@ pub async fn run_activity_log_stream_manager(
}
_ = enterprise_check_timer.tick() => {
// check if enterprise features status has changed
let current_enterprise_features_enabled = is_enterprise_enabled();
let current_enterprise_features_enabled = is_business_license_active();
if current_enterprise_features_enabled != enterprise_features_enabled {
warn!("Activity log stream manager will reload, detected license enterprise features status has changed");
enterprise_features_enabled = current_enterprise_features_enabled;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use sqlx::{PgExecutor, Type, query, query_as};
use struct_patch::Patch;

use crate::enterprise::is_enterprise_enabled;
use crate::enterprise::is_business_license_active;

#[derive(Debug, Deserialize, Patch, Serialize)]
#[patch(attribute(derive(Deserialize, Serialize)))]
Expand Down Expand Up @@ -35,7 +35,7 @@ impl EnterpriseSettings {
{
// avoid holding the rwlock across await, makes the future !Send
// and therefore unusable in axum handlers
if is_enterprise_enabled() {
if is_business_license_active() {
let settings = query_as!(
Self,
"SELECT admin_device_management, \
Expand Down
10 changes: 5 additions & 5 deletions crates/defguard_core/src/enterprise/directory_sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ use sqlx::{PgConnection, PgPool, error::Error as SqlxError};
use thiserror::Error;
use tokio::sync::broadcast::Sender;

#[cfg(not(test))]
use super::is_enterprise_enabled;
use super::{
db::models::openid_provider::{DirectorySyncTarget, OpenIdProvider},
ldap::utils::ldap_update_users_state,
};
#[cfg(not(test))]
use crate::enterprise::is_business_license_active;
use crate::{
db::{GatewayEvent, Group, User},
enterprise::{
Expand Down Expand Up @@ -383,7 +383,7 @@ pub(crate) async fn test_directory_sync_connection(
pool: &PgPool,
) -> Result<(), DirectorySyncError> {
#[cfg(not(test))]
if !is_enterprise_enabled() {
if !is_business_license_active() {
debug!("Enterprise is not enabled, skipping testing directory sync connection");
return Ok(());
}
Expand All @@ -408,7 +408,7 @@ pub(crate) async fn sync_user_groups_if_configured(
wg_tx: &Sender<GatewayEvent>,
) -> Result<(), DirectorySyncError> {
#[cfg(not(test))]
if !is_enterprise_enabled() {
if !is_business_license_active() {
debug!("Enterprise is not enabled, skipping syncing user groups");
return Ok(());
}
Expand Down Expand Up @@ -966,7 +966,7 @@ pub(crate) async fn do_directory_sync(
wireguard_tx: &Sender<GatewayEvent>,
) -> Result<(), DirectorySyncError> {
#[cfg(not(test))]
if !is_enterprise_enabled() {
if !is_business_license_active() {
debug!("Enterprise is not enabled, skipping performing directory sync");
return Ok(());
}
Expand Down
4 changes: 2 additions & 2 deletions crates/defguard_core/src/enterprise/firewall/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::{
db::{Device, User, WireguardNetwork},
enterprise::{
db::models::{acl::AliasKind, snat::UserSnatBinding},
is_enterprise_enabled,
is_business_license_active,
},
};

Expand Down Expand Up @@ -903,7 +903,7 @@ impl WireguardNetwork<Id> {
conn: &mut PgConnection,
) -> Result<Option<FirewallConfig>, FirewallError> {
// do a license check
if !is_enterprise_enabled() {
if !is_business_license_active() {
debug!(
"Enterprise features are disabled, skipping generating firewall config for \
location {self}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use tonic::Status;
use crate::{
enterprise::{
handlers::openid_login::{extract_state_data, user_from_claims},
is_enterprise_enabled,
is_business_license_active,
},
events::{BidiRequestContext, BidiStreamEvent, BidiStreamEventType, DesktopClientMfaEvent},
grpc::{
Expand All @@ -23,7 +23,7 @@ impl ClientMfaServer {
info: Option<DeviceInfo>,
) -> Result<(), Status> {
debug!("Received OIDC MFA authentication request: {request:?}");
if !is_enterprise_enabled() {
if !is_business_license_active() {
error!("OIDC MFA method requires enterprise feature to be enabled");
return Err(Status::invalid_argument("OIDC MFA method is not supported"));
}
Expand Down
4 changes: 2 additions & 2 deletions crates/defguard_core/src/enterprise/grpc/polling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use tonic::Status;

use crate::{
db::{Device, User, models::polling_token::PollingToken},
enterprise::is_enterprise_enabled,
enterprise::is_business_license_active,
grpc::utils::build_device_config_response,
};

Expand All @@ -24,7 +24,7 @@ impl PollingServer {
debug!("Validating polling token. Token: {token}");

// Polling service is enterprise-only, check the lincense
if !is_enterprise_enabled() {
if !is_business_license_active() {
debug!("Instance has enterprise features disabled, denying instance polling info");
return Err(Status::failed_precondition("no valid license"));
}
Expand Down
4 changes: 2 additions & 2 deletions crates/defguard_core/src/enterprise/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use axum::{
};

use super::{
db::models::enterprise_settings::EnterpriseSettings, is_enterprise_enabled,
db::models::enterprise_settings::EnterpriseSettings, is_business_license_active,
license::get_cached_license,
};
use crate::{appstate::AppState, error::WebError};
Expand All @@ -37,7 +37,7 @@ where
type Rejection = WebError;

async fn from_request_parts(_parts: &mut Parts, _state: &S) -> Result<Self, Self::Rejection> {
if is_enterprise_enabled() {
if is_business_license_active() {
Ok(LicenseInfo { valid: true })
} else {
Err(WebError::Forbidden(
Expand Down
6 changes: 3 additions & 3 deletions crates/defguard_core/src/enterprise/ldap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use sync::{get_ldap_sync_status, is_ldap_desynced, set_ldap_sync_status};
use self::error::LdapError;
use crate::{
db::{self, User},
enterprise::{is_enterprise_enabled, ldap::model::extract_dn_path, limits::update_counts},
enterprise::{is_business_license_active, ldap::model::extract_dn_path, limits::update_counts},
};

#[cfg(not(test))]
Expand Down Expand Up @@ -54,7 +54,7 @@ pub(crate) async fn do_ldap_sync(pool: &PgPool) -> Result<(), LdapError> {
return Ok(());
}

if !is_enterprise_enabled() {
if !is_business_license_active() {
info!(
"Enterprise features are disabled, not performing LDAP sync and automatically disabling it"
);
Expand Down Expand Up @@ -100,7 +100,7 @@ where
F: Future<Output = Result<T, LdapError>>,
{
let settings = Settings::get_current_settings();
if !is_enterprise_enabled() {
if !is_business_license_active() {
info!("Enterprise features are disabled, not performing LDAP operation");
set_ldap_sync_status(LdapSyncStatus::OutOfSync, pool).await?;
return Err(LdapError::EnterpriseDisabled("LDAP".to_string()));
Expand Down
Loading