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

Add proxy username and password settings for Azure repository plugin #2098

Merged
merged 1 commit into from
Feb 15, 2022

Conversation

willyborankin
Copy link
Contributor

@willyborankin willyborankin commented Feb 12, 2022

Description

Now to configure Azure plugin to use any proxy you need to set username/password using standard process variables:

Such settings have 2 main problems:

  • Storing password this way is insecure
  • In case of password leaking it is necessary to restart all nodes in the cluster

To avoid of a such problem username and password security settings were added
Storing username/password in security settings is more secure compare to process settings and in case of any problem with username and password such security settings could be reloaded without restart of each node in the cluster.

Re-loadable security settings:

  • azure.client.*.proxy.username - Proxy user name
  • azure.client.*.proxy.password - Proxy user password

Issues Resolved

[List any issues this PR will resolve]

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • 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.

@opensearch-ci-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success 76c49fa37417aec92265cc02e11db34176dd337b
Log 2361

Reports 2361

@willyborankin willyborankin marked this pull request as ready for review February 12, 2022 22:30
@willyborankin willyborankin requested a review from a team as a code owner February 12, 2022 22:30
@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success b09a27a234ca91554d7d47017c61e283635b6e53
Log 2365

Reports 2365

@opensearch-ci-bot
Copy link
Collaborator

❌   Gradle Check failure b32ccb3c436168052086cc470c1f1bf50ec75de2
Log 2366

Reports 2366

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success d5c6238497f1e789c9c1e9886480289bc9ed23ae
Log 2369

Reports 2369

@willyborankin willyborankin changed the title Add proxy username and password settings for Azure repository Add proxy username and password settings for Azure repository plugin Feb 14, 2022
}
});
}
final Type azureProxyType = proxySettings.getType() == Proxy.Type.SOCKS ? Type.SOCKS5 : Type.HTTP;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure we should discard the possibility of Type.SOCKS4 usage since we don't know all possible deployment scenarios. May be it makes sense to widen the proxy types (detach from enumeration) to DIRECT, HTTP, SOCKS (default to SOCKS4 to support compatibility since this is what is being picked right now), SOCKS4, SOCKS5?

Copy link
Contributor Author

@willyborankin willyborankin Feb 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is the problem that Azure SDK wraps up Proxy.Tpe and the real type for both - is Proxy.Type.SOCKS. We can set any in this case, since JDK takes care about SOCKS version

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I get what do you mean. Let's use Azure SDK ProxyType explicitly

Copy link
Contributor Author

@willyborankin willyborankin Feb 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. I had had to add ProxySettings.ProxyType. It wraps Azure SDK Type and use NONE as a default value, since settings cannot be null, and we need to check if ProxyType was set or not.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@dblock dblock requested a review from kartg February 14, 2022 17:08
AZURE_CLIENT_PREFIX_KEY,
"proxy.type",
(key) -> new Setting<>(key, "direct", s -> Proxy.Type.valueOf(s.toUpperCase(Locale.ROOT)), Property.NodeScope),
(key) -> new Setting<>(key, "none", s -> ProxySettings.ProxyType.valueOf(s.toUpperCase(Locale.ROOT)), Property.NodeScope),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not keep direct as the default? It seems like none is really not needed


SOCKS5(ProxyOptions.Type.SOCKS5.name()),

NONE("NONE");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We better keep DIRECT instead of none since people may use this value (and it was a default)

public static enum ProxyType {
HTTP(ProxyOptions.Type.HTTP.name()),

SOCKS4(ProxyOptions.Type.SOCKS4.name()),
Copy link
Collaborator

@reta reta Feb 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need SOCKS(ProxyOptions.Type.SOCKS4.name()) since it was a legit proxy value before (but mark is as @Deprecated, referring to SOCKS4)

@opensearch-ci-bot
Copy link
Collaborator

❌   Gradle Check failure 3341e652c0ce03374c9c3ba84aaba7f2c5443fb5
Log 2381

Reports 2381

@willyborankin
Copy link
Contributor Author

@reta fixed your comments

+ username
+ '\''
+ ", password='"
+ (Strings.isNullOrEmpty(password) ? "NO_EMPTY" : "EMPTY")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super minor: NOT_EMPTY (or *****)

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success d1cdcae982e5be7d6c2b98dbfca7f0c025782110
Log 2383

Reports 2383

@dblock
Copy link
Member

dblock commented Feb 14, 2022

- Help me understand where username/password are actually stored?

  • Are they stored in plain text or something else?
  • Are these values logged anywhere?
  • Is blank a valid password?

I see secureString and what happens below, thanks.

@dblock
Copy link
Member

dblock commented Feb 14, 2022

Please open related issues to document this plugin and its settings in https://github.com/opensearch-project/documentation-website.

@dblock
Copy link
Member

dblock commented Feb 14, 2022

@kartg Care to give this another look and merge?

@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success 13eadeed3dafb7b7b0830543810009f2909aa9c1
Log 2399

Reports 2399

final ProxySettings proxySettings = azureStorageSettings.getProxySettings();
if (proxySettings != ProxySettings.NO_PROXY_SETTINGS) {
if (proxySettings.isAuthenticated()) {
Authenticator.setDefault(new Authenticator() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it must be wrapped up with SocketAccess

Added username/password proxy settings for Azure repository.
Security settings:
- azure.client.*.proxy.username - Proxy user name
- azure.client.*.proxy.password - Proxy user password

Signed-off-by: Andrey Pleskach <[email protected]>
@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success 36df329
Log 2401

Reports 2401

@kartg kartg merged commit 62361ce into opensearch-project:main Feb 15, 2022
opensearch-trigger-bot bot pushed a commit that referenced this pull request Feb 15, 2022
Added username/password proxy settings for Azure repository.
Security settings:
- azure.client.*.proxy.username - Proxy user name
- azure.client.*.proxy.password - Proxy user password

Signed-off-by: Andrey Pleskach <[email protected]>
(cherry picked from commit 62361ce)
@@ -325,7 +327,7 @@ public String toString() {
sb.append(", timeout=").append(timeout);
sb.append(", endpointSuffix='").append(endpointSuffix).append('\'');
sb.append(", maxRetries=").append(maxRetries);
sb.append(", proxy=").append(proxy);
sb.append(", proxySettings=").append(proxySettings != ProxySettings.NO_PROXY_SETTINGS ? "PROXY_SET" : "PROXY_NOT_SET");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nitpick, but things like PROXY_SET imply some kind of variable. Since this is a log, maybe just use "set" and "not set"?

dblock pushed a commit that referenced this pull request Feb 16, 2022
…#2108)

Added username/password proxy settings for Azure repository.
Security settings:
- azure.client.*.proxy.username - Proxy user name
- azure.client.*.proxy.password - Proxy user password

Signed-off-by: Andrey Pleskach <[email protected]>
(cherry picked from commit 62361ce)

Co-authored-by: Andrey Pleskach <[email protected]>
@willyborankin
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants