Skip to content

Commit 06d1fdd

Browse files
authored
Merge pull request #190 from authlete/fix/client-jwks-update
fix: client remove jwk when neither jwk or jwks is provided
2 parents adfedd3 + 99cac09 commit 06d1fdd

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ HOSTNAME=registry.terraform.io
44
NAMESPACE=authlete
55
NAME=authlete
66
BINARY=terraform-provider-${NAME}
7-
VERSION=1.3.14
7+
VERSION=1.3.17
88
OS_ARCH=darwin_arm64
99
OS_ARCH_AMD64=linux_amd64
1010

internal/provider/client.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -794,12 +794,23 @@ func setDataToClient(d *schema.ResourceData, diags diag.Diagnostics, client ICli
794794
}
795795
}
796796
if d.HasChanges("jwks", "jwk") {
797-
if NotZeroString(d, "jwks") {
797+
isJwksStringProvided := NotZeroString(d, "jwks")
798+
configuredJwkBlocks := d.Get("jwk").(*schema.Set).List()
799+
800+
if isJwksStringProvided {
801+
// jwks takes importance over jwk
798802
client.SetJwks(d.Get("jwks").(string))
799-
} else if NotZeroArray(d, "jwk") {
803+
} else if len(configuredJwkBlocks) > 0 {
800804
var jwk string
801-
jwk, _ = updateJWKS(d.Get("jwk").(*schema.Set).List(), client.GetJwks(), diags)
805+
jwk, _ = updateJWKS(configuredJwkBlocks, client.GetJwks(), diags)
802806
client.SetJwks(jwk)
807+
} else {
808+
// neither jwks string or jwk blocks provided. Remove jwk.
809+
if v3 {
810+
client.(*authlete3.Client).Jwks = nil
811+
} else {
812+
client.(*authlete.Client).Jwks = nil
813+
}
803814
}
804815
}
805816
if d.HasChange("derived_sector_identifier") {

0 commit comments

Comments
 (0)