Handle Unauthenticated OPTIONS requests#96061
Merged
albertzaharovits merged 8 commits intoelastic:mainfrom May 12, 2023
Merged
Conversation
Comment on lines
+1659
to
+1668
| if (httpPreRequest.method() != RestRequest.Method.OPTIONS) { | ||
| authenticationService.authenticate( | ||
| httpPreRequest, | ||
| ActionListener.wrap(ignored -> listener.onResponse(null), listener::onFailure) | ||
| ); | ||
| } else { | ||
| // allow for unauthenticated OPTIONS request | ||
| // this includes CORS preflight, and regular OPTIONS that return permitted methods for a given path | ||
| listener.onResponse(null); | ||
| } |
Contributor
Author
There was a problem hiding this comment.
This is the interesting part. Allow requests with OPTIONS method to bypass authentication.
Comment on lines
+64
to
+71
| // requests with the OPTIONS method should be handled elsewhere, and not by calling {@code RestHandler#handleRequest} | ||
| // authn is bypassed for HTTP requests with the OPTIONS method, so this sanity check prevents dispatching unauthenticated requests | ||
| if (request.method() == Method.OPTIONS) { | ||
| // CORS - allow for preflight unauthenticated OPTIONS request | ||
| restHandler.handleRequest(request, channel, client); | ||
| handleException( | ||
| request, | ||
| channel, | ||
| new ElasticsearchSecurityException("Cannot dispatch OPTIONS request, as they are not authenticated") | ||
| ); |
Contributor
Author
There was a problem hiding this comment.
This is the second most interesting part.
Because OPTIONS requests bypass authentication, this is a sanity check that unauthenticated OPTIONS requests are not dispatched.
Collaborator
|
Pinging @elastic/es-security (Team:Security) |
Contributor
Author
|
Will loop this with @jakelandis post merge, as this is blocking some time-sensitive projects. ⚡ |
legrego
added a commit
to elastic/kibana
that referenced
this pull request
May 16, 2023
Resolves #157017 Resolves #157018 Unskips our Interactive Setup functional tests, which started failing after a recent ES snapshot promotion. This was caused by a regression in Elasticsearch, which was resolved via elastic/elasticsearch#96061. I will not be running a flaky test suite here, as these tests were consistently failing, as opposed to flaky.
jasonrhodes
pushed a commit
to elastic/kibana
that referenced
this pull request
May 17, 2023
Resolves #157017 Resolves #157018 Unskips our Interactive Setup functional tests, which started failing after a recent ES snapshot promotion. This was caused by a regression in Elasticsearch, which was resolved via elastic/elasticsearch#96061. I will not be running a flaky test suite here, as these tests were consistently failing, as opposed to flaky.
albertzaharovits
added a commit
to albertzaharovits/elasticsearch
that referenced
this pull request
Jun 15, 2023
This address HTTP OPTIONS requests following the authentication refactoring in elastic#95112. Relates elastic#95112
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This address HTTP OPTIONS requests following
the authentication refactoring in #95112.
Relates #95112