Venafi / terraform-provider-venafi

HashiCorp Terraform provider that uses Venafi to streamline machine identity (certificate and key) acquisition.
https://www.terraform.io/docs/providers/venafi/
Mozilla Public License 2.0
17 stars 20 forks source link

Add "venafi_credential" resource for automating TPP token request/refresh #25

Closed tr1ck3r closed 8 months ago

tr1ck3r commented 4 years ago

BUSINESS PROBLEM Allow the Venafi Terraform Provider to self-manage its access to Trust Protection Platform via token authentication where initialization begins with either username/password, client certificate, or refresh token.

PROPOSED SOLUTION venafi_credential Resource

Arguments (input):

Attributes (output):

On terraform apply:

  1. if expiration is set
    1. if expiration > now - refresh_window and
      1. refresh_token is set, then get new token(s) by calling POST /vedauth/authorize/token
      2. username & password are set, then get new token(s) by calling POST /vedauth/authorize
      3. p12_keycert & p12_password are set, then get new token(s) by calling POST /vedauth/authorize/certificate
    2. else do nothing
  2. else (expiration is not set) and
    1. username & password are set, then get new token(s) by calling POST /vedauth/authorize
    2. p12_keycert & p12_password are set, then get new token(s) by calling POST /vedauth/authorize/certificate
    3. refresh_token is set, then get new token(s) by calling POST /vedauth/authorize/token

On terraform destroy:

  1. if access_token is set, revoke token by calling GET /vedauth/revoke/token

CURRENT ALTERNATIVES Use VCert CLI getcred or direct REST API /vedauth calls to get an access_token which can then be used directly by the venafi_certificate resource (work-in-progress #22).

tr1ck3r commented 1 year ago

This was written several years back and some things have changed. The goal now should always be to get an access/refresh token pair and store them in the Terraform state so they can be used for certificate and policy API operations. If provided, neither the username, password, p12_keycert nor p12_password should ever be persisted to the Terraform state because their compromise poses a greater risk (potentially significantly greater) than compromise of the access_token and/or refresh_token.

When an access_token reaches the expiration window and there is a refresh_token stored, terraform apply should result in the refresh token being used to obtain a new token pair... no other option would be available because username, password, p12_keycert, and p12_password will not be available (not stored in the state).

brental commented 8 months ago

@luispresuelVenafi Now that there is venafi-token provider and a venafi-token_credential resource is this still required? It sounds like that resource addresses this issue so this might be able to be closed.

luispresuelVenafi commented 8 months ago

@brental I agree, this has been adressed in Terraform Token Provider. I'll close this issue. Thank you for the reminder on closing this one :smile: