Skip to content

Commit a53c05a

Browse files
promote oidc key upload to GA (#9147) (#16199)
[upstream:daa4c0ac469b735782537ecef4ca5b9039335440] Signed-off-by: Modular Magician <[email protected]>
1 parent 0b1192f commit a53c05a

File tree

4 files changed

+107
-1
lines changed

4 files changed

+107
-1
lines changed

.changelog/9147.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
iamworkforcepool: promoted field `oidc.jwks_json` in resource `google_iam_workforce_pool` to GA
3+
```

google/services/iamworkforcepool/resource_iam_workforce_pool_provider.go

+44
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,33 @@ However, existing tokens still grant access.`,
239239
},
240240
},
241241
},
242+
"jwks_json": {
243+
Type: schema.TypeString,
244+
Optional: true,
245+
Description: `OIDC JWKs in JSON String format. For details on definition of a
246+
JWK, see https:tools.ietf.org/html/rfc7517. If not set, then we
247+
use the 'jwks_uri' from the discovery document fetched from the
248+
.well-known path for the 'issuer_uri'. Currently, RSA and EC asymmetric
249+
keys are supported. The JWK must use following format and include only
250+
the following fields:
251+
'''
252+
{
253+
"keys": [
254+
{
255+
"kty": "RSA/EC",
256+
"alg": "<algorithm>",
257+
"use": "sig",
258+
"kid": "<key-id>",
259+
"n": "",
260+
"e": "",
261+
"x": "",
262+
"y": "",
263+
"crv": ""
264+
}
265+
]
266+
}
267+
'''`,
268+
},
242269
"web_sso_config": {
243270
Type: schema.TypeList,
244271
Computed: true,
@@ -799,6 +826,8 @@ func flattenIAMWorkforcePoolWorkforcePoolProviderOidc(v interface{}, d *schema.R
799826
flattenIAMWorkforcePoolWorkforcePoolProviderOidcClientSecret(original["clientSecret"], d, config)
800827
transformed["web_sso_config"] =
801828
flattenIAMWorkforcePoolWorkforcePoolProviderOidcWebSsoConfig(original["webSsoConfig"], d, config)
829+
transformed["jwks_json"] =
830+
flattenIAMWorkforcePoolWorkforcePoolProviderOidcJwksJson(original["jwksJson"], d, config)
802831
return []interface{}{transformed}
803832
}
804833
func flattenIAMWorkforcePoolWorkforcePoolProviderOidcIssuerUri(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
@@ -869,6 +898,10 @@ func flattenIAMWorkforcePoolWorkforcePoolProviderOidcWebSsoConfigAdditionalScope
869898
return v
870899
}
871900

901+
func flattenIAMWorkforcePoolWorkforcePoolProviderOidcJwksJson(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
902+
return v
903+
}
904+
872905
func expandIAMWorkforcePoolWorkforcePoolProviderDisplayName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
873906
return v, nil
874907
}
@@ -956,6 +989,13 @@ func expandIAMWorkforcePoolWorkforcePoolProviderOidc(v interface{}, d tpgresourc
956989
transformed["webSsoConfig"] = transformedWebSsoConfig
957990
}
958991

992+
transformedJwksJson, err := expandIAMWorkforcePoolWorkforcePoolProviderOidcJwksJson(original["jwks_json"], d, config)
993+
if err != nil {
994+
return nil, err
995+
} else if val := reflect.ValueOf(transformedJwksJson); val.IsValid() && !tpgresource.IsEmptyValue(val) {
996+
transformed["jwksJson"] = transformedJwksJson
997+
}
998+
959999
return transformed, nil
9601000
}
9611001

@@ -1065,6 +1105,10 @@ func expandIAMWorkforcePoolWorkforcePoolProviderOidcWebSsoConfigAdditionalScopes
10651105
return v, nil
10661106
}
10671107

1108+
func expandIAMWorkforcePoolWorkforcePoolProviderOidcJwksJson(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1109+
return v, nil
1110+
}
1111+
10681112
func resourceIAMWorkforcePoolWorkforcePoolProviderDecoder(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) {
10691113
if v := res["state"]; v == "DELETED" {
10701114
return nil, nil

google/services/iamworkforcepool/resource_iam_workforce_pool_provider_generated_test.go

+59
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,65 @@ resource "google_iam_workforce_pool_provider" "example" {
252252
`, context)
253253
}
254254

255+
func TestAccIAMWorkforcePoolWorkforcePoolProvider_iamWorkforcePoolProviderOidcUploadKeyExample(t *testing.T) {
256+
t.Parallel()
257+
258+
context := map[string]interface{}{
259+
"org_id": envvar.GetTestOrgFromEnv(t),
260+
"random_suffix": acctest.RandString(t, 10),
261+
}
262+
263+
acctest.VcrTest(t, resource.TestCase{
264+
PreCheck: func() { acctest.AccTestPreCheck(t) },
265+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
266+
CheckDestroy: testAccCheckIAMWorkforcePoolWorkforcePoolProviderDestroyProducer(t),
267+
Steps: []resource.TestStep{
268+
{
269+
Config: testAccIAMWorkforcePoolWorkforcePoolProvider_iamWorkforcePoolProviderOidcUploadKeyExample(context),
270+
},
271+
{
272+
ResourceName: "google_iam_workforce_pool_provider.example",
273+
ImportState: true,
274+
ImportStateVerify: true,
275+
ImportStateVerifyIgnore: []string{"location", "workforce_pool_id", "provider_id", "oidc.0.client_secret.0.value.0.plain_text"},
276+
},
277+
},
278+
})
279+
}
280+
281+
func testAccIAMWorkforcePoolWorkforcePoolProvider_iamWorkforcePoolProviderOidcUploadKeyExample(context map[string]interface{}) string {
282+
return acctest.Nprintf(`
283+
resource "google_iam_workforce_pool" "pool" {
284+
workforce_pool_id = "tf-test-example-pool%{random_suffix}"
285+
parent = "organizations/%{org_id}"
286+
location = "global"
287+
}
288+
289+
resource "google_iam_workforce_pool_provider" "example" {
290+
workforce_pool_id = google_iam_workforce_pool.pool.workforce_pool_id
291+
location = google_iam_workforce_pool.pool.location
292+
provider_id = "tf-test-example-prvdr%{random_suffix}"
293+
attribute_mapping = {
294+
"google.subject" = "assertion.sub"
295+
}
296+
oidc {
297+
issuer_uri = "https://accounts.thirdparty.com"
298+
client_id = "client-id"
299+
client_secret {
300+
value {
301+
plain_text = "client-secret"
302+
}
303+
}
304+
web_sso_config {
305+
response_type = "ID_TOKEN"
306+
assertion_claims_behavior = "ONLY_ID_TOKEN_CLAIMS"
307+
}
308+
jwks_json = "{\"keys\":[{\"kty\":\"RSA\",\"e\":\"AQAB\",\"use\":\"sig\",\"kid\":\"1i-PmZZrF1j2rOUAxkcQaaz3MnOXcwwziuch_XWjvqI\",\"alg\":\"RS256\",\"n\":\"kFpYE2Zm32y--cnUiFLm4cYmFO8tR4-5KU5-aqhRwiHPP0FkgdQZSoSyp_1DO6PruYfluRMviwOpbmM6LH7KemxVdxLKqLDkHSG0XC3dZkACRFNvBBOdFrvJ0ABXv3vVx592lFE0m-Je5-FerRSQCml6E7icNiTSxizEmvDsTIe8mvArjsODDrgWP25bEFwDPBd5cCl3_2gtW6YdaCRewLXdzuB5Wmp_vOu6trTUzEKbnQlWFtDDCPfOpywYXF8dY1Lbwas5iwwIZozwD2_CuTiyXa3T2_4oa119_rQrIC2BAv7q_S1Xoa2lk3q2GZUSVQ5i3gIbJuDHmp-6yh3k4w\"}]}"
309+
}
310+
}
311+
`, context)
312+
}
313+
255314
func testAccCheckIAMWorkforcePoolWorkforcePoolProviderDestroyProducer(t *testing.T) func(s *terraform.State) error {
256315
return func(s *terraform.State) error {
257316
for name, rs := range s.RootModule().Resources {

website/docs/r/iam_workforce_pool_provider.html.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ The following arguments are supported:
305305
Structure is [documented below](#nested_web_sso_config).
306306

307307
* `jwks_json` -
308-
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
308+
(Optional)
309309
OIDC JWKs in JSON String format. For details on definition of a
310310
JWK, see https:tools.ietf.org/html/rfc7517. If not set, then we
311311
use the `jwks_uri` from the discovery document fetched from the

0 commit comments

Comments
 (0)