@@ -42,6 +42,13 @@ type DatabaseConfig struct {
42
42
43
43
PasswordPolicy string `json:"password_policy" structs:"password_policy" mapstructure:"password_policy"`
44
44
VerifyConnection bool `json:"verify_connection" structs:"verify_connection" mapstructure:"verify_connection"`
45
+
46
+ // SkipStaticRoleImportRotation is a flag to toggle wether or not a given
47
+ // static account's password should be rotated on creation of the static
48
+ // roles associated with this DB config. This can be overridden at the
49
+ // role-level by the role's skip_import_rotation field. The default is
50
+ // false. Enterprise only.
51
+ SkipStaticRoleImportRotation bool `json:"skip_static_role_import_rotation" structs:"skip_static_role_import_rotation" mapstructure:"skip_static_role_import_rotation"`
45
52
}
46
53
47
54
func (c * DatabaseConfig ) SupportsCredentialType (credentialType v5.CredentialType ) bool {
@@ -205,57 +212,60 @@ func (b *databaseBackend) reloadPlugin() framework.OperationFunc {
205
212
// pathConfigurePluginConnection returns a configured framework.Path setup to
206
213
// operate on plugins.
207
214
func pathConfigurePluginConnection (b * databaseBackend ) * framework.Path {
208
- return & framework.Path {
209
- Pattern : fmt .Sprintf ("config/%s" , framework .GenericNameRegex ("name" )),
210
-
211
- DisplayAttrs : & framework.DisplayAttributes {
212
- OperationPrefix : operationPrefixDatabase ,
215
+ fields := map [string ]* framework.FieldSchema {
216
+ "name" : {
217
+ Type : framework .TypeString ,
218
+ Description : "Name of this database connection" ,
213
219
},
214
220
215
- Fields : map [string ]* framework.FieldSchema {
216
- "name" : {
217
- Type : framework .TypeString ,
218
- Description : "Name of this database connection" ,
219
- },
220
-
221
- "plugin_name" : {
222
- Type : framework .TypeString ,
223
- Description : `The name of a builtin or previously registered
221
+ "plugin_name" : {
222
+ Type : framework .TypeString ,
223
+ Description : `The name of a builtin or previously registered
224
224
plugin known to vault. This endpoint will create an instance of
225
225
that plugin type.` ,
226
- },
226
+ },
227
227
228
- "plugin_version" : {
229
- Type : framework .TypeString ,
230
- Description : `The version of the plugin to use.` ,
231
- },
228
+ "plugin_version" : {
229
+ Type : framework .TypeString ,
230
+ Description : `The version of the plugin to use.` ,
231
+ },
232
232
233
- "verify_connection" : {
234
- Type : framework .TypeBool ,
235
- Default : true ,
236
- Description : `If true, the connection details are verified by
233
+ "verify_connection" : {
234
+ Type : framework .TypeBool ,
235
+ Default : true ,
236
+ Description : `If true, the connection details are verified by
237
237
actually connecting to the database. Defaults to true.` ,
238
- },
238
+ },
239
239
240
- "allowed_roles" : {
241
- Type : framework .TypeCommaStringSlice ,
242
- Description : `Comma separated string or array of the role names
240
+ "allowed_roles" : {
241
+ Type : framework .TypeCommaStringSlice ,
242
+ Description : `Comma separated string or array of the role names
243
243
allowed to get creds from this database connection. If empty no
244
244
roles are allowed. If "*" all roles are allowed.` ,
245
- },
245
+ },
246
246
247
- "root_rotation_statements" : {
248
- Type : framework .TypeStringSlice ,
249
- Description : `Specifies the database statements to be executed
247
+ "root_rotation_statements" : {
248
+ Type : framework .TypeStringSlice ,
249
+ Description : `Specifies the database statements to be executed
250
250
to rotate the root user's credentials. See the plugin's API
251
251
page for more information on support and formatting for this
252
252
parameter.` ,
253
- },
254
- "password_policy" : {
255
- Type : framework .TypeString ,
256
- Description : `Password policy to use when generating passwords.` ,
257
- },
258
253
},
254
+ "password_policy" : {
255
+ Type : framework .TypeString ,
256
+ Description : `Password policy to use when generating passwords.` ,
257
+ },
258
+ }
259
+ AddConnectionFieldsEnt (fields )
260
+
261
+ return & framework.Path {
262
+ Pattern : fmt .Sprintf ("config/%s" , framework .GenericNameRegex ("name" )),
263
+
264
+ DisplayAttrs : & framework.DisplayAttributes {
265
+ OperationPrefix : operationPrefixDatabase ,
266
+ },
267
+
268
+ Fields : fields ,
259
269
260
270
ExistenceCheck : b .connectionExistenceCheck (),
261
271
@@ -480,6 +490,10 @@ func (b *databaseBackend) connectionWriteHandler() framework.OperationFunc {
480
490
config .PasswordPolicy = passwordPolicyRaw .(string )
481
491
}
482
492
493
+ if skipImportRotationRaw , ok := data .GetOk ("skip_static_role_import_rotation" ); ok {
494
+ config .SkipStaticRoleImportRotation = skipImportRotationRaw .(bool )
495
+ }
496
+
483
497
// Remove these entries from the data before we store it keyed under
484
498
// ConnectionDetails.
485
499
delete (data .Raw , "name" )
@@ -489,6 +503,7 @@ func (b *databaseBackend) connectionWriteHandler() framework.OperationFunc {
489
503
delete (data .Raw , "verify_connection" )
490
504
delete (data .Raw , "root_rotation_statements" )
491
505
delete (data .Raw , "password_policy" )
506
+ delete (data .Raw , "skip_static_role_import_rotation" )
492
507
493
508
id , err := uuid .GenerateUUID ()
494
509
if err != nil {
0 commit comments