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

[MD] Data source with wrong password connection in index pattern #2386

Closed
kristenTian opened this issue Sep 19, 2022 · 5 comments
Closed

[MD] Data source with wrong password connection in index pattern #2386

kristenTian opened this issue Sep 19, 2022 · 5 comments
Assignees
Labels
bug Something isn't working multiple datasource multiple datasource project

Comments

@kristenTian
Copy link
Contributor

If a data source is created with wrong credentials, when user try to use it in index pattern creation. The current behavior will ask user to type in credentials (see screenshots).

However even type in correct ones there, it won't help with the connection. Tested with this data source http://54.70.243.216/app/management/opensearch-dashboards/dataSources/2c080040-37ba-11ed-9c7d-b99e8398c755 on index pattern creation.

image

The proposal is to change the prompt from asking for credentials to a user friendly error message.

@kristenTian kristenTian added bug Something isn't working multiple datasource multiple datasource project labels Sep 19, 2022
@zengyan-amazon
Copy link
Member

@zhongnansu can you take a look?

@kristenTian
Copy link
Contributor Author

Please also test first create with wrong credential, then correct it using update data source, would it work in index pattern step.

@zhongnansu
Copy link
Member

zhongnansu commented Sep 22, 2022

@zengyan-amazon @kristenTian

Proposed Solution

    1. Considering we are adding support of legacy client for data source, after that, index pattern will switch back to use legacy client, then we can set the caller option at the service level, to pass in wrap401Error = false. It will not set WWW-Authenticate header anymore. Noticed this can only be done with legacy client, see 2) for why it wont work with new client.
  • 2. While initiating client for datasource, see if we can have this wrap401Error configured, not likely with legacy client tho. But for new opensearch client, could be. This won't work because new client doesn't add the header, non can be configured ref
    1. We catch the error for data source use case and cast to 400. Catching this error is not doable from data_source service level, can be done at the caller layer. Data_source service is only responsible for getting client. A client with incorrect credentials can still be initiated by data source service, and returned. We currently don't have logic in data source service to validate auth of client at creation time. 401 is thrown when the client is used by for example, index pattern to perform some action, like client.search().

Related Issue/PR #2204, #2133

Summary

I'll go with option 1, to update the #2204 to include the 401 specific change. fyi @zengyan-amazon

@kristenTian
Copy link
Contributor Author

Thanks for great details, what does the service level exactly means in option 1? If you already implemented, could you please share some code example.

@zhongnansu
Copy link
Member

Thanks for great details, what does the service level exactly means in option 1? If you already implemented, could you please share some code example.

In my PR, you can see wrap401Error = false was added as a default param in the callAPI. This is within the data source plugin. We don't need each caller to configure from their side. https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2204/files#diff-442cda9a371f9aa2ce417631ddf7a8b80f9ec6ade15676b1cfe390f1c25b3fe7R109

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working multiple datasource multiple datasource project
Projects
None yet
Development

No branches or pull requests

3 participants