From fe0caabee53c6fd0aade66b269cdcb41bb03dc18 Mon Sep 17 00:00:00 2001 From: aeneasr <3372410+aeneasr@users.noreply.github.com> Date: Thu, 16 Mar 2023 19:33:55 +0100 Subject: [PATCH] fix: mark client_id and client_secret as required Closes #3261 --- internal/httpclient/api/openapi.yaml | 6 ++++++ internal/httpclient/api_o_auth2.go | 26 ++++++++++++++------------ internal/httpclient/docs/OAuth2Api.md | 10 +++++----- oauth2/handler.go | 2 ++ spec/api.json | 10 +++++++++- spec/swagger.json | 6 ++++-- 6 files changed, 40 insertions(+), 20 deletions(-) diff --git a/internal/httpclient/api/openapi.yaml b/internal/httpclient/api/openapi.yaml index 460c6d93803..5bc5ee9a6ed 100644 --- a/internal/httpclient/api/openapi.yaml +++ b/internal/httpclient/api/openapi.yaml @@ -4155,9 +4155,13 @@ components: revokeOAuth2Token_request: properties: client_id: + required: + - client_id type: string x-formData-name: client_id client_secret: + required: + - client_secret type: string x-formData-name: client_secret token: @@ -4166,6 +4170,8 @@ components: type: string x-formData-name: token required: + - client_id + - client_secret - token type: object oauth2TokenExchange_request: diff --git a/internal/httpclient/api_o_auth2.go b/internal/httpclient/api_o_auth2.go index 7d4ebb8c853..574360830fe 100644 --- a/internal/httpclient/api_o_auth2.go +++ b/internal/httpclient/api_o_auth2.go @@ -3077,14 +3077,9 @@ func (a *OAuth2ApiService) RevokeOAuth2LoginSessionsExecute(r ApiRevokeOAuth2Log type ApiRevokeOAuth2TokenRequest struct { ctx context.Context ApiService *OAuth2ApiService - token *string clientId *string clientSecret *string -} - -func (r ApiRevokeOAuth2TokenRequest) Token(token string) ApiRevokeOAuth2TokenRequest { - r.token = &token - return r + token *string } func (r ApiRevokeOAuth2TokenRequest) ClientId(clientId string) ApiRevokeOAuth2TokenRequest { @@ -3097,6 +3092,11 @@ func (r ApiRevokeOAuth2TokenRequest) ClientSecret(clientSecret string) ApiRevoke return r } +func (r ApiRevokeOAuth2TokenRequest) Token(token string) ApiRevokeOAuth2TokenRequest { + r.token = &token + return r +} + func (r ApiRevokeOAuth2TokenRequest) Execute() (*http.Response, error) { return r.ApiService.RevokeOAuth2TokenExecute(r) } @@ -3137,6 +3137,12 @@ func (a *OAuth2ApiService) RevokeOAuth2TokenExecute(r ApiRevokeOAuth2TokenReques localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} + if r.clientId == nil { + return nil, reportError("clientId is required and must be specified") + } + if r.clientSecret == nil { + return nil, reportError("clientSecret is required and must be specified") + } if r.token == nil { return nil, reportError("token is required and must be specified") } @@ -3158,12 +3164,8 @@ func (a *OAuth2ApiService) RevokeOAuth2TokenExecute(r ApiRevokeOAuth2TokenReques if localVarHTTPHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept } - if r.clientId != nil { - localVarFormParams.Add("client_id", parameterToString(*r.clientId, "")) - } - if r.clientSecret != nil { - localVarFormParams.Add("client_secret", parameterToString(*r.clientSecret, "")) - } + localVarFormParams.Add("client_id", parameterToString(*r.clientId, "")) + localVarFormParams.Add("client_secret", parameterToString(*r.clientSecret, "")) localVarFormParams.Add("token", parameterToString(*r.token, "")) req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) if err != nil { diff --git a/internal/httpclient/docs/OAuth2Api.md b/internal/httpclient/docs/OAuth2Api.md index bdee97d6a53..30c653946c4 100644 --- a/internal/httpclient/docs/OAuth2Api.md +++ b/internal/httpclient/docs/OAuth2Api.md @@ -1664,7 +1664,7 @@ No authorization required ## RevokeOAuth2Token -> RevokeOAuth2Token(ctx).Token(token).ClientId(clientId).ClientSecret(clientSecret).Execute() +> RevokeOAuth2Token(ctx).ClientId(clientId).ClientSecret(clientSecret).Token(token).Execute() Revoke OAuth 2.0 Access or Refresh Token @@ -1683,13 +1683,13 @@ import ( ) func main() { + clientId := "clientId_example" // string | + clientSecret := "clientSecret_example" // string | token := "token_example" // string | - clientId := "clientId_example" // string | (optional) - clientSecret := "clientSecret_example" // string | (optional) configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) - resp, r, err := apiClient.OAuth2Api.RevokeOAuth2Token(context.Background()).Token(token).ClientId(clientId).ClientSecret(clientSecret).Execute() + resp, r, err := apiClient.OAuth2Api.RevokeOAuth2Token(context.Background()).ClientId(clientId).ClientSecret(clientSecret).Token(token).Execute() if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `OAuth2Api.RevokeOAuth2Token``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) @@ -1708,9 +1708,9 @@ Other parameters are passed through a pointer to a apiRevokeOAuth2TokenRequest s Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **token** | **string** | | **clientId** | **string** | | **clientSecret** | **string** | | + **token** | **string** | | ### Return type diff --git a/oauth2/handler.go b/oauth2/handler.go index 859fcbde37f..0eaa222517b 100644 --- a/oauth2/handler.go +++ b/oauth2/handler.go @@ -630,8 +630,10 @@ type revokeOAuth2Token struct { // required: true Token string `json:"token"` // in: formData + // required: true ClientID string `json:"client_id"` // in: formData + // required: true ClientSecret string `json:"client_secret"` } diff --git a/spec/api.json b/spec/api.json index 50ad59652df..9929f140130 100644 --- a/spec/api.json +++ b/spec/api.json @@ -3432,10 +3432,16 @@ "schema": { "properties": { "client_id": { + "required": [ + "client_id" + ], "type": "string", "x-formData-name": "client_id" }, "client_secret": { + "required": [ + "client_secret" + ], "type": "string", "x-formData-name": "client_secret" }, @@ -3448,7 +3454,9 @@ } }, "required": [ - "token" + "token", + "client_id", + "client_secret" ], "type": "object" } diff --git a/spec/swagger.json b/spec/swagger.json index 99f852805d6..2d1c548c34f 100755 --- a/spec/swagger.json +++ b/spec/swagger.json @@ -1880,12 +1880,14 @@ { "type": "string", "name": "client_id", - "in": "formData" + "in": "formData", + "required": true }, { "type": "string", "name": "client_secret", - "in": "formData" + "in": "formData", + "required": true } ], "responses": {