OpenSearch icon indicating copy to clipboard operation
OpenSearch copied to clipboard

Add authenticate to IdentityPlugin interface

Open cwperks opened this issue 1 year ago • 4 comments

Description

This PR is a follow-up to https://github.com/opensearch-project/OpenSearch/pull/14630. This PR adds authenticate to the IdentityPlugin interface and mimics how ActionPlugin.getRestHandlerWrapper works. ActionPlugin.getRestHandlerWrapper is an extension point specifically meant for Security to authenticate requests before delegating to the original rest handler. If a request is not authenticated, an unauthorized response is sent back to the client and the original rest handler is never delegated to.

I'm opening this PR as a step to removing the Identity feature flag (but keeping the interface marked as experimental).

I am planning to ask plugin maintainers to remove usages of ThreadContext.stashContext after the experimental feature flag for identity is removed.

This PR has a lot of overlap with https://github.com/opensearch-project/OpenSearch/pull/14630:

  • Adds threadPool to the constructor of IdentityService
  • Moves IdentityService instantiation to after the ThreadPool is created

Related Issues

Related to https://github.com/opensearch-project/security/issues/4439

Check List

  • [X] Functionality includes testing.
  • [X] API changes companion pull request created, if applicable.
  • [X] Public documentation issue/PR created, if applicable.

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.

cwperks avatar Aug 26 '24 20:08 cwperks

:x: Gradle check result for e6b82ba19e6c66a83709b5dd6e85b36f299b1146: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

github-actions[bot] avatar Aug 26 '24 21:08 github-actions[bot]

:x: Gradle check result for bc610a25b581abdb65618625224acb0372fb9161: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

github-actions[bot] avatar Aug 27 '24 00:08 github-actions[bot]

:grey_exclamation: Gradle check result for 1abfe9747245c6bcde568a2a67cc3d3d01eaef33: UNSTABLE

  • TEST FAILURES:
      2 org.opensearch.cluster.MinimumClusterManagerNodesIT.testThreeNodesNoClusterManagerBlock
      1 org.opensearch.remotestore.RemoteStoreStatsIT.testNonZeroPrimaryStatsOnNewlyCreatedIndexWithZeroDocs

Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure.

github-actions[bot] avatar Aug 27 '24 02:08 github-actions[bot]

Codecov Report

Attention: Patch coverage is 14.28571% with 18 lines in your changes missing coverage. Please review.

Project coverage is 71.95%. Comparing base (3937ccb) to head (c2d9a3a). Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
...opensearch/identity/shiro/ShiroIdentityPlugin.java 0.00% 16 Missing :warning:
...opensearch/identity/shiro/ShiroTokenExtractor.java 50.00% 1 Missing :warning:
...ensearch/identity/shiro/realm/OpenSearchRealm.java 50.00% 1 Missing :warning:
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #15430      +/-   ##
============================================
+ Coverage     71.90%   71.95%   +0.05%     
+ Complexity    64392    64376      -16     
============================================
  Files          5278     5278              
  Lines        300877   300871       -6     
  Branches      43478    43475       -3     
============================================
+ Hits         216351   216504     +153     
+ Misses        66747    66624     -123     
+ Partials      17779    17743      -36     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Aug 27 '24 02:08 codecov[bot]

Rebased this PR with the latest from main

cwperks avatar Aug 28 '24 20:08 cwperks

:grey_exclamation: Gradle check result for cdf1892cd87a554a0b4744db53d520263bc0fdcb: UNSTABLE

Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure.

github-actions[bot] avatar Aug 28 '24 20:08 github-actions[bot]

:white_check_mark: Gradle check result for 09e8fc0163fbb3aade29d1b921d0121a2c31ae78: SUCCESS

github-actions[bot] avatar Aug 28 '24 21:08 github-actions[bot]

Resolved conflicts in CHANGELOG.md and added tests

cwperks avatar Aug 29 '24 16:08 cwperks

:x: Gradle check result for 97dd9352de6e77ded505230395a27f725a10739e: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

github-actions[bot] avatar Aug 29 '24 17:08 github-actions[bot]

:grey_exclamation: Gradle check result for 74818684b1c69c7862921ce271e5eb57c370b164: UNSTABLE

  • TEST FAILURES:
      1 org.opensearch.search.SearchTimeoutIT.testSimpleTimeout {p0={"search.concurrent_segment_search.enabled":"true"}}
      1 org.opensearch.remotestore.RemoteStoreStatsIT.testDownloadStatsCorrectnessSinglePrimarySingleReplica

Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure.

github-actions[bot] avatar Aug 29 '24 18:08 github-actions[bot]

@stephen-crawford would you take a look when you have a moment?

cwperks avatar Aug 29 '24 19:08 cwperks

:x: Gradle check result for ca65e4bb50bf8fbb3fa97221fe05a767895a018a: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

github-actions[bot] avatar Aug 29 '24 20:08 github-actions[bot]

:grey_exclamation: Gradle check result for ca65e4bb50bf8fbb3fa97221fe05a767895a018a: UNSTABLE

Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure.

github-actions[bot] avatar Aug 29 '24 20:08 github-actions[bot]

:white_check_mark: Gradle check result for c286da66191ca09385854e3823a05a242dde2f61: SUCCESS

github-actions[bot] avatar Aug 29 '24 20:08 github-actions[bot]

:white_check_mark: Gradle check result for c11aed4f0b0b293f23dce4abfe69877f79d2c540: SUCCESS

github-actions[bot] avatar Aug 29 '24 20:08 github-actions[bot]

:x: Gradle check result for d9223a976db20ccdc406bd6cc56c469af815e0a4: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

github-actions[bot] avatar Aug 29 '24 21:08 github-actions[bot]

:white_check_mark: Gradle check result for aa047f9f5c7911f78cb7407dba6e4645e3d6bc2d: SUCCESS

github-actions[bot] avatar Aug 30 '24 14:08 github-actions[bot]

:grey_exclamation: Gradle check result for c107601af11052ac8a0b1b52d83e2b520c984f11: UNSTABLE

Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure.

github-actions[bot] avatar Sep 03 '24 14:09 github-actions[bot]

:x: Gradle check result for 05dd6ac550c0668d70481ef6942b74284a2d3aab: null

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

github-actions[bot] avatar Sep 04 '24 13:09 github-actions[bot]

:white_check_mark: Gradle check result for 05dd6ac550c0668d70481ef6942b74284a2d3aab: SUCCESS

github-actions[bot] avatar Sep 04 '24 20:09 github-actions[bot]

Rebased with latest from main

cwperks avatar Sep 10 '24 13:09 cwperks

:white_check_mark: Gradle check result for b0ce4a8593efae52ea6be8bae8b39404a3853e1a: SUCCESS

github-actions[bot] avatar Sep 10 '24 14:09 github-actions[bot]

@reta What do you think of this PR now? Instead of creating a new extension point in the IdentityPlugin, I changed this PR to remove the code from the RestController that is not suitable for the security plugin.

cwperks avatar Sep 10 '24 19:09 cwperks

@reta What do you think of this PR now? Instead of creating a new extension point in the IdentityPlugin, I changed this PR to remove the code from the RestController that is not suitable for the security plugin.

Thanks @cwperks , I will take a look in the next few days, sorry about the delay.

reta avatar Sep 11 '24 13:09 reta

:white_check_mark: Gradle check result for df4c0423fb3fbd4424332395baa32eb0520b52aa: SUCCESS

github-actions[bot] avatar Sep 11 '24 23:09 github-actions[bot]

@cwperks I think it looks pretty good, a few minor comments but LGTM otherwise, thanks!

reta avatar Sep 12 '24 13:09 reta

:white_check_mark: Gradle check result for d3bcc1cedd17727a7b8f879d88e21e117393a131: SUCCESS

github-actions[bot] avatar Sep 12 '24 14:09 github-actions[bot]

:white_check_mark: Gradle check result for 2a5678148956b33497ba0882e37799002f3b392a: SUCCESS

github-actions[bot] avatar Sep 12 '24 14:09 github-actions[bot]

:white_check_mark: Gradle check result for c8489fea8e4e74954db4fd6d7a270494c1c475ba: SUCCESS

github-actions[bot] avatar Sep 12 '24 16:09 github-actions[bot]

:x: Gradle check result for 34bc922d1b2f0cd20826102864a09b427fb94f5a: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

github-actions[bot] avatar Sep 18 '24 21:09 github-actions[bot]