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

feat: Ability to pass in a scope for certificate authentication #154

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
11 changes: 11 additions & 0 deletions venafi/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const (

utilityName = "HashiCorp Terraform"
defaultClientID = "hashicorp-terraform-by-venafi"
defaultScope = "configuration:manage,delete;certificate:manage"
defaultSkipRetirement = false

// Environment variables for Provider attributes
Expand All @@ -50,6 +51,7 @@ const (
envVenafiP12Certificate = "VENAFI_P12_CERTIFICATE"
envVenafiP12Password = "VENAFI_P12_PASSWORD"
envVenafiClientID = "VENAFI_CLIENT_ID"
envVenafiScope = "VENAFI_SCOPE"
envVenafiSkipRetirement = "VENAFI_SKIP_RETIREMENT"

// Attributes of the provider
Expand All @@ -66,6 +68,7 @@ const (
providerExternalJWT = "external_jwt"
providerTrustBundle = "trust_bundle"
providerClientID = "client_id"
providerScope = "scope"
providerSkipRetirement = "skip_retirement"

// Resource names
Expand Down Expand Up @@ -180,6 +183,12 @@ Example:
DefaultFunc: schema.EnvDefaultFunc(envVenafiClientID, defaultClientID),
Description: "application that will be using the token",
},
providerScope: {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc(envVenafiScope, defaultScope),
Description: "Set application scopes less than or equal to that of the application itself",
},
providerSkipRetirement: {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -222,6 +231,7 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}
p12Certificate := d.Get(providerP12Cert).(string)
p12Password := d.Get(providerP12Password).(string)
clientID := d.Get(providerClientID).(string)
scope := d.Get(providerScope).(string)
skipRetirement := d.Get(providerSkipRetirement).(bool)
tokenURL := d.Get(providerTokenURL).(string)
externalJWT := d.Get(providerExternalJWT).(string)
Expand Down Expand Up @@ -259,6 +269,7 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}
UserAgent: &userAgent,
Credentials: &endpoint.Authentication{
ClientId: clientID,
Scope: scope,
},
}

Expand Down