mrparkers / terraform-provider-keycloak

Terraform provider for Keycloak
https://registry.terraform.io/providers/mrparkers/keycloak/latest/docs
MIT License
635 stars 313 forks source link

Question: How to set the client registration policies at the realm level? #715

Open phungy opened 2 years ago

phungy commented 2 years ago

Hi,

I am trying to set the client registration policies at the realm level at "Realm -> Realm Settings -> Client Registration -> Client Registration Policies" image

I tried to find the resource name corresponding for what I want to do here https://registry.terraform.io/providers/mrparkers/keycloak/latest/docs/resources/openid_client_client_policy

At the beginning I thought I can use data source to bind the existing policy (i.e: "Trusted Hosts") and just add the extra url I need. But didn't find any supported data source for that. Then I tried to create a new client policy with keycloak_openid_client_client_policy but from the documentation, it requires a list of clients. But I don't want to set a list of client as we want to allow trusted third (base on the policy) to be able to create dynamically client in the dedicated realm we set up.

I also tried to create a dummy client to tested out the keycloak_openid_client_client_policy.

data "keycloak_openid_client" "client_realm_management" {
  realm_id  = local.realm_id
  client_id = "realm-management"
}

resource "keycloak_openid_client" "client_test" {
  client_id = "client_test"
  name      = "client_test"
  realm_id  = local.realm_id

  access_type = "CONFIDENTIAL"
}

resource "keycloak_openid_client_client_policy" "trusted-hosts-v2" {
  resource_server_id = data.keycloak_openid_client.client_realm_management.id
  realm_id           = local.realm_id
  name               = "trusted-hosts-v2"
  decision_strategy  = "UNANIMOUS"
  logic              = "POSITIVE"
  clients = [
    keycloak_openid_client.client_test.id
  ]
}

But I got an ERROR [o.k.s.e.KeycloakErrorHandler:65] (executor-thread-3283) Uncaught server error: java.lang.NullPointerException. The log didn't tell me much about what is wrong.

Is there anything I missed. Or I am on the wrong direction? Does the current version of terraform provider supports the settings I mention in the screenshot?

Thanks for your advices. Phung

phungy commented 2 years ago

Hi @tomrutsaert , Do you know if the setting I want to set is supported by the latest version of the plugin? Thanks

FWest98 commented 10 months ago

Same question as in https://github.com/mrparkers/terraform-provider-keycloak/issues/882