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

Support using internal realm name on components for support with imported realms #929

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions docs/resources/realm_keystore_aes_generated.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ resource "keycloak_realm_keystore_aes_generated" "keystore_aes_generated" {

- `name` - (Required) Display name of provider when linked in admin console.
- `realm_id` - (Required) The realm this keystore exists in.
- `internal_realm_id` - (Optional) The internal id for the realm, if the realm is imported into Terraform. This is not relevant for realms created through Terraform.
- `enabled` - (Optional) When `false`, key is not accessible in this realm. Defaults to `true`.
- `active` - (Optional) When `false`, key in not used for signing. Defaults to `true`.
- `priority` - (Optional) Priority for the provider. Defaults to `0`
Expand Down
1 change: 1 addition & 0 deletions docs/resources/realm_keystore_ecdsa_generated.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ resource "keycloak_realm_keystore_ecdsa_generated" "keystore_ecdsa_generated" {

- `name` - (Required) Display name of provider when linked in admin console.
- `realm_id` - (Required) The realm this keystore exists in.
- `internal_realm_id` - (Optional) The internal id for the realm, if the realm is imported into Terraform. This is not relevant for realms created through Terraform.
- `enabled` - (Optional) When `false`, key is not accessible in this realm. Defaults to `true`.
- `active` - (Optional) When `false`, key in not used for signing. Defaults to `true`.
- `priority` - (Optional) Priority for the provider. Defaults to `0`
Expand Down
1 change: 1 addition & 0 deletions docs/resources/realm_keystore_hmac_generated.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ resource "keycloak_realm_keystore_hmac_generated" "keystore_hmac_generated" {

- `name` - (Required) Display name of provider when linked in admin console.
- `realm_id` - (Required) The realm this keystore exists in.
- `internal_realm_id` - (Optional) The internal id for the realm, if the realm is imported into Terraform. This is not relevant for realms created through Terraform.
- `enabled` - (Optional) When `false`, key is not accessible in this realm. Defaults to `true`.
- `active` - (Optional) When `false`, key in not used for signing. Defaults to `true`.
- `priority` - (Optional) Priority for the provider. Defaults to `0`
Expand Down
1 change: 1 addition & 0 deletions docs/resources/realm_keystore_java_keystore.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ resource "keycloak_realm_keystore_java_keystore" "java_keystore" {

- `name` - (Required) Display name of provider when linked in admin console.
- `realm_id` - (Required) The realm this keystore exists in.
- `internal_realm_id` - (Optional) The internal id for the realm, if the realm is imported into Terraform. This is not relevant for realms created through Terraform.
- `keystore` - (Required) Path to keys file on keycloak instance.
- `keystore_password` - (Required) Password for the keys.
- `key_alias` - (Required) Alias for the private key.
Expand Down
1 change: 1 addition & 0 deletions docs/resources/realm_keystore_rsa.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ resource "keycloak_realm_keystore_rsa" "keystore_rsa" {

- `name` - (Required) Display name of provider when linked in admin console.
- `realm_id` - (Required) The realm this keystore exists in.
- `internal_realm_id` - (Optional) The internal id for the realm, if the realm is imported into Terraform. This is not relevant for realms created through Terraform.
- `private_key` - (Required) Private RSA Key encoded in PEM format.
- `certificate` - (Required) X509 Certificate encoded in PEM format.
- `enabled` - (Optional) When `false`, key is not accessible in this realm. Defaults to `true`.
Expand Down
1 change: 1 addition & 0 deletions docs/resources/realm_keystore_rsa_generated.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ resource "keycloak_realm_keystore_rsa_generated" "keystore_rsa_generated" {

- `name` - (Required) Display name of provider when linked in admin console.
- `realm_id` - (Required) The realm this keystore exists in.
- `internal_realm_id` - (Optional) The internal id for the realm, if the realm is imported into Terraform. This is not relevant for realms created through Terraform.
- `enabled` - (Optional) When `false`, key is not accessible in this realm. Defaults to `true`.
- `active` - (Optional) When `false`, key in not used for signing. Defaults to `true`.
- `priority` - (Optional) Priority for the provider. Defaults to `0`
Expand Down
16 changes: 12 additions & 4 deletions keycloak/realm_keystore_aes_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (
)

type RealmKeystoreAesGenerated struct {
Id string
Name string
RealmId string
Id string
Name string
RealmId string
InternalRealmId string

Active bool
Enabled bool
Expand All @@ -33,10 +34,17 @@ func convertFromRealmKeystoreAesGeneratedToComponent(realmKey *RealmKeystoreAesG
},
}

var parentId string
if realmKey.InternalRealmId != "" {
parentId = realmKey.InternalRealmId
} else {
parentId = realmKey.RealmId
}

return &component{
Id: realmKey.Id,
Name: realmKey.Name,
ParentId: realmKey.RealmId,
ParentId: parentId,
ProviderId: "aes-generated",
ProviderType: "org.keycloak.keys.KeyProvider",
Config: componentConfig,
Expand Down
16 changes: 12 additions & 4 deletions keycloak/realm_keystore_ecdsa_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (
)

type RealmKeystoreEcdsaGenerated struct {
Id string
Name string
RealmId string
Id string
Name string
RealmId string
InternalRealmId string

Active bool
Enabled bool
Expand All @@ -33,10 +34,17 @@ func convertFromRealmKeystoreEcdsaGeneratedToComponent(realmKey *RealmKeystoreEc
},
}

var parentId string
if realmKey.InternalRealmId != "" {
parentId = realmKey.InternalRealmId
} else {
parentId = realmKey.RealmId
}

return &component{
Id: realmKey.Id,
Name: realmKey.Name,
ParentId: realmKey.RealmId,
ParentId: parentId,
ProviderId: "ecdsa-generated",
ProviderType: "org.keycloak.keys.KeyProvider",
Config: componentConfig,
Expand Down
16 changes: 12 additions & 4 deletions keycloak/realm_keystore_hmac_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (
)

type RealmKeystoreHmacGenerated struct {
Id string
Name string
RealmId string
Id string
Name string
RealmId string
InternalRealmId string

Active bool
Enabled bool
Expand Down Expand Up @@ -37,10 +38,17 @@ func convertFromRealmKeystoreHmacGeneratedToComponent(realmKey *RealmKeystoreHma
},
}

var parentId string
if realmKey.InternalRealmId != "" {
parentId = realmKey.InternalRealmId
} else {
parentId = realmKey.RealmId
}

return &component{
Id: realmKey.Id,
Name: realmKey.Name,
ParentId: realmKey.RealmId,
ParentId: parentId,
ProviderId: "hmac-generated",
ProviderType: "org.keycloak.keys.KeyProvider",
Config: componentConfig,
Expand Down
16 changes: 12 additions & 4 deletions keycloak/realm_keystore_java_keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (
)

type RealmKeystoreJavaKeystore struct {
Id string
Name string
RealmId string
Id string
Name string
RealmId string
InternalRealmId string

Active bool
Enabled bool
Expand Down Expand Up @@ -50,10 +51,17 @@ func convertFromRealmKeystoreJavaKeystoreToComponent(realmKey *RealmKeystoreJava
},
}

var parentId string
if realmKey.InternalRealmId != "" {
parentId = realmKey.InternalRealmId
} else {
parentId = realmKey.RealmId
}

return &component{
Id: realmKey.Id,
Name: realmKey.Name,
ParentId: realmKey.RealmId,
ParentId: parentId,
ProviderId: "java-keystore",
ProviderType: "org.keycloak.keys.KeyProvider",
Config: componentConfig,
Expand Down
16 changes: 12 additions & 4 deletions keycloak/realm_keystore_rsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (
)

type RealmKeystoreRsa struct {
Id string
Name string
RealmId string
Id string
Name string
RealmId string
InternalRealmId string

Active bool
Enabled bool
Expand Down Expand Up @@ -43,10 +44,17 @@ func convertFromRealmKeystoreRsaToComponent(realmKey *RealmKeystoreRsa) *compone
},
}

var parentId string
if realmKey.InternalRealmId != "" {
parentId = realmKey.InternalRealmId
} else {
parentId = realmKey.RealmId
}

return &component{
Id: realmKey.Id,
Name: realmKey.Name,
ParentId: realmKey.RealmId,
ParentId: parentId,
ProviderId: realmKey.ProviderId,
ProviderType: "org.keycloak.keys.KeyProvider",
Config: componentConfig,
Expand Down
16 changes: 12 additions & 4 deletions keycloak/realm_keystore_rsa_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (
)

type RealmKeystoreRsaGenerated struct {
Id string
Name string
RealmId string
Id string
Name string
RealmId string
InternalRealmId string

Active bool
Enabled bool
Expand Down Expand Up @@ -40,10 +41,17 @@ func convertFromRealmKeystoreRsaGeneratedToComponent(realmKey *RealmKeystoreRsaG
},
}

var parentId string
if realmKey.InternalRealmId != "" {
parentId = realmKey.InternalRealmId
} else {
parentId = realmKey.RealmId
}

return &component{
Id: realmKey.Id,
Name: realmKey.Name,
ParentId: realmKey.RealmId,
ParentId: parentId,
ProviderId: "rsa-generated",
ProviderType: "org.keycloak.keys.KeyProvider",
Config: componentConfig,
Expand Down
6 changes: 6 additions & 0 deletions provider/resource_keycloak_realm_keystore_aes_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ func resourceKeycloakRealmKeystoreAesGenerated() *schema.Resource {
Required: true,
ForceNew: true,
},
"internal_realm_id": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: "Internal realm id, if it differs from 'realm_id'",
},
"active": {
Type: schema.TypeBool,
Optional: true,
Expand Down
6 changes: 6 additions & 0 deletions provider/resource_keycloak_realm_keystore_ecdsa_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ func resourceKeycloakRealmKeystoreEcdsaGenerated() *schema.Resource {
Required: true,
ForceNew: true,
},
"internal_realm_id": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: "Internal realm id, if it differs from 'realm_id'",
},
"active": {
Type: schema.TypeBool,
Optional: true,
Expand Down
6 changes: 6 additions & 0 deletions provider/resource_keycloak_realm_keystore_hmac_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ func resourceKeycloakRealmKeystoreHmacGenerated() *schema.Resource {
Required: true,
ForceNew: true,
},
"internal_realm_id": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: "Internal realm id, if it differs from 'realm_id'",
},
"active": {
Type: schema.TypeBool,
Optional: true,
Expand Down
6 changes: 6 additions & 0 deletions provider/resource_keycloak_realm_keystore_java_keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ func resourceKeycloakRealmKeystoreJavaKeystore() *schema.Resource {
Required: true,
ForceNew: true,
},
"internal_realm_id": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: "Internal realm id, if it differs from 'realm_id'",
},
"active": {
Type: schema.TypeBool,
Optional: true,
Expand Down
13 changes: 10 additions & 3 deletions provider/resource_keycloak_realm_keystore_rsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ func resourceKeycloakRealmKeystoreRsa() *schema.Resource {
Required: true,
ForceNew: true,
},
"internal_realm_id": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: "Internal realm id, if it differs from 'realm_id'",
},
"active": {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -80,9 +86,10 @@ func resourceKeycloakRealmKeystoreRsa() *schema.Resource {

func getRealmKeystoreRsaFromData(data *schema.ResourceData) *keycloak.RealmKeystoreRsa {
mapper := &keycloak.RealmKeystoreRsa{
Id: data.Id(),
Name: data.Get("name").(string),
RealmId: data.Get("realm_id").(string),
Id: data.Id(),
Name: data.Get("name").(string),
RealmId: data.Get("realm_id").(string),
InternalRealmId: data.Get("internal_realm_id").(string),

Active: data.Get("active").(bool),
Enabled: data.Get("enabled").(bool),
Expand Down
6 changes: 6 additions & 0 deletions provider/resource_keycloak_realm_keystore_rsa_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ func resourceKeycloakRealmKeystoreRsaGenerated() *schema.Resource {
Required: true,
ForceNew: true,
},
"internal_realm_id": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: "Internal realm id, if it differs from 'realm_id'",
},
"active": {
Type: schema.TypeBool,
Optional: true,
Expand Down
Loading