Skip to content

Commit 55dd075

Browse files
committed
fix: make grant_types optional in OpenIdConnectApplicationSettingsClient
Rebased onto master after v6.1.0 openapi spec regeneration. The Okta API does not require grant_types when creating an OIDC application client — it defaults to [authorization_code]. The generated Go SDK incorrectly marks grant_types as a required property, which forces callers to supply an empty array just to satisfy the constructor signature and triggers a JSON unmarshal error on responses where grant_types isn't present. This change: - Removes the required: [grant_types] entry from the two source OpenAPI spec files (.generator/*.yaml and okta/api/openapi.yaml) - Regenerates the affected Go model: - GrantTypes json tag gains omitempty - NewOpenIdConnectApplicationSettingsClient no longer takes a grantTypes parameter - GetGrantTypes/GetGrantTypesOk handle nil GrantTypes - UnmarshalJSON drops the requiredProperties check for grant_types - ToMap skips grant_types when nil
1 parent 59e763d commit 55dd075

File tree

5 files changed

+12
-38
lines changed

5 files changed

+12
-38
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44553,8 +44553,6 @@ components:
4455344553
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.
4455444554
Only the `https` URI scheme can use wildcard redirect URIs.
4455544555
> **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.
44556-
required:
44557-
- grant_types
4455844556
OpenIdConnectApplicationSettingsClientKeys:
4455944557
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
4456044558
type: object

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ func main() {
549549
}
550550
client := okta.NewAPIClient(config)
551551

552-
settingClient := okta.NewOpenIdConnectApplicationSettingsClient([]string{"grantTypes"})
552+
settingClient := okta.NewOpenIdConnectApplicationSettingsClient()
553553
settingClient.SetClientUri("https://example.com/client")
554554
settingClient.SetLogoUri("https://example.com/assets/images/logo-new.png")
555555
settingClient.SetResponseTypes([]string{"token", "id_token", "code"})

okta/api/openapi.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70077,8 +70077,6 @@ components:
7007770077
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.
7007870078
Only the `https` URI scheme can use wildcard redirect URIs.
7007970079
> **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.
70080-
required:
70081-
- grant_types
7008270080
type: object
7008370081
OpenIdConnectApplicationSettingsClientKeys:
7008470082
description: "A [JSON Web Key Set](https://tools.ietf.org/html/rfc7517#section-5)\

okta/docs/OpenIdConnectApplicationSettingsClient.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Name | Type | Description | Notes
1313
**DpopBoundAccessTokens** | Pointer to **bool** | Indicates that the client application uses Demonstrating Proof-of-Possession (DPoP) for token requests. If `true`, the authorization server rejects token requests from this client that don't contain the DPoP header. > **Note:** If `dpop_bound_access_tokens` is true, then `client_credentials` and `implicit` aren't allowed in `grant_types`. | [optional] [default to false]
1414
**FrontchannelLogoutSessionRequired** | Pointer to **bool** | <x-lifecycle-container><x-lifecycle class=\"ea\"></x-lifecycle> <x-lifecycle class=\"oie\"></x-lifecycle></x-lifecycle-container>Determines whether Okta sends `sid` and `iss` in the logout request | [optional]
1515
**FrontchannelLogoutUri** | Pointer to **string** | <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 | [optional]
16-
**GrantTypes** | **[]string** | |
16+
**GrantTypes** | **[]string** | | [optional]
1717
**IdTokenEncryptedResponseAlg** | Pointer to **string** | 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/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. | [optional]
1818
**IdpInitiatedLogin** | Pointer to [**OpenIdConnectApplicationIdpInitiatedLogin**](OpenIdConnectApplicationIdpInitiatedLogin.md) | | [optional]
1919
**InitiateLoginUri** | Pointer to **string** | URL string that a third party can use to initiate the sign-in flow by the client | [optional]
@@ -38,7 +38,7 @@ Name | Type | Description | Notes
3838

3939
### NewOpenIdConnectApplicationSettingsClient
4040

41-
`func NewOpenIdConnectApplicationSettingsClient(grantTypes []string, ) *OpenIdConnectApplicationSettingsClient`
41+
`func NewOpenIdConnectApplicationSettingsClient() *OpenIdConnectApplicationSettingsClient`
4242

4343
NewOpenIdConnectApplicationSettingsClient instantiates a new OpenIdConnectApplicationSettingsClient object
4444
This constructor will assign default values to properties that have it defined,

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
// 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/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)