Skip to content

Commit f6b11e3

Browse files
committed
fix: make grant_types optional in OpenIdConnectApplicationSettingsClient
The Okta API does not always return grant_types in OIDC app responses, but the OpenAPI spec marks it as required, causing UnmarshalJSON to fail with "no value given for required property grant_types". Applies the same fix pattern introduced in okta#559 (buttonField, allowMultipleAcsEndpoints) to a field that PR did not cover: - Remove grant_types from the required list in both spec YAML files - Remove from requiredProperties validation in UnmarshalJSON - Add omitempty to the JSON tag - Update constructor and getters accordingly Verified against a real Okta org: zero unmarshal errors across all apps after this change.
1 parent 88f88aa commit f6b11e3

File tree

3 files changed

+9
-35
lines changed

3 files changed

+9
-35
lines changed

.generator/okta-management-APIs-oasv3-noEnums-inheritance.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42689,8 +42689,6 @@ components:
4268942689
For example, if `https://redirect-*-domain.example.com/oidc/redirect` is configured as a redirect URI, then `https://redirect-1-domain.example.com/oidc/redirect` and `https://redirect-sub-domain.example.com/oidc/redirect` match, but `https://redirect-1.sub-domain.example.com/oidc/redirect` doesn't match.
4269042690
Only the `https` URI scheme can use wildcard redirect URIs.
4269142691
> **Note:** The use of wildcard subdomains is discouraged as an insecure practice, since it may allow malicious actors to have tokens or authorization codes sent to unexpected or attacker-controlled pages. Exercise caution if you decide to include a wildcard redirect URI in your configuration.
42692-
required:
42693-
- grant_types
4269442692
OpenIdConnectApplicationSettingsClientKeys:
4269542693
description: A [JSON Web Key Set](https://tools.ietf.org/html/rfc7517#section-5) for validating JWTs presented to Okta or for encrypting ID tokens minted by Okta for the client
4269642694
type: object

okta/api/openapi.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67055,8 +67055,6 @@ components:
6705567055
For example, if `https://redirect-*-domain.example.com/oidc/redirect` is configured as a redirect URI, then `https://redirect-1-domain.example.com/oidc/redirect` and `https://redirect-sub-domain.example.com/oidc/redirect` match, but `https://redirect-1.sub-domain.example.com/oidc/redirect` doesn't match.
6705667056
Only the `https` URI scheme can use wildcard redirect URIs.
6705767057
> **Note:** The use of wildcard subdomains is discouraged as an insecure practice, since it may allow malicious actors to have tokens or authorization codes sent to unexpected or attacker-controlled pages. Exercise caution if you decide to include a wildcard redirect URI in your configuration.
67058-
required:
67059-
- grant_types
6706067058
type: object
6706167059
OpenIdConnectApplicationSettingsClientKeys:
6706267060
description: "A [JSON Web Key Set](https://tools.ietf.org/html/rfc7517#section-5)\

okta/model_open_id_connect_application_settings_client.go

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ package okta
2525

2626
import (
2727
"encoding/json"
28-
"fmt"
2928
)
3029

3130
// checks if the OpenIdConnectApplicationSettingsClient type satisfies the MappedNullable interface at compile time
@@ -51,7 +50,7 @@ type OpenIdConnectApplicationSettingsClient struct {
5150
FrontchannelLogoutSessionRequired *bool `json:"frontchannel_logout_session_required,omitempty"`
5251
// <x-lifecycle-container><x-lifecycle class=\"ea\"></x-lifecycle> <x-lifecycle class=\"oie\"></x-lifecycle></x-lifecycle-container>URL where Okta sends the logout request
5352
FrontchannelLogoutUri *string `json:"frontchannel_logout_uri,omitempty"`
54-
GrantTypes []string `json:"grant_types"`
53+
GrantTypes []string `json:"grant_types,omitempty"`
5554
// <x-lifecycle-container><x-lifecycle class=\"ea\"></x-lifecycle></x-lifecycle-container>JWE alg algorithm for encrypting the ID token issued to this client. If this is requested, the response is signed, and then encrypted with the result being a nested JWT. The default, if omitted, is that no encryption is performed. See the [Application Public Keys API](/openapi/okta-management/management/tag/ApplicationSSOPublicKeys/) for more information on encryption keys. See [Key management](https://developer.okta.com/docs/guides/key-management/main/) for more information on how encryption keys are used.
5655
IdTokenEncryptedResponseAlg *string `json:"id_token_encrypted_response_alg,omitempty"`
5756
IdpInitiatedLogin *OpenIdConnectApplicationIdpInitiatedLogin `json:"idp_initiated_login,omitempty"`
@@ -95,13 +94,12 @@ type _OpenIdConnectApplicationSettingsClient OpenIdConnectApplicationSettingsCli
9594
// This constructor will assign default values to properties that have it defined,
9695
// and makes sure properties required by API are set, but the set of arguments
9796
// will change when the set of required properties is changed
98-
func NewOpenIdConnectApplicationSettingsClient(grantTypes []string) *OpenIdConnectApplicationSettingsClient {
97+
func NewOpenIdConnectApplicationSettingsClient() *OpenIdConnectApplicationSettingsClient {
9998
this := OpenIdConnectApplicationSettingsClient{}
10099
var consentMethod string = "TRUSTED"
101100
this.ConsentMethod = &consentMethod
102101
var dpopBoundAccessTokens bool = false
103102
this.DpopBoundAccessTokens = &dpopBoundAccessTokens
104-
this.GrantTypes = grantTypes
105103
return &this
106104
}
107105

@@ -405,20 +403,19 @@ func (o *OpenIdConnectApplicationSettingsClient) SetFrontchannelLogoutUri(v stri
405403
o.FrontchannelLogoutUri = &v
406404
}
407405

408-
// GetGrantTypes returns the GrantTypes field value
406+
// GetGrantTypes returns the GrantTypes field value if set, zero value otherwise.
409407
func (o *OpenIdConnectApplicationSettingsClient) GetGrantTypes() []string {
410-
if o == nil {
408+
if o == nil || o.GrantTypes == nil {
411409
var ret []string
412410
return ret
413411
}
414-
415412
return o.GrantTypes
416413
}
417414

418-
// GetGrantTypesOk returns a tuple with the GrantTypes field value
415+
// GetGrantTypesOk returns a tuple with the GrantTypes field value if set, nil otherwise
419416
// and a boolean to check if the value has been set.
420417
func (o *OpenIdConnectApplicationSettingsClient) GetGrantTypesOk() ([]string, bool) {
421-
if o == nil {
418+
if o == nil || o.GrantTypes == nil {
422419
return nil, false
423420
}
424421
return o.GrantTypes, true
@@ -1074,7 +1071,9 @@ func (o OpenIdConnectApplicationSettingsClient) ToMap() (map[string]interface{},
10741071
if !IsNil(o.FrontchannelLogoutUri) {
10751072
toSerialize["frontchannel_logout_uri"] = o.FrontchannelLogoutUri
10761073
}
1077-
toSerialize["grant_types"] = o.GrantTypes
1074+
if o.GrantTypes != nil {
1075+
toSerialize["grant_types"] = o.GrantTypes
1076+
}
10781077
if !IsNil(o.IdTokenEncryptedResponseAlg) {
10791078
toSerialize["id_token_encrypted_response_alg"] = o.IdTokenEncryptedResponseAlg
10801079
}
@@ -1141,27 +1140,6 @@ func (o OpenIdConnectApplicationSettingsClient) ToMap() (map[string]interface{},
11411140
}
11421141

11431142
func (o *OpenIdConnectApplicationSettingsClient) UnmarshalJSON(data []byte) (err error) {
1144-
// This validates that all required properties are included in the JSON object
1145-
// by unmarshalling the object into a generic map with string keys and checking
1146-
// that every required field exists as a key in the generic map.
1147-
requiredProperties := []string{
1148-
"grant_types",
1149-
}
1150-
1151-
allProperties := make(map[string]interface{})
1152-
1153-
err = json.Unmarshal(data, &allProperties)
1154-
1155-
if err != nil {
1156-
return err
1157-
}
1158-
1159-
for _, requiredProperty := range requiredProperties {
1160-
if _, exists := allProperties[requiredProperty]; !exists {
1161-
return fmt.Errorf("no value given for required property %v", requiredProperty)
1162-
}
1163-
}
1164-
11651143
varOpenIdConnectApplicationSettingsClient := _OpenIdConnectApplicationSettingsClient{}
11661144

11671145
err = json.Unmarshal(data, &varOpenIdConnectApplicationSettingsClient)

0 commit comments

Comments
 (0)