-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Remove identity-related feature flagged code from the RestController #15430
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
Merged
reta
merged 25 commits into
opensearch-project:main
from
cwperks:identity-plugin-authenticate
Sep 19, 2024
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
e6b82ba
Add authenticate to IdentityPlugin interface
cwperks bc610a2
Handle null
cwperks 1abfe97
Fix tests
cwperks cf3f41f
Merge branch 'main' into identity-plugin-authenticate
cwperks cdf1892
Fix ActionModuleTests
cwperks 09e8fc0
Add to CHANGELOG
cwperks 4ebccdd
Merge branch 'main' into identity-plugin-authenticate
cwperks 97dd935
Add DelegatingRestHandlerTests
cwperks 7481868
Address forbiddenApi
cwperks 7da9bd7
Remove authenticate from IdentityPlugin and keep RestController featu…
cwperks ca65e4b
Move RestTokenExtractor to identity-shiro plugin
cwperks c286da6
Remove change in IdentityService
cwperks c11aed4
Remove changes in ActionModuleTests
cwperks d9223a9
Add tests for RestTokenExtractor
cwperks aa047f9
Merge branch 'main' into identity-plugin-authenticate
cwperks c107601
Merge branch 'main' into identity-plugin-authenticate
cwperks 05dd6ac
Merge branch 'main' into identity-plugin-authenticate
cwperks b0ce4a8
Merge branch 'main' into identity-plugin-authenticate
cwperks 6409e73
Merge branch 'main' into identity-plugin-authenticate
cwperks df4c042
Remove DelegatingRestHandler
cwperks d3bcc1c
Call super instead of keeping a reference to the delegated restHandler
cwperks 2a56781
Merge branch 'main' into identity-plugin-authenticate
cwperks c8489fe
Address code review comments
cwperks 34bc922
Merge branch 'main' into identity-plugin-authenticate
cwperks c2d9a3a
Merge branch 'main' into identity-plugin-authenticate
cwperks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
45 changes: 45 additions & 0 deletions
45
.../identity-shiro/src/test/java/org/opensearch/identity/shiro/ShiroTokenExtractorTests.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.identity.shiro; | ||
|
||
import org.opensearch.identity.tokens.AuthToken; | ||
import org.opensearch.identity.tokens.BasicAuthToken; | ||
import org.opensearch.rest.RestRequest; | ||
import org.opensearch.test.OpenSearchTestCase; | ||
import org.opensearch.test.rest.FakeRestRequest; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
import java.util.Base64; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.instanceOf; | ||
|
||
public class ShiroTokenExtractorTests extends OpenSearchTestCase { | ||
|
||
public void testAuthorizationHeaderExtractionWithBasicAuthToken() { | ||
String basicAuthHeader = Base64.getEncoder().encodeToString("foo:bar".getBytes(StandardCharsets.UTF_8)); | ||
RestRequest fakeRequest = new FakeRestRequest.Builder(xContentRegistry()).withHeaders( | ||
Map.of(ShiroTokenExtractor.AUTH_HEADER_NAME, List.of(BasicAuthToken.TOKEN_IDENTIFIER + " " + basicAuthHeader)) | ||
).build(); | ||
AuthToken extractedToken = ShiroTokenExtractor.extractToken(fakeRequest); | ||
assertThat(extractedToken, instanceOf(BasicAuthToken.class)); | ||
assertThat(extractedToken.asAuthHeaderValue(), equalTo(basicAuthHeader)); | ||
} | ||
|
||
public void testAuthorizationHeaderExtractionWithUnknownToken() { | ||
String authHeader = "foo"; | ||
RestRequest fakeRequest = new FakeRestRequest.Builder(xContentRegistry()).withHeaders( | ||
Map.of(ShiroTokenExtractor.AUTH_HEADER_NAME, List.of(authHeader)) | ||
).build(); | ||
AuthToken extractedToken = ShiroTokenExtractor.extractToken(fakeRequest); | ||
assertNull(extractedToken); | ||
} | ||
} |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.