Skip to content

Conversation

@rjernst
Copy link
Member

@rjernst rjernst commented Mar 24, 2020

Xpack license state contains a helper method to determine whether
security is disabled due to license level defaults. Most code needs to
know whether security is enabled, not disabled, but this method exists
so that the security being explicitly disabled can be distinguished from
licence level defaulting to disabled. However, in the case that security
is explicitly disabled, the handlers in question are never registered,
so security is implicitly not disabled explicitly, and thus we can share
a single method to know whether licensing is enabled.

Xpack license state contains a helper method to determine whether
security is disabled due to license level defaults. Most code needs to
know whether security is enabled, not disabled, but this method exists
so that the security being explicitly disabled can be distinguished from
licence level defaulting to disabled. However, in the case that security
is explicitly disabled, the handlers in question are never registered,
so security is implicitly not disabled explicitly, and thus we can share
a single method to know whether licensing is enabled.
@rjernst rjernst added >refactoring :Security/License License functionality for commercial features v8.0.0 v7.7.0 labels Mar 24, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-security (:Security/License)

@rjernst rjernst requested a review from tvernum March 24, 2020 00:58
Copy link
Contributor

@tvernum tvernum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, subject to the 2 comments below.

}
} else if (SECURITY_ACTION_MATCHER.test(action)) {
if (licenseState.isSecurityDisabledByLicenseDefaults()) {
if (licenseState.isSecurityEnabled()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one looks to be backwards.

Suggested change
if (licenseState.isSecurityEnabled()) {
if (licenseState.isSecurityEnabled() == false) {

// FIPS 140
assertThat(source.getValue("fips_140.enabled"), is(fips140Enabled));
} else {
if (explicitlyDisabled) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't follow how this works. We don't seem to configure the value security.enabled based on explicitlyDisabled.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops you're right, I need to explicitly set the settings as well since SecurityUsageTransportAction checks it as well.

@bpintea bpintea added v7.8.0 and removed v7.7.0 labels Mar 25, 2020
@rjernst rjernst merged commit 0bee3f7 into elastic:master Mar 25, 2020
@rjernst rjernst deleted the refactor_license5 branch March 25, 2020 23:42
rjernst added a commit that referenced this pull request Mar 26, 2020
This was a bug in #54043, where the logic for security being enabled
needs to be combined with it not being explicitly disabled.
rjernst added a commit to rjernst/elasticsearch that referenced this pull request Mar 26, 2020
Xpack license state contains a helper method to determine whether
security is disabled due to license level defaults. Most code needs to
know whether security is enabled, not disabled, but this method exists
so that the security being explicitly disabled can be distinguished from
licence level defaulting to disabled. However, in the case that security
is explicitly disabled, the handlers in question are never registered,
so security is implicitly not disabled explicitly, and thus we can share
a single method to know whether licensing is enabled.
rjernst added a commit that referenced this pull request Mar 26, 2020
Xpack license state contains a helper method to determine whether
security is disabled due to license level defaults. Most code needs to
know whether security is enabled, not disabled, but this method exists
so that the security being explicitly disabled can be distinguished from
licence level defaulting to disabled. However, in the case that security
is explicitly disabled, the handlers in question are never registered,
so security is implicitly not disabled explicitly, and thus we can share
a single method to know whether licensing is enabled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>refactoring :Security/License License functionality for commercial features v7.8.0 v8.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants