Mastercard / terraform-provider-restapi

A terraform provider to manage objects in a RESTful API
Other
785 stars 215 forks source link

Fix for endpoint_params #202 #231

Open harshavmb opened 11 months ago

harshavmb commented 11 months ago

As of now endpoint_params part of oauth_client_credentials block isn't functional. Below issues were/are flagged::

This PR is a proposal to get it working with the limitations in mind. I disabled the map validation for complex values like this one, there is no support & it's discussed here. I changed the var type of endpoint_params from map of a list of strings to map of strings as the go oauth2 SDK expects in the below format::

EndpointParams: url.Values {
    "audience": {"audience1"}
 },

To me this is a weird format it's neither list nor string but interface{}. Anyways, with this format being expected, list isn't accepted at all. Hence, I chose the json. It's partly inspired from azurerm-provider.

An example configuration would look like below::

provider "restapi" {
  uri                  = "https://example.com/"
  debug                = true
  write_returns_object = true

  oauth_client_credentials {
    oauth_client_id      = "xxxx-yyyy-zzzz"
    oauth_client_secret  = "ssshsecret"
    oauth_token_endpoint = "https://login.example.com/abcde/oauth2/token"
    endpoint_params = <<ENDPOINT_PARAMS
    {
      "resource": "https://example.com/"
    }
    ENDPOINT_PARAMS
  }
}
mhriemers commented 1 month ago

Any update on when this will be merged?

emmanuelgautier commented 6 days ago

This PR is definitely helpful. Some authorization server require to pass audience for example.

Is there anything we can do to help you merge this PR?