Skip to content

Commit

Permalink
Hide/Show authentication method in multi data source plugin based on …
Browse files Browse the repository at this point in the history
…configuration (#5916)

* [AuthType Config] Add EnabledAuthType configuration in yml file and pass value to dataSourceManagement root mount

Signed-off-by: Xinrui Bai <xinruiba@amazon.com>

* [AuthType Config] provide default auth types when types array is empty

Signed-off-by: Xinrui Bai <xinruiba@amazon.com>

* [AuthRegistry Onboard - DataSourceCreationForm] Integrate auth cofig with AuthRegistray and providing data source options from AuthRegistry

Signed-off-by: Xinrui Bai <xinruiba@amazon.com>

* [AuthRegistry Onboard] Support default selected auth type in datasource creation page

Signed-off-by: Xinrui Bai <xinruiba@amazon.com>

* [AuthRegistry Onboard] SDisable auth option selector when auth options no more than 1

Signed-off-by: Xinrui Bai <xinruiba@amazon.com>

* [AuthRegistry Onboard] clear credential attribute every time use select NoAuth option. Also update credentialField data type

Signed-off-by: Xinrui Bai <xinruiba@amazon.com>

* Update yml file to disable config

Signed-off-by: Xinrui Bai <xinruiba@amazon.com>

* Update change.md file

Signed-off-by: Xinrui Bai <xinruiba@amazon.com>

* [UT] Fix broken test cases

Signed-off-by: Xinrui Bai <xinruiba@amazon.com>

* [UT] Add more unit tests

Signed-off-by: Xinrui Bai <xinruiba@amazon.com>

* [UT] update unit test and handle scenario when no options enabled

Signed-off-by: Xinrui Bai <xinruiba@amazon.com>

* [UT] update description of unit test case

Signed-off-by: Xinrui Bai <xinruiba@amazon.com>

* [UT] update unit test cases to resolve comment

Signed-off-by: Xinrui Bai <xinruiba@amazon.com>

* [UT] Snapshot auth option super selector for unit test. Also upate the default message in datasorurce creation form ---> auth type section

Signed-off-by: Xinrui Bai <xinruiba@amazon.com>

---------

Signed-off-by: Xinrui Bai <xinruiba@amazon.com>
  • Loading branch information
xinruiba committed Feb 28, 2024
1 parent a7ab795 commit 20b6c5a
Show file tree
Hide file tree
Showing 19 changed files with 2,081 additions and 44 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Multiple Datasource] Concatenate data source name with index pattern name and change delimiter to double colon ([#5907](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5907))
- [Multiple Datasource] Refactor client and legacy client to use authentication registry ([#5881](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5881))
- [Multiple Datasource] Improved error handling for the search API when a null value is passed for the dataSourceId ([#5882](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5882))
- [Multiple Datasource] Hide/Show authentication method in multi data source plugin based on configuration ([#5916](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5916))

### 🐛 Bug Fixes

Expand Down
11 changes: 11 additions & 0 deletions config/opensearch_dashboards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,17 @@
# 'ff00::/8',
# ]

# Set enabled false to hide authentication method in OpenSearch Dashboards.
# If this setting is commented then all 3 options will be available in OpenSearch Dashboards.
# Default value will be considered to True.
#data_source.authTypes:
# NoAuthentication:
# enabled: true
# UsernamePassword:
# enabled: true
# AWSSigV4:
# enabled: true

# Set the value of this setting to false to hide the help menu link to the OpenSearch Dashboards user survey
# opensearchDashboards.survey.url: "https://survey.opensearch.org"

Expand Down
11 changes: 11 additions & 0 deletions src/plugins/data_source/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ export const configSchema = schema.object({
appender: fileAppenderSchema,
}),
endpointDeniedIPs: schema.maybe(schema.arrayOf(schema.string())),
authTypes: schema.object({
NoAuthentication: schema.object({
enabled: schema.boolean({ defaultValue: true }),
}),
UsernamePassword: schema.object({
enabled: schema.boolean({ defaultValue: true }),
}),
AWSSigV4: schema.object({
enabled: schema.boolean({ defaultValue: true }),
}),
}),
});

export type DataSourcePluginConfigType = TypeOf<typeof configSchema>;
6 changes: 6 additions & 0 deletions src/plugins/data_source/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export class DataSourcePlugin implements Plugin<DataSourcePluginSetup, DataSourc
return {
dataSourceEnabled: config.enabled,
hideLocalCluster: config.hideLocalCluster,
noAuthenticationTypeEnabled: config.authTypes.NoAuthentication.enabled,
usernamePasswordAuthEnabled: config.authTypes.UsernamePassword.enabled,
awsSigV4AuthEnabled: config.authTypes.AWSSigV4.enabled,
};
}

Expand All @@ -30,6 +33,9 @@ export class DataSourcePlugin implements Plugin<DataSourcePluginSetup, DataSourc
return {
dataSourceEnabled: config.enabled,
hideLocalCluster: config.hideLocalCluster,
noAuthenticationTypeEnabled: config.authTypes.NoAuthentication.enabled,
usernamePasswordAuthEnabled: config.authTypes.UsernamePassword.enabled,
awsSigV4AuthEnabled: config.authTypes.AWSSigV4.enabled,
};
}

Expand Down
6 changes: 6 additions & 0 deletions src/plugins/data_source/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@
export interface DataSourcePluginSetup {
dataSourceEnabled: boolean;
hideLocalCluster: boolean;
noAuthenticationTypeEnabled: boolean;
usernamePasswordAuthEnabled: boolean;
awsSigV4AuthEnabled: boolean;
}

export interface DataSourcePluginStart {
dataSourceEnabled: boolean;
hideLocalCluster: boolean;
noAuthenticationTypeEnabled: boolean;
usernamePasswordAuthEnabled: boolean;
awsSigV4AuthEnabled: boolean;
}
1 change: 1 addition & 0 deletions src/plugins/data_source/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const config: PluginConfigDescriptor<DataSourcePluginConfigType> = {
exposeToBrowser: {
enabled: true,
hideLocalCluster: true,
authTypes: true,
},
schema: configSchema,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import { EuiSuperSelectOption } from '@elastic/eui';

export interface AuthenticationMethod {
name: string;
credentialForm: React.JSX.Element;
credentialSourceOption: EuiSuperSelectOption<string>;
credentialForm?: React.JSX.Element;
crendentialFormField?: { [key: string]: string };
}

export type IAuthenticationMethodRegistery = Omit<
Expand Down
Loading

0 comments on commit 20b6c5a

Please sign in to comment.