Skip to content

Commit

Permalink
Add cn_validations property to pki_secret_backend_role
Browse files Browse the repository at this point in the history
  • Loading branch information
bmhughes committed Aug 3, 2023
1 parent 67b1e2b commit e60abfa
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions internal/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ const (
FieldCredentialType = "credential_type"
FieldFilename = "filename"
FieldDefault = "default"
FieldCnValidations = "cn_validations"
/*
common environment variables
*/
Expand Down
13 changes: 10 additions & 3 deletions vault/resource_pki_secret_backend_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var pkiSecretListFields = []string{
consts.FieldAllowedSerialNumbers,
consts.FieldExtKeyUsage,
consts.FieldKeyUsage,
consts.FieldCnValidations,
}

var pkiSecretBooleanFields = []string{
Expand Down Expand Up @@ -414,9 +415,15 @@ func pkiSecretBackendRoleResource() *schema.Resource {
Required: false,
Optional: true,
Description: "Defines allowed Subject serial numbers.",
Elem: &schema.Schema{
Type: schema.TypeString,
},
Elem: &schema.Schema{Type: schema.TypeString},
},
consts.FieldCnValidations: {
Type: schema.TypeList,
Required: false,
Optional: true,
Computed: true,
Description: "Specify validations to run on the Common Name field of the certificate.",
Elem: &schema.Schema{Type: schema.TypeString},
},
consts.FieldAllowedUserIds: {
Type: schema.TypeList,
Expand Down
2 changes: 2 additions & 0 deletions vault/resource_pki_secret_backend_role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ resource "vault_pki_secret_backend_role" "test" {
basic_constraints_valid_for_non_ca = false
not_before_duration = "45m"
allowed_serial_numbers = ["*"]
cn_validations = ["email", "hostname"]
}
`, path, name, roleTTL, maxTTL, extraConfig)
}
Expand Down Expand Up @@ -425,6 +426,7 @@ resource "vault_pki_secret_backend_role" "test" {
basic_constraints_valid_for_non_ca = false
not_before_duration = "45m"
allowed_serial_numbers = ["*"]
cn_validations = ["disabled"]
}`, path, name, policyIdentifiers)
}

Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/pki_secret_backend_role.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ The following arguments are supported:

* `client_flag` - (Optional) Flag to specify certificates for client use

* `cn_validations` - (Optional) Validations to run on the Common Name field of the certificate, choices: `email`, `hostname`, `disabled`

* `code_signing_flag` - (Optional) Flag to specify certificates for code signing use

* `email_protection_flag` - (Optional) Flag to specify certificates for email protection use
Expand Down

0 comments on commit e60abfa

Please sign in to comment.