mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-11-04 12:37:59 +00:00 
			
		
		
		
	* Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Updating the license from MPL to Business Source License. Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at https://hashi.co/bsl-blog, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl. * add missing license headers * Update copyright file headers to BUS-1.1 * Fix test that expected exact offset on hcl file --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com> Co-authored-by: Sarah Thompson <sthompson@hashicorp.com> Co-authored-by: Brian Kassouf <bkassouf@hashicorp.com>
		
			
				
	
	
		
			231 lines
		
	
	
		
			9.0 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			231 lines
		
	
	
		
			9.0 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
/**
 | 
						|
 * Copyright (c) HashiCorp, Inc.
 | 
						|
 * SPDX-License-Identifier: BUSL-1.1
 | 
						|
 */
 | 
						|
 | 
						|
export const AVAILABLE_PLUGIN_TYPES = [
 | 
						|
  {
 | 
						|
    value: 'elasticsearch-database-plugin',
 | 
						|
    displayName: 'Elasticsearch',
 | 
						|
    fields: [
 | 
						|
      { attr: 'plugin_name' },
 | 
						|
      { attr: 'name' },
 | 
						|
      { attr: 'verify_connection', show: false },
 | 
						|
      { 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' },
 | 
						|
    ],
 | 
						|
  },
 | 
						|
  {
 | 
						|
    value: 'mongodb-database-plugin',
 | 
						|
    displayName: 'MongoDB',
 | 
						|
    fields: [
 | 
						|
      { attr: 'plugin_name' },
 | 
						|
      { attr: 'name' },
 | 
						|
      { attr: 'connection_url' },
 | 
						|
      { attr: 'verify_connection', show: false },
 | 
						|
      { 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' },
 | 
						|
      { attr: 'verify_connection', show: false },
 | 
						|
      { 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' },
 | 
						|
    ],
 | 
						|
  },
 | 
						|
  {
 | 
						|
    value: 'mysql-aurora-database-plugin',
 | 
						|
    displayName: 'MySQL (Aurora)',
 | 
						|
    fields: [
 | 
						|
      { attr: 'plugin_name' },
 | 
						|
      { attr: 'name' },
 | 
						|
      { attr: 'verify_connection', show: false },
 | 
						|
      { 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' },
 | 
						|
    ],
 | 
						|
  },
 | 
						|
  {
 | 
						|
    value: 'mysql-legacy-database-plugin',
 | 
						|
    displayName: 'MySQL (Legacy)',
 | 
						|
    fields: [
 | 
						|
      { attr: 'plugin_name' },
 | 
						|
      { attr: 'name' },
 | 
						|
      { attr: 'verify_connection', show: false },
 | 
						|
      { 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' },
 | 
						|
    ],
 | 
						|
  },
 | 
						|
  {
 | 
						|
    value: 'mysql-database-plugin',
 | 
						|
    displayName: 'MySQL/MariaDB',
 | 
						|
    fields: [
 | 
						|
      { attr: 'plugin_name' },
 | 
						|
      { attr: 'name' },
 | 
						|
      { attr: 'verify_connection', show: false },
 | 
						|
      { 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' },
 | 
						|
    ],
 | 
						|
  },
 | 
						|
  {
 | 
						|
    value: 'mysql-rds-database-plugin',
 | 
						|
    displayName: 'MySQL (RDS)',
 | 
						|
    fields: [
 | 
						|
      { attr: 'plugin_name' },
 | 
						|
      { attr: 'name' },
 | 
						|
      { attr: 'verify_connection', show: false },
 | 
						|
      { 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' },
 | 
						|
    ],
 | 
						|
  },
 | 
						|
  {
 | 
						|
    value: 'vault-plugin-database-oracle',
 | 
						|
    displayName: 'Oracle',
 | 
						|
    fields: [
 | 
						|
      { attr: 'plugin_name' },
 | 
						|
      { attr: 'name' },
 | 
						|
      { attr: 'verify_connection', show: false },
 | 
						|
      { 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' },
 | 
						|
    ],
 | 
						|
  },
 | 
						|
  {
 | 
						|
    value: 'postgresql-database-plugin',
 | 
						|
    displayName: 'PostgreSQL',
 | 
						|
    fields: [
 | 
						|
      { attr: 'plugin_name' },
 | 
						|
      { attr: 'name' },
 | 
						|
      { attr: 'verify_connection', show: false },
 | 
						|
      { 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'],
 | 
						|
  dynamic: ['default_ttl', 'max_ttl'],
 | 
						|
};
 | 
						|
 | 
						|
export const STATEMENT_FIELDS = {
 | 
						|
  static: {
 | 
						|
    default: ['rotation_statements'],
 | 
						|
    'elasticsearch-database-plugin': [],
 | 
						|
    'mongodb-database-plugin': [],
 | 
						|
    'mssql-database-plugin': [],
 | 
						|
    'mysql-database-plugin': [],
 | 
						|
    'mysql-aurora-database-plugin': [],
 | 
						|
    'mysql-legacy-database-plugin': [],
 | 
						|
    'mysql-rds-database-plugin': [],
 | 
						|
    'vault-plugin-database-oracle': [],
 | 
						|
    'postgresql-database-plugin': [],
 | 
						|
  },
 | 
						|
  dynamic: {
 | 
						|
    default: ['creation_statements', 'revocation_statements', 'rollback_statements', 'renew_statements'],
 | 
						|
    'elasticsearch-database-plugin': ['creation_statement'],
 | 
						|
    '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'],
 | 
						|
    'mysql-rds-database-plugin': ['creation_statements', 'revocation_statements'],
 | 
						|
    'vault-plugin-database-oracle': ['creation_statements', 'revocation_statements'],
 | 
						|
    'postgresql-database-plugin': [
 | 
						|
      'creation_statements',
 | 
						|
      'revocation_statements',
 | 
						|
      'rollback_statements',
 | 
						|
      'renew_statements',
 | 
						|
    ],
 | 
						|
  },
 | 
						|
};
 | 
						|
 | 
						|
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];
 | 
						|
}
 |