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

[Backport 2.x] Hide/Show authentication method in multi data source plugin based on configuration #5976

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading