2023-03-15 16:00:52 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*/
|
|
|
|
|
2021-10-11 23:42:11 +00:00
|
|
|
export const AVAILABLE_PLUGIN_TYPES = [
|
2021-10-29 16:58:56 +00:00
|
|
|
{
|
|
|
|
value: 'elasticsearch-database-plugin',
|
|
|
|
displayName: 'Elasticsearch',
|
|
|
|
fields: [
|
|
|
|
{ attr: 'plugin_name' },
|
|
|
|
{ attr: 'name' },
|
2021-11-16 18:56:42 +00:00
|
|
|
{ attr: 'verify_connection', show: false },
|
2021-10-29 16:58:56 +00:00
|
|
|
{ attr: 'password_policy' },
|
|
|
|
{ attr: 'url', group: 'pluginConfig' },
|
|
|
|
{ attr: 'username', group: 'pluginConfig', show: false },
|
|
|
|
{ attr: 'password', group: 'pluginConfig', show: false },
|
|
|
|
{ attr: 'ca_cert', group: 'pluginConfig' },
|
|
|
|
{ attr: 'ca_path', group: 'pluginConfig' },
|
|
|
|
{ attr: 'client_cert', group: 'pluginConfig' },
|
|
|
|
{ attr: 'client_key', group: 'pluginConfig' },
|
|
|
|
{ attr: 'tls_server_name', group: 'pluginConfig' },
|
|
|
|
{ attr: 'insecure', group: 'pluginConfig' },
|
|
|
|
{ attr: 'username_template', group: 'pluginConfig' },
|
|
|
|
],
|
|
|
|
},
|
2021-10-11 23:42:11 +00:00
|
|
|
{
|
|
|
|
value: 'mongodb-database-plugin',
|
|
|
|
displayName: 'MongoDB',
|
|
|
|
fields: [
|
|
|
|
{ attr: 'plugin_name' },
|
|
|
|
{ attr: 'name' },
|
|
|
|
{ attr: 'connection_url' },
|
2021-11-16 18:56:42 +00:00
|
|
|
{ attr: 'verify_connection', show: false },
|
2021-10-11 23:42:11 +00:00
|
|
|
{ attr: 'password_policy' },
|
|
|
|
{ attr: 'username', group: 'pluginConfig', show: false },
|
|
|
|
{ attr: 'password', group: 'pluginConfig', show: false },
|
|
|
|
{ attr: 'write_concern', group: 'pluginConfig' },
|
|
|
|
{ attr: 'username_template', group: 'pluginConfig' },
|
|
|
|
{ attr: 'tls', group: 'pluginConfig', subgroup: 'TLS options' },
|
|
|
|
{ attr: 'tls_ca', group: 'pluginConfig', subgroup: 'TLS options' },
|
|
|
|
{ attr: 'root_rotation_statements', group: 'statements' },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 'mssql-database-plugin',
|
|
|
|
displayName: 'MSSQL',
|
|
|
|
fields: [
|
|
|
|
{ attr: 'plugin_name' },
|
|
|
|
{ attr: 'name' },
|
|
|
|
{ attr: 'connection_url' },
|
2021-11-16 18:56:42 +00:00
|
|
|
{ attr: 'verify_connection', show: false },
|
2021-10-11 23:42:11 +00:00
|
|
|
{ attr: 'password_policy' },
|
|
|
|
{ attr: 'username', group: 'pluginConfig', show: false },
|
|
|
|
{ attr: 'password', group: 'pluginConfig', show: false },
|
|
|
|
{ attr: 'username_template', group: 'pluginConfig' },
|
|
|
|
{ attr: 'max_open_connections', group: 'pluginConfig' },
|
|
|
|
{ attr: 'max_idle_connections', group: 'pluginConfig' },
|
|
|
|
{ attr: 'max_connection_lifetime', group: 'pluginConfig' },
|
|
|
|
{ attr: 'root_rotation_statements', group: 'statements' },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2021-10-29 16:58:56 +00:00
|
|
|
value: 'mysql-aurora-database-plugin',
|
|
|
|
displayName: 'MySQL (Aurora)',
|
2021-10-11 23:42:11 +00:00
|
|
|
fields: [
|
|
|
|
{ attr: 'plugin_name' },
|
|
|
|
{ attr: 'name' },
|
2021-11-16 18:56:42 +00:00
|
|
|
{ attr: 'verify_connection', show: false },
|
2021-10-11 23:42:11 +00:00
|
|
|
{ attr: 'password_policy' },
|
|
|
|
{ attr: 'connection_url', group: 'pluginConfig' },
|
|
|
|
{ attr: 'username', group: 'pluginConfig', show: false },
|
|
|
|
{ attr: 'password', group: 'pluginConfig', show: false },
|
|
|
|
{ attr: 'max_open_connections', group: 'pluginConfig' },
|
|
|
|
{ attr: 'max_idle_connections', group: 'pluginConfig' },
|
|
|
|
{ attr: 'max_connection_lifetime', group: 'pluginConfig' },
|
|
|
|
{ attr: 'username_template', group: 'pluginConfig' },
|
|
|
|
{ attr: 'tls', group: 'pluginConfig', subgroup: 'TLS options' },
|
|
|
|
{ attr: 'tls_ca', group: 'pluginConfig', subgroup: 'TLS options' },
|
|
|
|
{ attr: 'root_rotation_statements', group: 'statements' },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2021-10-29 16:58:56 +00:00
|
|
|
value: 'mysql-legacy-database-plugin',
|
|
|
|
displayName: 'MySQL (Legacy)',
|
2021-10-11 23:42:11 +00:00
|
|
|
fields: [
|
|
|
|
{ attr: 'plugin_name' },
|
|
|
|
{ attr: 'name' },
|
2021-11-16 18:56:42 +00:00
|
|
|
{ attr: 'verify_connection', show: false },
|
2021-10-11 23:42:11 +00:00
|
|
|
{ attr: 'password_policy' },
|
|
|
|
{ attr: 'connection_url', group: 'pluginConfig' },
|
|
|
|
{ attr: 'username', group: 'pluginConfig', show: false },
|
|
|
|
{ attr: 'password', group: 'pluginConfig', show: false },
|
|
|
|
{ attr: 'max_open_connections', group: 'pluginConfig' },
|
|
|
|
{ attr: 'max_idle_connections', group: 'pluginConfig' },
|
|
|
|
{ attr: 'max_connection_lifetime', group: 'pluginConfig' },
|
|
|
|
{ attr: 'username_template', group: 'pluginConfig' },
|
|
|
|
{ attr: 'tls', group: 'pluginConfig', subgroup: 'TLS options' },
|
|
|
|
{ attr: 'tls_ca', group: 'pluginConfig', subgroup: 'TLS options' },
|
|
|
|
{ attr: 'root_rotation_statements', group: 'statements' },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2021-10-29 16:58:56 +00:00
|
|
|
value: 'mysql-database-plugin',
|
|
|
|
displayName: 'MySQL/MariaDB',
|
2021-10-11 23:42:11 +00:00
|
|
|
fields: [
|
|
|
|
{ attr: 'plugin_name' },
|
|
|
|
{ attr: 'name' },
|
2021-11-16 18:56:42 +00:00
|
|
|
{ attr: 'verify_connection', show: false },
|
2021-10-11 23:42:11 +00:00
|
|
|
{ attr: 'password_policy' },
|
|
|
|
{ attr: 'connection_url', group: 'pluginConfig' },
|
|
|
|
{ attr: 'username', group: 'pluginConfig', show: false },
|
|
|
|
{ attr: 'password', group: 'pluginConfig', show: false },
|
|
|
|
{ attr: 'max_open_connections', group: 'pluginConfig' },
|
|
|
|
{ attr: 'max_idle_connections', group: 'pluginConfig' },
|
|
|
|
{ attr: 'max_connection_lifetime', group: 'pluginConfig' },
|
|
|
|
{ attr: 'username_template', group: 'pluginConfig' },
|
|
|
|
{ attr: 'tls', group: 'pluginConfig', subgroup: 'TLS options' },
|
|
|
|
{ attr: 'tls_ca', group: 'pluginConfig', subgroup: 'TLS options' },
|
|
|
|
{ attr: 'root_rotation_statements', group: 'statements' },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2021-10-29 16:58:56 +00:00
|
|
|
value: 'mysql-rds-database-plugin',
|
|
|
|
displayName: 'MySQL (RDS)',
|
2021-10-11 23:42:11 +00:00
|
|
|
fields: [
|
|
|
|
{ attr: 'plugin_name' },
|
|
|
|
{ attr: 'name' },
|
2021-11-16 18:56:42 +00:00
|
|
|
{ attr: 'verify_connection', show: false },
|
2021-10-11 23:42:11 +00:00
|
|
|
{ attr: 'password_policy' },
|
|
|
|
{ attr: 'connection_url', group: 'pluginConfig' },
|
|
|
|
{ attr: 'username', group: 'pluginConfig', show: false },
|
|
|
|
{ attr: 'password', group: 'pluginConfig', show: false },
|
|
|
|
{ attr: 'max_open_connections', group: 'pluginConfig' },
|
|
|
|
{ attr: 'max_idle_connections', group: 'pluginConfig' },
|
|
|
|
{ attr: 'max_connection_lifetime', group: 'pluginConfig' },
|
|
|
|
{ attr: 'username_template', group: 'pluginConfig' },
|
|
|
|
{ attr: 'tls', group: 'pluginConfig', subgroup: 'TLS options' },
|
|
|
|
{ attr: 'tls_ca', group: 'pluginConfig', subgroup: 'TLS options' },
|
|
|
|
{ attr: 'root_rotation_statements', group: 'statements' },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2021-11-10 22:20:36 +00:00
|
|
|
value: 'vault-plugin-database-oracle',
|
2021-10-29 16:58:56 +00:00
|
|
|
displayName: 'Oracle',
|
2021-10-11 23:42:11 +00:00
|
|
|
fields: [
|
|
|
|
{ attr: 'plugin_name' },
|
|
|
|
{ attr: 'name' },
|
2021-11-16 18:56:42 +00:00
|
|
|
{ attr: 'verify_connection', show: false },
|
2021-10-11 23:42:11 +00:00
|
|
|
{ attr: 'password_policy' },
|
2021-10-29 16:58:56 +00:00
|
|
|
{ attr: 'connection_url', group: 'pluginConfig' },
|
2021-10-11 23:42:11 +00:00
|
|
|
{ attr: 'username', group: 'pluginConfig', show: false },
|
|
|
|
{ attr: 'password', group: 'pluginConfig', show: false },
|
2021-10-29 16:58:56 +00:00
|
|
|
{ attr: 'max_open_connections', group: 'pluginConfig' },
|
|
|
|
{ attr: 'max_idle_connections', group: 'pluginConfig' },
|
|
|
|
{ attr: 'max_connection_lifetime', group: 'pluginConfig' },
|
2021-10-11 23:42:11 +00:00
|
|
|
{ attr: 'username_template', group: 'pluginConfig' },
|
2021-10-29 16:58:56 +00:00
|
|
|
{ attr: 'root_rotation_statements', group: 'statements' },
|
2021-10-11 23:42:11 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2021-10-29 16:58:56 +00:00
|
|
|
value: 'postgresql-database-plugin',
|
|
|
|
displayName: 'PostgreSQL',
|
2021-10-11 23:42:11 +00:00
|
|
|
fields: [
|
|
|
|
{ attr: 'plugin_name' },
|
|
|
|
{ attr: 'name' },
|
2021-11-16 18:56:42 +00:00
|
|
|
{ attr: 'verify_connection', show: false },
|
2021-10-11 23:42:11 +00:00
|
|
|
{ attr: 'password_policy' },
|
|
|
|
{ attr: 'connection_url', group: 'pluginConfig' },
|
|
|
|
{ attr: 'username', group: 'pluginConfig', show: false },
|
|
|
|
{ attr: 'password', group: 'pluginConfig', show: false },
|
|
|
|
{ attr: 'max_open_connections', group: 'pluginConfig' },
|
|
|
|
{ attr: 'max_idle_connections', group: 'pluginConfig' },
|
|
|
|
{ attr: 'max_connection_lifetime', group: 'pluginConfig' },
|
|
|
|
{ attr: 'username_template', group: 'pluginConfig' },
|
|
|
|
{ attr: 'root_rotation_statements', group: 'statements' },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
export const ROLE_FIELDS = {
|
|
|
|
static: ['username', 'rotation_period'],
|
2022-02-23 16:00:20 +00:00
|
|
|
dynamic: ['default_ttl', 'max_ttl'],
|
2021-10-11 23:42:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const STATEMENT_FIELDS = {
|
|
|
|
static: {
|
|
|
|
default: ['rotation_statements'],
|
2021-10-29 16:58:56 +00:00
|
|
|
'elasticsearch-database-plugin': [],
|
2021-10-11 23:42:11 +00:00
|
|
|
'mongodb-database-plugin': [],
|
|
|
|
'mssql-database-plugin': [],
|
|
|
|
'mysql-database-plugin': [],
|
|
|
|
'mysql-aurora-database-plugin': [],
|
|
|
|
'mysql-legacy-database-plugin': [],
|
2021-10-29 16:58:56 +00:00
|
|
|
'mysql-rds-database-plugin': [],
|
2021-11-10 22:20:36 +00:00
|
|
|
'vault-plugin-database-oracle': [],
|
2021-10-29 16:58:56 +00:00
|
|
|
'postgresql-database-plugin': [],
|
2021-10-11 23:42:11 +00:00
|
|
|
},
|
|
|
|
dynamic: {
|
|
|
|
default: ['creation_statements', 'revocation_statements', 'rollback_statements', 'renew_statements'],
|
2021-10-29 16:58:56 +00:00
|
|
|
'elasticsearch-database-plugin': ['creation_statement'],
|
2021-10-11 23:42:11 +00:00
|
|
|
'mongodb-database-plugin': ['creation_statement', 'revocation_statement'],
|
|
|
|
'mssql-database-plugin': ['creation_statements', 'revocation_statements'],
|
|
|
|
'mysql-database-plugin': ['creation_statements', 'revocation_statements'],
|
|
|
|
'mysql-aurora-database-plugin': ['creation_statements', 'revocation_statements'],
|
|
|
|
'mysql-legacy-database-plugin': ['creation_statements', 'revocation_statements'],
|
2021-10-29 16:58:56 +00:00
|
|
|
'mysql-rds-database-plugin': ['creation_statements', 'revocation_statements'],
|
2021-11-10 22:20:36 +00:00
|
|
|
'vault-plugin-database-oracle': ['creation_statements', 'revocation_statements'],
|
2021-10-29 16:58:56 +00:00
|
|
|
'postgresql-database-plugin': [
|
|
|
|
'creation_statements',
|
|
|
|
'revocation_statements',
|
|
|
|
'rollback_statements',
|
|
|
|
'renew_statements',
|
|
|
|
],
|
2021-10-11 23:42:11 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export function getStatementFields(type, plugin) {
|
|
|
|
if (!type) return null;
|
|
|
|
let dbValidFields = STATEMENT_FIELDS[type].default;
|
|
|
|
if (STATEMENT_FIELDS[type][plugin]) {
|
|
|
|
dbValidFields = STATEMENT_FIELDS[type][plugin];
|
|
|
|
}
|
|
|
|
return dbValidFields;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getRoleFields(type) {
|
|
|
|
if (!type) return null;
|
|
|
|
return ROLE_FIELDS[type];
|
|
|
|
}
|