Skip to content

Commit 32f996f

Browse files
Add new oidc.web_sso_config field to WorkforcePoolProvider. (#7658) (#14327)
* Add new oidc.webSsoConfig field to WorkforcePoolProvider. * Remove required property of oidc.web_sso_config. * Add default_from_api: true to web_sso_config. Signed-off-by: Modular Magician <[email protected]>
1 parent 9a6dd26 commit 32f996f

5 files changed

+142
-0
lines changed

.changelog/7658.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
iamworkforcepool: added `oidc.web_sso_config` field to `google_iam_workforce_pool_provider`
3+
```

google/resource_iam_workforce_pool_provider.go

+91
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,31 @@ However, existing tokens still grant access.`,
198198
Required: true,
199199
Description: `The OIDC issuer URI. Must be a valid URI using the 'https' scheme.`,
200200
},
201+
"web_sso_config": {
202+
Type: schema.TypeList,
203+
Computed: true,
204+
Optional: true,
205+
Description: `Configuration for web single sign-on for the OIDC provider. Here, web sign-in refers to console sign-in and gcloud sign-in through the browser.`,
206+
MaxItems: 1,
207+
Elem: &schema.Resource{
208+
Schema: map[string]*schema.Schema{
209+
"assertion_claims_behavior": {
210+
Type: schema.TypeString,
211+
Required: true,
212+
ValidateFunc: validateEnum([]string{"ONLY_ID_TOKEN_CLAIMS"}),
213+
Description: `The behavior for how OIDC Claims are included in the 'assertion' object used for attribute mapping and attribute condition.
214+
* ONLY_ID_TOKEN_CLAIMS: Only include ID Token Claims. Possible values: ["ONLY_ID_TOKEN_CLAIMS"]`,
215+
},
216+
"response_type": {
217+
Type: schema.TypeString,
218+
Required: true,
219+
ValidateFunc: validateEnum([]string{"ID_TOKEN"}),
220+
Description: `The Response Type to request for in the OIDC Authorization Request for web sign-in.
221+
* ID_TOKEN: The 'response_type=id_token' selection uses the Implicit Flow for web sign-in. Possible values: ["ID_TOKEN"]`,
222+
},
223+
},
224+
},
225+
},
201226
},
202227
},
203228
ExactlyOneOf: []string{"saml", "oidc"},
@@ -646,6 +671,8 @@ func flattenIAMWorkforcePoolWorkforcePoolProviderOidc(v interface{}, d *schema.R
646671
flattenIAMWorkforcePoolWorkforcePoolProviderOidcIssuerUri(original["issuerUri"], d, config)
647672
transformed["client_id"] =
648673
flattenIAMWorkforcePoolWorkforcePoolProviderOidcClientId(original["clientId"], d, config)
674+
transformed["web_sso_config"] =
675+
flattenIAMWorkforcePoolWorkforcePoolProviderOidcWebSsoConfig(original["webSsoConfig"], d, config)
649676
return []interface{}{transformed}
650677
}
651678
func flattenIAMWorkforcePoolWorkforcePoolProviderOidcIssuerUri(v interface{}, d *schema.ResourceData, config *Config) interface{} {
@@ -656,6 +683,29 @@ func flattenIAMWorkforcePoolWorkforcePoolProviderOidcClientId(v interface{}, d *
656683
return v
657684
}
658685

686+
func flattenIAMWorkforcePoolWorkforcePoolProviderOidcWebSsoConfig(v interface{}, d *schema.ResourceData, config *Config) interface{} {
687+
if v == nil {
688+
return nil
689+
}
690+
original := v.(map[string]interface{})
691+
if len(original) == 0 {
692+
return nil
693+
}
694+
transformed := make(map[string]interface{})
695+
transformed["response_type"] =
696+
flattenIAMWorkforcePoolWorkforcePoolProviderOidcWebSsoConfigResponseType(original["responseType"], d, config)
697+
transformed["assertion_claims_behavior"] =
698+
flattenIAMWorkforcePoolWorkforcePoolProviderOidcWebSsoConfigAssertionClaimsBehavior(original["assertionClaimsBehavior"], d, config)
699+
return []interface{}{transformed}
700+
}
701+
func flattenIAMWorkforcePoolWorkforcePoolProviderOidcWebSsoConfigResponseType(v interface{}, d *schema.ResourceData, config *Config) interface{} {
702+
return v
703+
}
704+
705+
func flattenIAMWorkforcePoolWorkforcePoolProviderOidcWebSsoConfigAssertionClaimsBehavior(v interface{}, d *schema.ResourceData, config *Config) interface{} {
706+
return v
707+
}
708+
659709
func expandIAMWorkforcePoolWorkforcePoolProviderDisplayName(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
660710
return v, nil
661711
}
@@ -729,6 +779,13 @@ func expandIAMWorkforcePoolWorkforcePoolProviderOidc(v interface{}, d TerraformR
729779
transformed["clientId"] = transformedClientId
730780
}
731781

782+
transformedWebSsoConfig, err := expandIAMWorkforcePoolWorkforcePoolProviderOidcWebSsoConfig(original["web_sso_config"], d, config)
783+
if err != nil {
784+
return nil, err
785+
} else if val := reflect.ValueOf(transformedWebSsoConfig); val.IsValid() && !isEmptyValue(val) {
786+
transformed["webSsoConfig"] = transformedWebSsoConfig
787+
}
788+
732789
return transformed, nil
733790
}
734791

@@ -740,6 +797,40 @@ func expandIAMWorkforcePoolWorkforcePoolProviderOidcClientId(v interface{}, d Te
740797
return v, nil
741798
}
742799

800+
func expandIAMWorkforcePoolWorkforcePoolProviderOidcWebSsoConfig(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
801+
l := v.([]interface{})
802+
if len(l) == 0 || l[0] == nil {
803+
return nil, nil
804+
}
805+
raw := l[0]
806+
original := raw.(map[string]interface{})
807+
transformed := make(map[string]interface{})
808+
809+
transformedResponseType, err := expandIAMWorkforcePoolWorkforcePoolProviderOidcWebSsoConfigResponseType(original["response_type"], d, config)
810+
if err != nil {
811+
return nil, err
812+
} else if val := reflect.ValueOf(transformedResponseType); val.IsValid() && !isEmptyValue(val) {
813+
transformed["responseType"] = transformedResponseType
814+
}
815+
816+
transformedAssertionClaimsBehavior, err := expandIAMWorkforcePoolWorkforcePoolProviderOidcWebSsoConfigAssertionClaimsBehavior(original["assertion_claims_behavior"], d, config)
817+
if err != nil {
818+
return nil, err
819+
} else if val := reflect.ValueOf(transformedAssertionClaimsBehavior); val.IsValid() && !isEmptyValue(val) {
820+
transformed["assertionClaimsBehavior"] = transformedAssertionClaimsBehavior
821+
}
822+
823+
return transformed, nil
824+
}
825+
826+
func expandIAMWorkforcePoolWorkforcePoolProviderOidcWebSsoConfigResponseType(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
827+
return v, nil
828+
}
829+
830+
func expandIAMWorkforcePoolWorkforcePoolProviderOidcWebSsoConfigAssertionClaimsBehavior(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
831+
return v, nil
832+
}
833+
743834
func resourceIAMWorkforcePoolWorkforcePoolProviderDecoder(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) {
744835
if v := res["state"]; v == "DELETED" {
745836
return nil, nil

google/resource_iam_workforce_pool_provider_generated_test.go

+8
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ resource "google_iam_workforce_pool_provider" "example" {
167167
oidc {
168168
issuer_uri = "https://accounts.thirdparty.com"
169169
client_id = "client-id"
170+
web_sso_config {
171+
response_type = "ID_TOKEN"
172+
assertion_claims_behavior = "ONLY_ID_TOKEN_CLAIMS"
173+
}
170174
}
171175
}
172176
`, context)
@@ -216,6 +220,10 @@ resource "google_iam_workforce_pool_provider" "example" {
216220
oidc {
217221
issuer_uri = "https://accounts.thirdparty.com"
218222
client_id = "client-id"
223+
web_sso_config {
224+
response_type = "ID_TOKEN"
225+
assertion_claims_behavior = "ONLY_ID_TOKEN_CLAIMS"
226+
}
219227
}
220228
display_name = "Display name"
221229
description = "A sample OIDC workforce pool provider."

google/resource_iam_workforce_pool_workforce_pool_provider_test.go

+12
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ resource "google_iam_workforce_pool_provider" "my_provider" {
149149
oidc {
150150
issuer_uri = "https://accounts.thirdparty.com"
151151
client_id = "client-id"
152+
web_sso_config {
153+
response_type = "ID_TOKEN"
154+
assertion_claims_behavior = "ONLY_ID_TOKEN_CLAIMS"
155+
}
152156
}
153157
display_name = "Display name"
154158
description = "A sample OIDC workforce pool provider."
@@ -176,6 +180,10 @@ resource "google_iam_workforce_pool_provider" "my_provider" {
176180
oidc {
177181
issuer_uri = "https://test.thirdparty.com"
178182
client_id = "new-client-id"
183+
web_sso_config {
184+
response_type = "ID_TOKEN"
185+
assertion_claims_behavior = "ONLY_ID_TOKEN_CLAIMS"
186+
}
179187
}
180188
display_name = "New Display name"
181189
description = "A sample OIDC workforce pool provider with updated description."
@@ -203,6 +211,10 @@ resource "google_iam_workforce_pool_provider" "my_provider" {
203211
oidc {
204212
issuer_uri = "https://accounts.thirdparty.com"
205213
client_id = "client-id"
214+
web_sso_config {
215+
response_type = "ID_TOKEN"
216+
assertion_claims_behavior = "ONLY_ID_TOKEN_CLAIMS"
217+
}
206218
}
207219
}
208220
`, context)

website/docs/r/iam_workforce_pool_provider.html.markdown

+28
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ resource "google_iam_workforce_pool_provider" "example" {
9999
oidc {
100100
issuer_uri = "https://accounts.thirdparty.com"
101101
client_id = "client-id"
102+
web_sso_config {
103+
response_type = "ID_TOKEN"
104+
assertion_claims_behavior = "ONLY_ID_TOKEN_CLAIMS"
105+
}
102106
}
103107
}
104108
```
@@ -122,6 +126,10 @@ resource "google_iam_workforce_pool_provider" "example" {
122126
oidc {
123127
issuer_uri = "https://accounts.thirdparty.com"
124128
client_id = "client-id"
129+
web_sso_config {
130+
response_type = "ID_TOKEN"
131+
assertion_claims_behavior = "ONLY_ID_TOKEN_CLAIMS"
132+
}
125133
}
126134
display_name = "Display name"
127135
description = "A sample OIDC workforce pool provider."
@@ -271,6 +279,26 @@ The following arguments are supported:
271279
(Required)
272280
The client ID. Must match the audience claim of the JWT issued by the identity provider.
273281

282+
* `web_sso_config` -
283+
(Optional)
284+
Configuration for web single sign-on for the OIDC provider. Here, web sign-in refers to console sign-in and gcloud sign-in through the browser.
285+
Structure is [documented below](#nested_web_sso_config).
286+
287+
288+
<a name="nested_web_sso_config"></a>The `web_sso_config` block supports:
289+
290+
* `response_type` -
291+
(Required)
292+
The Response Type to request for in the OIDC Authorization Request for web sign-in.
293+
* ID_TOKEN: The `response_type=id_token` selection uses the Implicit Flow for web sign-in.
294+
Possible values are: `ID_TOKEN`.
295+
296+
* `assertion_claims_behavior` -
297+
(Required)
298+
The behavior for how OIDC Claims are included in the `assertion` object used for attribute mapping and attribute condition.
299+
* ONLY_ID_TOKEN_CLAIMS: Only include ID Token Claims.
300+
Possible values are: `ONLY_ID_TOKEN_CLAIMS`.
301+
274302
## Attributes Reference
275303

276304
In addition to the arguments listed above, the following computed attributes are exported:

0 commit comments

Comments
 (0)