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

Refactor getClient and getLegacyClient to use authentication method registry #5881

Merged

Conversation

bandinib-amzn
Copy link
Member

@bandinib-amzn bandinib-amzn commented Feb 15, 2024

Description

Refactoring client and legacy client to use authentication registry.

Issues Resolved

Partially fixes #5692, #5838

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Copy link

codecov bot commented Feb 15, 2024

Codecov Report

Attention: Patch coverage is 88.57143% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 67.00%. Comparing base (4ab0ca8) to head (d0b1d2b).

Files Patch % Lines
...gins/data_source/server/client/configure_client.ts 85.71% 0 Missing and 2 partials ⚠️
...ta_source/server/legacy/configure_legacy_client.ts 91.66% 0 Missing and 1 partial ⚠️
...ins/data_source/server/util/credential_provider.ts 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5881      +/-   ##
==========================================
- Coverage   67.01%   67.00%   -0.01%     
==========================================
  Files        3305     3307       +2     
  Lines       63585    63614      +29     
  Branches    10155    10163       +8     
==========================================
+ Hits        42611    42627      +16     
- Misses      18505    18518      +13     
  Partials     2469     2469              
Flag Coverage Δ
Linux_1 35.21% <ø> (ø)
Linux_2 55.09% <ø> (ø)
Linux_3 43.63% <88.57%> (+0.04%) ⬆️
Linux_4 35.20% <ø> (ø)
Windows_1 35.24% <ø> (-0.04%) ⬇️
Windows_2 55.06% <ø> (ø)
Windows_3 43.63% <88.57%> (+0.04%) ⬆️
Windows_4 35.20% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -14,6 +14,7 @@ export interface DataSourceAttributes extends SavedObjectAttributes {
credentials: UsernamePasswordTypedContent | SigV4Content | undefined | AuthTypeContent;
};
lastUpdatedTime?: string;
name: AuthType | string;
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's the difference of name vs auth.type?

Copy link
Member Author

Choose a reason for hiding this comment

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

Name can be any unique string to identify the authentication method.

auth.type is to specify using which method request needs to be signed. Right now we only have three ways: No auth, Basic authentication and AWS SigV4 authentication to sign the request.

So for example, I want to add new authentication method named abc for role based authentication. So my plugin will do all the work such as assume role etc to get temporary credentials (Access key, secret key and session token) and provide those data source plugin and will ask to sign request using AWS SigV4 with provided credentials.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see, just curious not a blocker, do we show name on the UI or is it solely used as identifier internally?

} = dataSourceAttr;
const { endpoint: nodeUrl } = dataSourceAttr;
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we extract endpoint as before, eg. line 103

Copy link
Member Author

Choose a reason for hiding this comment

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

nodeUrl is never reassigned. Therefore I used const instead

Copy link
Collaborator

Choose a reason for hiding this comment

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

Got it!

@bandinib-amzn
Copy link
Member Author

Failed functional test is not related to the code change in this PR.

ZilongX
ZilongX previously approved these changes Feb 21, 2024
@ZilongX ZilongX added the multiple datasource multiple datasource project label Feb 21, 2024
@bandinib-amzn bandinib-amzn force-pushed the refactor-datasource-client branch from 95f3a54 to f9ee790 Compare February 22, 2024 18:39
Flyingliuhub
Flyingliuhub previously approved these changes Feb 22, 2024
@bandinib-amzn bandinib-amzn force-pushed the refactor-datasource-client branch from f9ee790 to deac092 Compare February 22, 2024 23:20
@bandinib-amzn bandinib-amzn dismissed stale reviews from ZilongX and Flyingliuhub via d0b1d2b February 23, 2024 00:28
@bandinib-amzn bandinib-amzn force-pushed the refactor-datasource-client branch from deac092 to d0b1d2b Compare February 23, 2024 00:28
@ZilongX ZilongX self-requested a review February 23, 2024 00:31
@bandinib-amzn bandinib-amzn merged commit d56b04d into opensearch-project:main Feb 23, 2024
68 checks passed
@bandinib-amzn bandinib-amzn deleted the refactor-datasource-client branch February 23, 2024 03:05
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch-Dashboards/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch-Dashboards/backport-2.x
# Create a new branch
git switch --create backport/backport-5881-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 d56b04d0aac6aed21825f44eb70bb4a9b512dde0
# Push it to GitHub
git push --set-upstream origin backport/backport-5881-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-5881-to-2.x.

@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch-Dashboards/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch-Dashboards/backport-2.x
# Create a new branch
git switch --create backport/backport-5881-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 d56b04d0aac6aed21825f44eb70bb4a9b512dde0
# Push it to GitHub
git push --set-upstream origin backport/backport-5881-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-5881-to-2.x.

bandinib-amzn added a commit to bandinib-amzn/OpenSearch-Dashboards that referenced this pull request Feb 23, 2024
…egistry (opensearch-project#5881)

* Refactor getClient and getLegacyClient to use authentication method registry

Signed-off-by: Bandini Bhopi <[email protected]>

* Adds changelog and UT

Signed-off-by: Bandini Bhopi <[email protected]>

---------

Signed-off-by: Bandini Bhopi <[email protected]>
(cherry picked from commit d56b04d)
bandinib-amzn added a commit to bandinib-amzn/OpenSearch-Dashboards that referenced this pull request Feb 26, 2024
…egistry (opensearch-project#5881)

* Refactor getClient and getLegacyClient to use authentication method registry

Signed-off-by: Bandini Bhopi <[email protected]>

* Adds changelog and UT

Signed-off-by: Bandini Bhopi <[email protected]>

---------

Signed-off-by: Bandini Bhopi <[email protected]>
(cherry picked from commit d56b04d)
bandinib-amzn added a commit to bandinib-amzn/OpenSearch-Dashboards that referenced this pull request Feb 26, 2024
…egistry (opensearch-project#5881)

* Refactor getClient and getLegacyClient to use authentication method registry

Signed-off-by: Bandini Bhopi <[email protected]>

* Adds changelog and UT

Signed-off-by: Bandini Bhopi <[email protected]>

---------

Signed-off-by: Bandini Bhopi <[email protected]>
(cherry picked from commit d56b04d)
bandinib-amzn added a commit to bandinib-amzn/OpenSearch-Dashboards that referenced this pull request Feb 27, 2024
…egistry (opensearch-project#5881)

* Refactor getClient and getLegacyClient to use authentication method registry

Signed-off-by: Bandini Bhopi <[email protected]>

* Adds changelog and UT

Signed-off-by: Bandini Bhopi <[email protected]>

---------

Signed-off-by: Bandini Bhopi <[email protected]>
(cherry picked from commit d56b04d)
bandinib-amzn added a commit that referenced this pull request Feb 27, 2024
…uthentication method registry (#5881) (#5940)

* Refactor getClient and getLegacyClient to use authentication method registry (#5881)

* Refactor getClient and getLegacyClient to use authentication method registry

Signed-off-by: Bandini Bhopi <[email protected]>

* Adds changelog and UT

Signed-off-by: Bandini Bhopi <[email protected]>

---------

Signed-off-by: Bandini Bhopi <[email protected]>
(cherry picked from commit d56b04d)

* Reverted accidental changes

Signed-off-by: Bandini Bhopi <[email protected]>

---------

Signed-off-by: Bandini Bhopi <[email protected]>
SuZhou-Joe pushed a commit to SuZhou-Joe/OpenSearch-Dashboards that referenced this pull request Mar 4, 2024
…egistry (opensearch-project#5881)

* Refactor getClient and getLegacyClient to use authentication method registry

Signed-off-by: Bandini Bhopi <[email protected]>

* Adds changelog and UT

Signed-off-by: Bandini Bhopi <[email protected]>

---------

Signed-off-by: Bandini Bhopi <[email protected]>
@manasvinibs
Copy link
Member

Manual backport #5940

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.

[Proposal] Refactoring data source plugin to support add-on authentication method with plug-in module
5 participants