Skip to content

Commit 16f2314

Browse files
rjernstAdam Locke
authored andcommitted
Enforce license expiration (elastic#79671)
Licensed features in check the license state to determine if a feature is currently allowed. When the license expires, the feature should no longer work, falling back to any Basic licensed behavior. Historically though, some features have had lenient behavior, continuing to work indefinitely after the license has expired. This commit changes most of the existing licensed features that were lenient to enforce license expiration. The one exception is ip filtering, which will remain working.
1 parent 15597b4 commit 16f2314

File tree

3 files changed

+14
-23
lines changed

3 files changed

+14
-23
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/license/LicensedFeature.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ public boolean check(XPackLicenseState state) {
4141
* A Persistent feature is one that is tracked starting when the license is checked, and later may be untracked.
4242
*/
4343
public static class Persistent extends LicensedFeature {
44-
private Persistent(String family, String name, License.OperationMode minimumOperationMode, boolean needsActive) {
45-
super(family, name, minimumOperationMode, needsActive);
44+
private Persistent(String family, String name, License.OperationMode minimumOperationMode) {
45+
super(family, name, minimumOperationMode, true);
4646
}
4747

4848
/**
@@ -111,7 +111,7 @@ public static Momentary momentary(String family, String name, License.OperationM
111111

112112
/** Create a persistent feature for the given license level */
113113
public static Persistent persistent(String family, String name, License.OperationMode licenseLevel) {
114-
return new Persistent(family, name, licenseLevel, true);
114+
return new Persistent(family, name, licenseLevel);
115115
}
116116

117117
/**
@@ -123,15 +123,6 @@ public static Momentary momentaryLenient(String family, String name, License.Ope
123123
return new Momentary(family, name, licenseLevel, false);
124124
}
125125

126-
/**
127-
* Creates a persistent feature, but one that is lenient as
128-
* to whether the license needs to be active to allow the feature.
129-
*/
130-
@Deprecated
131-
public static Persistent persistentLenient(String family, String name, License.OperationMode licenseLevel) {
132-
return new Persistent(family, name, licenseLevel, false);
133-
}
134-
135126
/**
136127
* Returns whether the feature is allowed by the current license
137128
* without affecting feature tracking.

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/SecurityField.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ public final class SecurityField {
2323
// Document and Field Level Security are Platinum+
2424
private static final String DLS_FLS_FEATURE_FAMILY = "security-dls-fls";
2525
public static final LicensedFeature.Momentary DOCUMENT_LEVEL_SECURITY_FEATURE =
26-
LicensedFeature.momentaryLenient(DLS_FLS_FEATURE_FAMILY, "dls", License.OperationMode.PLATINUM);
26+
LicensedFeature.momentary(DLS_FLS_FEATURE_FAMILY, "dls", License.OperationMode.PLATINUM);
2727
public static final LicensedFeature.Momentary FIELD_LEVEL_SECURITY_FEATURE =
28-
LicensedFeature.momentaryLenient(DLS_FLS_FEATURE_FAMILY, "fls", License.OperationMode.PLATINUM);
28+
LicensedFeature.momentary(DLS_FLS_FEATURE_FAMILY, "fls", License.OperationMode.PLATINUM);
2929

3030

3131
private SecurityField() {

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -357,29 +357,29 @@ public class Security extends Plugin implements SystemIndexPlugin, IngestPlugin,
357357
public static final LicensedFeature.Momentary IP_FILTERING_FEATURE =
358358
LicensedFeature.momentaryLenient(null, "security-ip-filtering", License.OperationMode.GOLD);
359359
public static final LicensedFeature.Momentary AUDITING_FEATURE =
360-
LicensedFeature.momentaryLenient(null, "security-auditing", License.OperationMode.GOLD);
360+
LicensedFeature.momentary(null, "security-auditing", License.OperationMode.GOLD);
361361
public static final LicensedFeature.Momentary TOKEN_SERVICE_FEATURE =
362-
LicensedFeature.momentaryLenient(null, "security-token-service", License.OperationMode.STANDARD);
362+
LicensedFeature.momentary(null, "security-token-service", License.OperationMode.STANDARD);
363363

364364
private static final String REALMS_FEATURE_FAMILY = "security-realms";
365365
// Builtin realms (file/native) realms are Basic licensed, so don't need to be checked or tracked
366366
// Some realms (LDAP, AD, PKI) are Gold+
367367
public static final LicensedFeature.Persistent LDAP_REALM_FEATURE =
368-
LicensedFeature.persistentLenient(REALMS_FEATURE_FAMILY, "ldap", License.OperationMode.GOLD);
368+
LicensedFeature.persistent(REALMS_FEATURE_FAMILY, "ldap", License.OperationMode.GOLD);
369369
public static final LicensedFeature.Persistent AD_REALM_FEATURE =
370-
LicensedFeature.persistentLenient(REALMS_FEATURE_FAMILY, "active-directory", License.OperationMode.GOLD);
370+
LicensedFeature.persistent(REALMS_FEATURE_FAMILY, "active-directory", License.OperationMode.GOLD);
371371
public static final LicensedFeature.Persistent PKI_REALM_FEATURE =
372-
LicensedFeature.persistentLenient(REALMS_FEATURE_FAMILY, "pki", License.OperationMode.GOLD);
372+
LicensedFeature.persistent(REALMS_FEATURE_FAMILY, "pki", License.OperationMode.GOLD);
373373
// SSO realms are Platinum+
374374
public static final LicensedFeature.Persistent SAML_REALM_FEATURE =
375-
LicensedFeature.persistentLenient(REALMS_FEATURE_FAMILY, "saml", License.OperationMode.PLATINUM);
375+
LicensedFeature.persistent(REALMS_FEATURE_FAMILY, "saml", License.OperationMode.PLATINUM);
376376
public static final LicensedFeature.Persistent OIDC_REALM_FEATURE =
377-
LicensedFeature.persistentLenient(REALMS_FEATURE_FAMILY, "oidc", License.OperationMode.PLATINUM);
377+
LicensedFeature.persistent(REALMS_FEATURE_FAMILY, "oidc", License.OperationMode.PLATINUM);
378378
public static final LicensedFeature.Persistent KERBEROS_REALM_FEATURE =
379-
LicensedFeature.persistentLenient(REALMS_FEATURE_FAMILY, "kerberos", License.OperationMode.PLATINUM);
379+
LicensedFeature.persistent(REALMS_FEATURE_FAMILY, "kerberos", License.OperationMode.PLATINUM);
380380
// Custom realms are Platinum+
381381
public static final LicensedFeature.Persistent CUSTOM_REALMS_FEATURE =
382-
LicensedFeature.persistentLenient(REALMS_FEATURE_FAMILY, "custom", License.OperationMode.PLATINUM);
382+
LicensedFeature.persistent(REALMS_FEATURE_FAMILY, "custom", License.OperationMode.PLATINUM);
383383

384384
public static final LicensedFeature.Momentary DELEGATED_AUTHORIZATION_FEATURE =
385385
LicensedFeature.momentary(null, "security-delegated-authorization", License.OperationMode.PLATINUM);

0 commit comments

Comments
 (0)