Skip to content

Commit

Permalink
Cleans up unwanted changes
Browse files Browse the repository at this point in the history
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
  • Loading branch information
DarshitChanpura committed Sep 28, 2023
1 parent 903f180 commit 3b6f0e1
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 126 deletions.
7 changes: 0 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Implement Visitor Design pattern in QueryBuilder to enable the capability to traverse through the complex QueryBuilder tree. ([#10110](https://github.com/opensearch-project/OpenSearch/pull/10110))
- Add capability to restrict async durability mode for remote indexes ([#10189](https://github.com/opensearch-project/OpenSearch/pull/10189))

- Support for HTTP/2 (server-side) ([#3847](https://github.com/opensearch-project/OpenSearch/pull/3847))
- Add getter for path field in NestedQueryBuilder ([#4636](https://github.com/opensearch-project/OpenSearch/pull/4636))
- Allow mmap to use new JDK-19 preview APIs in Apache Lucene 9.4+ ([#5151](https://github.com/opensearch-project/OpenSearch/pull/5151))
- Add events correlation engine plugin ([#6854](https://github.com/opensearch-project/OpenSearch/issues/6854))
- Introduce new dynamic cluster setting to control slice computation for concurrent segment search ([#9107](https://github.com/opensearch-project/OpenSearch/pull/9107))
- Implement on behalf of token passing for extensions ([#8679](https://github.com/opensearch-project/OpenSearch/pull/8679))

### Dependencies
- Bump JNA version from 5.5 to 5.13 ([#9963](https://github.com/opensearch-project/OpenSearch/pull/9963))
- Bump `peter-evans/create-or-update-comment` from 2 to 3 ([#9575](https://github.com/opensearch-project/OpenSearch/pull/9575))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,16 @@ public Optional<AuthenticationToken> translateAuthToken(org.opensearch.identity.
final BasicAuthToken basicAuthToken = (BasicAuthToken) authenticationToken;
return Optional.of(new UsernamePasswordToken(basicAuthToken.getUser(), basicAuthToken.getPassword()));
}

return Optional.empty();
}

@Override
public AuthToken issueOnBehalfOfToken(Subject subject, OnBehalfOfClaims claims) {

String password = generatePassword();
final byte[] rawEncoded = Base64.getUrlEncoder().encode((claims.getAudience() + ":" + password).getBytes(UTF_8)); // Make a new
// ShiroSubject w/
// audience as
// name
final byte[] rawEncoded = Base64.getUrlEncoder().encode((claims.getAudience() + ":" + password).getBytes(UTF_8));
// Make a new ShiroSubject w/ audience as name
final String usernamePassword = new String(rawEncoded, UTF_8);
final String header = "Basic " + usernamePassword;
BasicAuthToken token = new BasicAuthToken(header);
Expand All @@ -80,12 +79,12 @@ public AuthToken issueOnBehalfOfToken(Subject subject, OnBehalfOfClaims claims)
public AuthToken issueServiceAccountToken(String audience) {

String password = generatePassword();
final byte[] rawEncoded = Base64.getUrlEncoder().withoutPadding().encode((audience + ":" + password).getBytes(UTF_8)); // Make a new
final byte[] rawEncoded = Base64.getUrlEncoder().withoutPadding().encode((audience + ":" + password).getBytes(UTF_8));
final String usernamePassword = new String(rawEncoded, UTF_8);
final String header = "Basic " + usernamePassword;

BasicAuthToken token = new BasicAuthToken(header);
shiroTokenPasswordMap.put(token, password);

return token;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,20 +270,6 @@ public String get(String setting, String defaultValue) {
return retVal == null ? defaultValue : retVal;
}

/**
* Returns a setting value based on the setting key.
*/
public Settings getNestedSettings(String key) {
return (Settings) settings.get(key);
}

/**
* Returns a setting value based on the setting key.
*/
public List<Settings> getNestedListOfSettings(String key) {
return (List<Settings>) settings.get(key);
}

/**
* Returns the setting value (as float) associated with the setting key. If it does not exists,
* returns the default value provided.
Expand Down Expand Up @@ -680,7 +666,6 @@ private static void fromXContent(XContentParser parser, StringBuilder keyBuilder
fromXContent(parser, keyBuilder, builder, allowNullValues);
} else if (parser.currentToken() == XContentParser.Token.START_ARRAY) {
List<String> list = new ArrayList<>();
List<Object> listOfObjects = new ArrayList<>();
while (parser.nextToken() != XContentParser.Token.END_ARRAY) {
if (parser.currentToken() == XContentParser.Token.VALUE_STRING) {
list.add(parser.text());
Expand All @@ -689,19 +674,12 @@ private static void fromXContent(XContentParser parser, StringBuilder keyBuilder
} else if (parser.currentToken() == XContentParser.Token.VALUE_BOOLEAN) {
list.add(String.valueOf(parser.text()));
} else {
listOfObjects.add(fromXContent(parser, true, false));
// throw new IllegalStateException("only value lists are allowed in serialized settings");
throw new IllegalStateException("only value lists are allowed in serialized settings");
}
}
String key = keyBuilder.toString();
validateValue(key, list, parser, allowNullValues);
builder.putList(key, list);
if (!listOfObjects.isEmpty()) {
builder.putListOfObjects(key, listOfObjects);
}
if (!list.isEmpty() && !listOfObjects.isEmpty()) {
throw new IllegalStateException("list cannot contain both values and objects");
}
} else if (parser.currentToken() == XContentParser.Token.VALUE_NULL) {
String key = keyBuilder.toString();
validateValue(key, null, parser, allowNullValues);
Expand Down Expand Up @@ -808,20 +786,6 @@ public String get(String key) {
return Settings.toString(map.get(key));
}

/**
* Returns a setting value based on the setting key.
*/
public Settings getNestedSettings(String key) {
return (Settings) map.get(key);
}

/**
* Returns a setting value based on the setting key.
*/
public List<Settings> getNestedListOfSettings(String key) {
return (List<Settings>) map.get(key);
}

/** Return the current secure settings, or {@code null} if none have been set. */
public SecureSettings getSecureSettings() {
return secureSettings.get();
Expand Down Expand Up @@ -1059,19 +1023,6 @@ public Builder putList(String setting, List<String> values) {
return this;
}

/**
* Sets the setting with the provided setting key and a list of values.
*
* @param setting The setting key
* @param values The values
* @return The builder
*/
public Builder putListOfObjects(String setting, List<Object> values) {
remove(setting);
map.put(setting, new ArrayList<>(values));
return this;
}

/**
* Sets all the provided settings including secure settings
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,6 @@
* compatible open source license.
*/

/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

package org.opensearch.discovery;

import org.opensearch.core.common.io.stream.StreamInput;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public static enum OpenSearchRequestType {
* @param additionalSettings Additional settings to read in from extension initialization request
* @throws IOException If the extensions discovery file is not properly retrieved.
*/
public ExtensionsManager(Set<Setting<?>> additionalSettings, IdentityService identityService) throws IOException {
public ExtensionsManager(Set<Setting<?>> additionalSettings) throws IOException {
logger.info("ExtensionsManager initialized");
this.initializedExtensions = new HashMap<String, DiscoveryExtensionNode>();
this.extensionIdMap = new HashMap<String, DiscoveryExtensionNode>();
Expand All @@ -134,7 +134,6 @@ public ExtensionsManager(Set<Setting<?>> additionalSettings, IdentityService ide
}
this.client = null;
this.extensionTransportActionsHandler = null;
this.identityService = identityService;
}

/**
Expand All @@ -157,6 +156,7 @@ public void initializeServicesAndRestHandler(
NodeClient client,
IdentityService identityService
) {
this.identityService = identityService;
this.restActionsRequestHandler = new RestActionsRequestHandler(
actionModule.getRestController(),
extensionIdMap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
public class NoopExtensionsManager extends ExtensionsManager {

public NoopExtensionsManager() throws IOException {
super(Set.of(), new IdentityService(Settings.EMPTY, List.of()));
super(Set.of());
}

@Override
Expand All @@ -45,6 +45,7 @@ public void initializeServicesAndRestHandler(
NodeClient client,
IdentityService identityService
) {
this.setIdentityService(new IdentityService(Settings.EMPTY, List.of()));
// no-op
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ public String executor() {
};

try {

// Will be replaced with ExtensionTokenProcessor and PrincipalIdentifierToken classes from feature/identity

Map<String, List<String>> filteredHeaders = filterHeaders(headers, allowList, denyList);
Expand Down
3 changes: 1 addition & 2 deletions server/src/main/java/org/opensearch/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,7 @@ protected Node(
for (ExtensionAwarePlugin extAwarePlugin : extensionAwarePlugins) {
additionalSettings.addAll(extAwarePlugin.getExtensionSettings());
}
this.extensionsManager = new ExtensionsManager(additionalSettings, identityService);
this.extensionsManager.setIdentityService(identityService);
this.extensionsManager = new ExtensionsManager(additionalSettings);
} else {
this.extensionsManager = new NoopExtensionsManager();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void testSetupRestHandlerContainsKnownBuiltin() throws IOException {
usageService,
null,
new IdentityService(Settings.EMPTY, new ArrayList<>()),
new ExtensionsManager(Set.of(), new IdentityService(Settings.EMPTY, List.of()))
new ExtensionsManager(Set.of())
);
actionModule.initRestHandlers(null);
// At this point the easiest way to confirm that a handler is loaded is to try to register another one on top of it and to fail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public void testReadContextListener() throws InterruptedException, IOException {
assertEquals(NUMBER_OF_PARTS * PART_SIZE, Files.size(fileLocation));
}

@AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/9776")
public void testReadContextListenerFailure() throws Exception {
Path fileLocation = path.resolve(UUID.randomUUID().toString());
List<InputStreamContainer> blobPartStreams = initializeBlobPartStreams();
Expand Down
Loading

0 comments on commit 3b6f0e1

Please sign in to comment.