[Proposal] Refactoring data source plugin to support add-on authentication method with plug-in module #5692
Labels
dashboards anywhere
label for dashboards anywhere
enhancement
New feature or request
multiple datasource
multiple datasource project
v2.13.0
Overview
The purpose of this design document is to outline the approach and specifications for adding an interface in multi data source plugin that allows the seamless integration of authentication method through plugin. This enhancement aims to provide a standardized and user-friendly mechanism for extending the authentication in multi data source plugin.
User stories
Currently in multi data source, we support these auth types
In AWS SigV4, we only support user based access policies where IAM user comes with IAM access key & secret key that can be used to sign the request.
As a user I want additional support for role based authentication for my OpenSearch domain. Data source plugin already supports AWS SigV4 for authenticating request. I want to add required UI fields and generate access toke, secret key and session token in external plugin and pass them to data source plugin to authenticating request. As a user I want interface in data source plugin to register my own authentication method.
Requirement
Functional
Non-functional
Architecture Proposal
To meet the outlined requirements, we will introduce a new interface in data source and data source management plugins. These plugins are OpenSearch Dashboards core plugins. This will extend the current multi data source plugin’s capabilities, enabling it to be able to support multiple authentication method.
Components
Location of Datasource Codebase
The proposed architecture will comprise a set of back-end functionalities sitting within the server folder of the core data_source plugin and a set of front-end functionalities sitting within the public folder of the core data_source_management plugin. The interfaces to register authentication method into the registry and get authentication registry will be made accessible via the setup and start hook in plugin.ts. Any core components or plugins that list dataSource and dataSourceManagement as a dependency will have access to these interfaces. During plugin setup stage, it initiates registry to store authentication methods and provide function to register authentication method. When the plugin starts, it returns function to retrieve the authentication registry. During setup stage of both dataSource
and dataSourceManagement plugins, we need authentication registry to pass to async handler. We are using core. getStartService which allows plugins to get access to APIs available in start inside async handlers. Promise will not resolve until Core and plugin dependencies have completed start. This should only be used inside handlers registered during setup that will only be executed after start lifecycle.
Interfaces and Classes
Authentication method registry:
We will maintain two registry to hold authentication method information. One in server which holds the credential provider and one in public which holds the UI elements to mount on web page.
data_source plugin
1] DataSourceCredentialsProvider: Instance of DataSourceCredentialsProvider will be responsible for providing credentials to sign the request either with Basic auth or AWS SigV4 which are only supported request signing mechanism.
2] DataSourceAttributes: Right now we only support UsernamePasswordTypedContent, SigV4Content and undefined as type for auth credentials. We will need to support more generic type along with existing types to allow credentials in the form of key:value pair. Also we will add new field name: AuthType | string in DataSourceAttributes to identify the authentication method. To ensure compatibility with existing auth methods, we will make default value same as type for Basic and SigV4 authentication method. auth.type in DataSourceAttributes will have only values of AuthType. auth.type will tell data_source plugin, using which method request needs to be signed. Right now we only have two ways: Basic authentication and AWS SigV4 authentication to sign the request.
3] SigV4Content: This proposed architecture will also extend the ability of multi data source to support authentication using IAM role. Current architecture only supports authenticating as IAM user. As IAM role session requires temporary security credentials through assuming role, we will need additional field for sessionToken in SigV4Content interface.
4] Client: Based on authentication method type, client will look for authentication method in auth registry to get credentials. Client pooling and caching will be handled by data_source core plugin.
data_source_management plugin
1] AuthenticationMethod: To support custom authentication method from plugin, browser side we need option for selection and then form to enter fields which would be credentials or fields which required to retrieve credentials in case role based authentication. Plugins or any component which will be using these API, need to take care of validations as well for those fields. Core data_source_management plugin will be in charge to mount those UI component in parent form and calls sever side API to test connection and save the data source.
Tracking issue
#5838
Follow up Issue
#5694
The text was updated successfully, but these errors were encountered: