Skip to content

Commit

Permalink
[AuthType Config] Add EnabledAuthType configuration in yml file and p…
Browse files Browse the repository at this point in the history
…ass value to dataSourceManagement root mount

Signed-off-by: Xinrui Bai <[email protected]>
  • Loading branch information
xinruiba committed Feb 20, 2024
1 parent eff7cb5 commit 333987f
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 3 deletions.
9 changes: 9 additions & 0 deletions config/opensearch_dashboards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,15 @@
# 'ff00::/8',
# ]

# Full AuthType list: ['NoAuth', 'UsernamePasswordType', 'SigV4'].
# Add / Remove elements in this list to Enable / Diasble auth types.
# If this setting is commented then all options will be available.
data_source.enabledAuthTypes: [
'NoAuth',
'UsernamePasswordType',
'SigV4',
]

# 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
3 changes: 3 additions & 0 deletions src/plugins/data_source/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ export const configSchema = schema.object({
appender: fileAppenderSchema,
}),
endpointDeniedIPs: schema.maybe(schema.arrayOf(schema.string())),
enabledAuthTypes: schema.arrayOf(schema.string(), {
defaultValue: ['NoAuth', 'UsernamePasswordType', 'SigV4'],
}),
});

export type DataSourcePluginConfigType = TypeOf<typeof configSchema>;
2 changes: 2 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,7 @@ export class DataSourcePlugin implements Plugin<DataSourcePluginSetup, DataSourc
return {
dataSourceEnabled: config.enabled,
hideLocalCluster: config.hideLocalCluster,
enabledAuthTypes: config.enabledAuthTypes,
};
}

Expand All @@ -30,6 +31,7 @@ export class DataSourcePlugin implements Plugin<DataSourcePluginSetup, DataSourc
return {
dataSourceEnabled: config.enabled,
hideLocalCluster: config.hideLocalCluster,
enabledAuthTypes: config.enabledAuthTypes,
};
}

Expand Down
2 changes: 2 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,11 @@
export interface DataSourcePluginSetup {
dataSourceEnabled: boolean;
hideLocalCluster: boolean;
enabledAuthTypes: string[];
}

export interface DataSourcePluginStart {
dataSourceEnabled: boolean;
hideLocalCluster: boolean;
enabledAuthTypes: string[];
}
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,
enabledAuthTypes: true,
},
schema: configSchema,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import React from 'react';
import ReactDOM from 'react-dom';
import { Route, Router, Switch } from 'react-router-dom';
import { DataPublicPluginStart } from 'src/plugins/data/public';
import { DataSourcePluginSetup } from 'src/plugins/data_source/public';
import { ManagementAppMountParams } from '../../../management/public';

import { OpenSearchDashboardsContextProvider } from '../../../opensearch_dashboards_react/public';
Expand All @@ -24,7 +25,8 @@ export interface DataSourceManagementStartDependencies {

export async function mountManagementSection(
getStartServices: StartServicesAccessor<DataSourceManagementStartDependencies>,
params: ManagementAppMountParams
params: ManagementAppMountParams,
dataSource: DataSourcePluginSetup
) {
const [
{ chrome, application, savedObjects, uiSettings, notifications, overlays, http, docLinks },
Expand All @@ -40,6 +42,7 @@ export async function mountManagementSection(
http,
docLinks,
setBreadcrumbs: params.setBreadcrumbs,
enabledAuthTypes: dataSource.enabledAuthTypes,
};

ReactDOM.render(
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/data_source_management/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { DataSourcePluginSetup } from 'src/plugins/data_source/public';
import { CoreSetup, CoreStart, Plugin } from '../../../core/public';

import { PLUGIN_NAME } from '../common';
Expand All @@ -19,6 +20,7 @@ import {
export interface DataSourceManagementSetupDependencies {
management: ManagementSetup;
indexPatternManagement: IndexPatternManagementSetup;
dataSource: DataSourcePluginSetup;
}

export interface DataSourceManagementPluginSetup {
Expand All @@ -43,7 +45,7 @@ export class DataSourceManagementPlugin

public setup(
core: CoreSetup<DataSourceManagementPluginStart>,
{ management, indexPatternManagement }: DataSourceManagementSetupDependencies
{ management, indexPatternManagement, dataSource }: DataSourceManagementSetupDependencies
) {
const opensearchDashboardsSection = management.sections.section.opensearchDashboards;

Expand All @@ -65,7 +67,7 @@ export class DataSourceManagementPlugin
mount: async (params) => {
const { mountManagementSection } = await import('./management_app');

return mountManagementSection(core.getStartServices, params);
return mountManagementSection(core.getStartServices, params, dataSource);
},
});

Expand Down
1 change: 1 addition & 0 deletions src/plugins/data_source_management/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface DataSourceManagementContext {
http: HttpSetup;
docLinks: DocLinksStart;
setBreadcrumbs: ManagementAppMountParams['setBreadcrumbs'];
enabledAuthTypes: string[];
}

export interface DataSourceTableItem {
Expand Down

0 comments on commit 333987f

Please sign in to comment.