Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a warning header when a license is about to expire #64948

Merged
merged 21 commits into from
Dec 4, 2020

Conversation

BigPandaToo
Copy link
Contributor

@BigPandaToo BigPandaToo commented Nov 11, 2020

This implementation will add the warning header
if the license is going to expire in less than
{LICENSE_EXPIRATION_WARNING_PERIOD} days.
The messages added:

Warning: 299 Elasticsearch-8.0.0-###"Your license will expire in [N] days. Contact your administrator or update your license for continued use of features"

or

Warning: 299 Elasticsearch-8.0.0-### "Your license expires today. Contact your administrator or update your license for continued use of features"

If license has expired less than
{GRACE_PERIOD_DURATION} days ago following
warning is added:

Warning: 299 Elasticsearch-8.0.0-### "Your license expired on ["EEEE, MMMM dd, yyyy" ]. Contact your administrator or update your license for continued use of features"

Both {LICENSE_EXPIRATION_WARNING_PERIOD}
and {GRACE_PERIOD_DURATION} are currently 7 days.

The message will be added to each request unless
authentication fails.
Note: with this change all warning headers will be removed
from a response if authentication fails.

Resolves #60562

@BigPandaToo BigPandaToo marked this pull request as draft November 11, 2020 16:05
@BigPandaToo
Copy link
Contributor Author

@elasticmachine update branch

@BigPandaToo BigPandaToo marked this pull request as ready for review November 11, 2020 16:54
@BigPandaToo
Copy link
Contributor Author

@elasticmachine update branch

@BigPandaToo BigPandaToo marked this pull request as draft November 11, 2020 16:59
@BigPandaToo
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/bwc

1 similar comment
@BigPandaToo
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/bwc

@BigPandaToo
Copy link
Contributor Author

@elasticmachine update branch

@BigPandaToo BigPandaToo marked this pull request as ready for review November 11, 2020 19:54
@BigPandaToo
Copy link
Contributor Author

@elasticmachine update branch

@BigPandaToo BigPandaToo marked this pull request as draft November 11, 2020 19:55
@BigPandaToo
Copy link
Contributor Author

@elasticmachine update branch

elasticmachine and others added 2 commits November 12, 2020 04:41
…on to the responses of _security/oidc/authenticate and _security/oidc/authenticate APIs

Resolves elastic#53161
@BigPandaToo BigPandaToo marked this pull request as ready for review November 12, 2020 20:09
Copy link
Member

@jkakavas jkakavas left a comment

Choose a reason for hiding this comment

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

I left a few comments. I also think we need to elaborate on the PR description ( it's not clear what through SECURITY_IP_FILTER means ) and add a couple of sentences on why we add the check on checkFeature and more especially why we think this is enough for solving the issue this PR is meant to.

We also need some tests that ensure we are indeed adding the warning header under the circumstances we expect it to be added

@BigPandaToo BigPandaToo added Team:Security Meta label for security team v7.11.0 v8.0.0 labels Nov 17, 2020
@elasticmachine
Copy link
Collaborator

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

@BigPandaToo BigPandaToo added the :Security/License License functionality for commercial features label Nov 17, 2020
@BigPandaToo
Copy link
Contributor Author

@elasticmachine update branch

@BigPandaToo
Copy link
Contributor Author

@elasticmachine update branch

 messages; changing "today" calculation; adding a test case for failing
 authN to make sure we remove the warning header
@BigPandaToo BigPandaToo requested a review from tvernum December 1, 2020 20:12
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, but I'd like to hear from @tbrooks8 before we merge.
(and if we can switch to assertThat, that would be good too)

@BigPandaToo
Copy link
Contributor Author

@elasticmachine update branch

Copy link
Contributor

@Tim-Brooks Tim-Brooks left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@jkakavas jkakavas left a comment

Choose a reason for hiding this comment

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

Just some nits suggestions and a question regarding if removing all warning headers on authentication failure is intentional

@BigPandaToo
Copy link
Contributor Author

Just some nits suggestions and a question regarding if removing all warning headers on authentication failure is intentional

@jkakavas Yes, it is intentional (see Tim's comment above). If Authentication fails it does make sense to not reveal any additional information

@jkakavas jkakavas self-requested a review December 4, 2020 10:48
Copy link
Member

@jkakavas jkakavas left a comment

Choose a reason for hiding this comment

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

LGTM

@BigPandaToo
Copy link
Contributor Author

@elasticmachine update branch

@BigPandaToo BigPandaToo merged commit 0b586c2 into elastic:master Dec 4, 2020
BigPandaToo added a commit to BigPandaToo/elasticsearch that referenced this pull request Dec 4, 2020
)

* This change adds a warning header when a license is about to expire

Resolves elastic#60562

* This change adds realm name of the realm used to perform authentication to the responses of _security/oidc/authenticate and _security/oidc/authenticate APIs

Resolves elastic#53161

* Adding doc for the new API introduced by elastic#64517 - /_security/saml/metadata/{realm}

Related to elastic#49018

* Adding a warning header when a license is about to expire

Resolves elastic#60562

* Addressing the PR feedback

* Switching back to adding the header during featureCheck to allow
warnings when authentication is disabled as well. Adding filterHeader
implementation to SecurityRestFilter exception handling to remove all
the warnings if authentication fails.

* Changing the wording for "expired" message to be consistent with the log
 messages; changing "today" calculation; adding a test case for failing
 authN to make sure we remove the warning header

* Small changes in the way we verify header in tests

* Nit changes

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
BigPandaToo added a commit that referenced this pull request Dec 5, 2020
)

* Adding a warning header when a license is about to expire (#64948)

* This change adds a warning header when a license is about to expire

Resolves #60562

* This change adds realm name of the realm used to perform authentication to the responses of _security/oidc/authenticate and _security/oidc/authenticate APIs

Resolves #53161

* Adding doc for the new API introduced by #64517 - /_security/saml/metadata/{realm}

Related to #49018

* Adding a warning header when a license is about to expire

Resolves #60562

* Addressing the PR feedback

* Switching back to adding the header during featureCheck to allow
warnings when authentication is disabled as well. Adding filterHeader
implementation to SecurityRestFilter exception handling to remove all
the warnings if authentication fails.

* Changing the wording for "expired" message to be consistent with the log
 messages; changing "today" calculation; adding a test case for failing
 authN to make sure we remove the warning header

* Small changes in the way we verify header in tests

* Nit changes

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

* Resolving backporting issue: adding copyMapWithRemovedEntry() util function
Fixing unused imports

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@BigPandaToo BigPandaToo deleted the Warning_header branch April 19, 2021 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Security/License License functionality for commercial features Team:Security Meta label for security team v7.11.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide warning headers when using a licensed feature and the license expiration is looming
9 participants