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

[Backport 1.3] Add early rejection from RestHandler for unauthorized requests (#3418) #3675

Merged
merged 25 commits into from
Nov 27, 2023

Conversation

peternied
Copy link
Member

@peternied peternied commented Nov 9, 2023

Description

Includes:


Previously unauthorized requests were fully processed and rejected once they reached the RestHandler. This allocations more memory and resources for these requests that might not be useful if they are already detected as unauthorized. Using the headerVerifer and decompressor customization from [1], perform an early authorization check when only the headers are available, save an 'early response' for transmission and do not perform the decompression on the request to speed up closing out the connection.

graph TD

    oA["Receive Request Headers<br>(Orginal)"] --> oB[Decompress Request]
    oB --> oC[RestHandler]
       oC --> osrf[Intercept Request]
    subgraph sp[Security Plugin]
       osrf --> oD[Check Authorization]
       oD --> oE{Authorized?}
       oE -->|Yes| oF[Process and Respond]
       oE -->|No| oG[Reject Request]
   end
   oF --> oH[Forward to Request Handler]



    H["Receive Request Headers<br>(Updated)"] --> I[HeaderVerifier]
    subgraph nsp[Security Plugin]
       I --> J{Authorized?}
       J -->|Yes| K[Decompress Request]
       J -->|No| N[Save Early Response]
    end
    K --> L[RestHandler]
    N --> L
    L --> M[Intercept Request]
    subgraph n2sp[Security Plugin]
       M --> n2D["Check Authorization<br>(Cached)"]
       n2D --> nE{Authorized?}
       nE -->|Yes| nF[Process and Respond]
       nE -->|No| nG[Reject Request]
   end
   nF --> nH[Forward to Request Handler]

class oA,oB old;
class H,I,K,N,n2D new;
classDef old fill:#f9d0c4,stroke:#f28b82;
classDef new fill:#cfe8fc,stroke:#68a9ef;

Loading

Issues Resolved

Check List

  • New functionality includes testing
  • New functionality has been documented
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

peternied and others added 16 commits November 3, 2023 20:24
Signed-off-by: Peter Nied <petern@amazon.com>
Signed-off-by: Peter Nied <petern@amazon.com>
Signed-off-by: Peter Nied <petern@amazon.com>
Signed-off-by: Peter Nied <petern@amazon.com>
…ion (opensearch-project#3430)

Backport of f20cc68 from opensearch-project#3430

Introduced a new abstraction, SecurityRequest & SecurityRequestChannel,
to streamline and secure the authentication process in the OpenSearch
Security plugin. By isolating the essential request components needed
for authentication, we minimize potential risks associated with previous
designs and provide a more maintainable architecture.

Signed-off-by: Peter Nied <petern@amazon.com>
(cherry picked from commit f20cc68)
Signed-off-by: Peter Nied <petern@amazon.com>
Signed-off-by: Peter Nied <petern@amazon.com>
Signed-off-by: Peter Nied <petern@amazon.com>
Signed-off-by: Peter Nied <petern@amazon.com>
Signed-off-by: Peter Nied <petern@amazon.com>
…action

Signed-off-by: Peter Nied <petern@amazon.com>
Signed-off-by: Peter Nied <petern@amazon.com>
Signed-off-by: Peter Nied <petern@amazon.com>
Signed-off-by: Peter Nied <petern@amazon.com>
Signed-off-by: Peter Nied <petern@amazon.com>
…requests (opensearch-project#3418) (opensearch-project#3495)

Backport of 6b0b682 from opensearch-project#3418

Previously unauthorized requests were fully processed and rejected once
they reached the RestHandler. This allocations more memory and resources
for these requests that might not be useful if they are already detected
as unauthorized. Using the headerVerifer and decompressor customization
from [1], perform an early authorization check when only the headers are
available, save an 'early response' for transmission and do not perform
the decompression on the request to speed up closing out the connection.

- Resolves opensearch-project/OpenSearch#10260

Signed-off-by: Peter Nied <petern@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <craig5008@gmail.com>
Co-authored-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Peter Nied <petern@amazon.com>
@peternied
Copy link
Member Author

peternied commented Nov 9, 2023

I've tested this change locally - CI won't start passing until the related change in core has been merged [1].

Signed-off-by: Peter Nied <petern@amazon.com>
peternied and others added 8 commits November 10, 2023 10:07
Signed-off-by: Peter Nied <peternied@hotmail.com>
Signed-off-by: Peter Nied <peternied@hotmail.com>
Signed-off-by: Peter Nied <petern@amazon.com>
…ejection

Signed-off-by: Peter Nied <petern@amazon.com>
…ation (opensearch-project#3599)

Backport 499db78 from opensearch-project#3583.

---------

Signed-off-by: Craig Perkins <craig5008@gmail.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Peter Nied <petern@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Peter Nied <petern@amazon.com>
Co-authored-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: Peter Nied <petern@amazon.com>
Signed-off-by: Peter Nied <petern@amazon.com>
@peternied peternied changed the title Add early rejection from RestHandler for unauthorized requests (#3418) [Backport 1.3] Add early rejection from RestHandler for unauthorized requests (#3418) Nov 21, 2023
@peternied peternied marked this pull request as ready for review November 21, 2023 23:14
@peternied peternied requested a review from cliu123 as a code owner November 21, 2023 23:14
@willyborankin willyborankin merged commit c608fae into opensearch-project:1.3 Nov 27, 2023
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants