Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add allowed_uri_sans_template option for vault_pki_secret_backend_role #1182

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions vault/resource_pki_secret_backend_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ func pkiSecretBackendRoleResource() *schema.Resource {
Type: schema.TypeString,
},
},
"allowed_uri_sans_template": {
Type: schema.TypeBool,
Required: false,
Optional: true,
Description: "Flag to indicate that `allowed_uri_sans` specifies a template expression (e.g. {{identity.entity.aliases.<mount accessor>.name}})",
Default: false,
},
"allowed_other_sans": {
Type: schema.TypeList,
Required: false,
Expand Down Expand Up @@ -362,6 +369,7 @@ func pkiSecretBackendRoleCreate(d *schema.ResourceData, meta interface{}) error
"enforce_hostnames": d.Get("enforce_hostnames"),
"allow_ip_sans": d.Get("allow_ip_sans"),
"allowed_uri_sans": d.Get("allowed_uri_sans"),
"allowed_uri_sans_template": d.Get("allowed_uri_sans_template"),
"allowed_other_sans": d.Get("allowed_other_sans"),
"server_flag": d.Get("server_flag"),
"client_flag": d.Get("client_flag"),
Expand Down Expand Up @@ -487,6 +495,7 @@ func pkiSecretBackendRoleRead(d *schema.ResourceData, meta interface{}) error {
d.Set("enforce_hostnames", secret.Data["enforce_hostnames"])
d.Set("allow_ip_sans", secret.Data["allow_ip_sans"])
d.Set("allowed_uri_sans", secret.Data["allowed_uri_sans"])
d.Set("allowed_uri_sans_template", secret.Data["allowed_uri_sans_template"])
d.Set("allowed_other_sans", secret.Data["allowed_other_sans"])
d.Set("server_flag", secret.Data["server_flag"])
d.Set("client_flag", secret.Data["client_flag"])
Expand Down Expand Up @@ -557,6 +566,7 @@ func pkiSecretBackendRoleUpdate(d *schema.ResourceData, meta interface{}) error
"enforce_hostnames": d.Get("enforce_hostnames"),
"allow_ip_sans": d.Get("allow_ip_sans"),
"allowed_uri_sans": d.Get("allowed_uri_sans"),
"allowed_uri_sans_template": d.Get("allowed_uri_sans_template"),
"allowed_other_sans": d.Get("allowed_other_sans"),
"server_flag": d.Get("server_flag"),
"client_flag": d.Get("client_flag"),
Expand Down
6 changes: 5 additions & 1 deletion vault/resource_pki_secret_backend_role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ func TestPkiSecretBackendRole_basic(t *testing.T) {
resource.TestCheckResourceAttr("vault_pki_secret_backend_role.test", "allow_any_name", "false"),
resource.TestCheckResourceAttr("vault_pki_secret_backend_role.test", "enforce_hostnames", "true"),
resource.TestCheckResourceAttr("vault_pki_secret_backend_role.test", "allow_ip_sans", "true"),
resource.TestCheckResourceAttr("vault_pki_secret_backend_role.test", "allowed_uri_sans.#", "2"),
resource.TestCheckResourceAttr("vault_pki_secret_backend_role.test", "allowed_uri_sans.0", "uri.test.domain"),
resource.TestCheckResourceAttr("vault_pki_secret_backend_role.test", "allowed_uri_sans.1", "spiffe://{{identity.entity.name}}"),
resource.TestCheckResourceAttr("vault_pki_secret_backend_role.test", "allowed_uri_sans_template", "true"),
resource.TestCheckResourceAttr("vault_pki_secret_backend_role.test", "allowed_other_sans.0", "1.2.3.4.5.5;UTF8:test"),
resource.TestCheckResourceAttr("vault_pki_secret_backend_role.test", "server_flag", "true"),
resource.TestCheckResourceAttr("vault_pki_secret_backend_role.test", "client_flag", "true"),
Expand Down Expand Up @@ -191,7 +194,8 @@ resource "vault_pki_secret_backend_role" "test" {
allow_any_name = false
enforce_hostnames = true
allow_ip_sans = true
allowed_uri_sans = ["uri.test.domain"]
allowed_uri_sans = ["uri.test.domain", "spiffe://{{identity.entity.name}}"]
allowed_uri_sans_template = true
allowed_other_sans = ["1.2.3.4.5.5;UTF8:test"]
server_flag = true
client_flag = true
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 @@ -64,6 +64,8 @@ The following arguments are supported:

* `allowed_uri_sans` - (Optional) Defines allowed URI SANs

* `allowed_uri_sans_template` - (Optional) Flag, if set, `allowed_uri_sans` can be specified using identity template expressions such as `{{identity.entity.aliases.<mount accessor>.name}}`.

* `allowed_other_sans` - (Optional) Defines allowed custom SANs

* `server_flag` - (Optional) Flag to specify certificates for server use
Expand Down