diff --git a/.schema/openapi/patches/generic_error.yaml b/.schema/openapi/patches/generic_error.yaml new file mode 100644 index 00000000000..5a26a85b845 --- /dev/null +++ b/.schema/openapi/patches/generic_error.yaml @@ -0,0 +1,6 @@ +- op: add + path: /paths/~1sessions~1whoami/get/parameters/0/example + value: MP2YWEMeM8MxjkGKpH4dqOQ4Q4DlSPaj +- op: add + path: /paths/~1sessions~1whoami/get/parameters/1/example + value: ory_kratos_session=a19iOVAbdzdgl70Rq1QZmrKmcjDtdsviCTZx7m9a9yHIUS8Wa9T7hvqyGTsLHi6Qifn2WUfpAKx9DWp0SJGleIn9vh2YF4A16id93kXFTgIgmwIOvbVAScyrx7yVl6bPZnCx27ec4WQDtaTewC1CpgudeDV2jQQnSaCP6ny3xa8qLH-QUgYqdQuoA_LF1phxgRCUfIrCLQOkolX5nv3ze_f== diff --git a/.schema/openapi/patches/security.yaml b/.schema/openapi/patches/security.yaml index 5c583bb7adf..9318c64e2b1 100644 --- a/.schema/openapi/patches/security.yaml +++ b/.schema/openapi/patches/security.yaml @@ -1,10 +1,3 @@ - op: replace - path: /components/securitySchemes/oryAccessToken - value: - type: http - scheme: bearer - description: | - This security mechanism is only applicable when using the [Ory Platform](https://console.ory.sh) by - creating an [Ory Personal Access Token](https://www.ory.sh/docs/guides/create-personal-access-token). - If you are using the open source version, this security mechanism - will not work out of the box as you will need to add a security mechanism yourself. + path: /components/schemas/genericError/properties/details/additionalProperties + value: false diff --git a/Makefile b/Makefile index 3d404d254bc..929834f5618 100644 --- a/Makefile +++ b/Makefile @@ -90,6 +90,7 @@ sdk: .bin/swagger .bin/ory node_modules -p file://.schema/openapi/patches/security.yaml \ -p file://.schema/openapi/patches/session.yaml \ -p file://.schema/openapi/patches/identity.yaml \ + -p file://.schema/openapi/patches/generic_error.yaml \ spec/swagger.json spec/api.json rm -rf internal/httpclient/models internal/httpclient/clients diff --git a/internal/httpclient/README.md b/internal/httpclient/README.md index f26c96b38ce..228221f5ace 100644 --- a/internal/httpclient/README.md +++ b/internal/httpclient/README.md @@ -216,14 +216,11 @@ Class | Method | HTTP request | Description ### oryAccessToken -- **Type**: HTTP Bearer token authentication +- **Type**: API key +- **API key parameter name**: Authorization +- **Location**: HTTP header -Example - -```golang -auth := context.WithValue(context.Background(), sw.ContextAccessToken, "BEARER_TOKEN_STRING") -r, err := client.Service.Operation(auth, args) -``` +Note, each API key must be added to a map of `map[string]APIKey` where the key is: Authorization and passed in as the auth context for each request. ## Documentation for Utility Methods diff --git a/internal/httpclient/api/openapi.yaml b/internal/httpclient/api/openapi.yaml index 973e9bc2706..56ee2b4f146 100644 --- a/internal/httpclient/api/openapi.yaml +++ b/internal/httpclient/api/openapi.yaml @@ -2660,7 +2660,7 @@ components: example: SQL field "foo" is not a bool. type: string details: - additionalProperties: true + additionalProperties: false description: Further error details type: object message: @@ -4595,12 +4595,8 @@ components: type: object securitySchemes: oryAccessToken: - description: | - This security mechanism is only applicable when using the [Ory Platform](https://console.ory.sh) by - creating an [Ory Personal Access Token](https://www.ory.sh/docs/guides/create-personal-access-token). - If you are using the open source version, this security mechanism - will not work out of the box as you will need to add a security mechanism yourself. - scheme: bearer - type: http + in: header + name: Authorization + type: apiKey x-forwarded-proto: string x-request-id: string diff --git a/internal/httpclient/api_v0alpha1.go b/internal/httpclient/api_v0alpha1.go index 6419280b1de..3390512cfd6 100644 --- a/internal/httpclient/api_v0alpha1.go +++ b/internal/httpclient/api_v0alpha1.go @@ -925,6 +925,20 @@ func (a *V0alpha1ApiService) AdminCreateIdentityExecute(r V0alpha1ApiApiAdminCre } // body params localVarPostBody = r.adminCreateIdentityBody + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["oryAccessToken"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["Authorization"] = key + } + } + } req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err @@ -1200,6 +1214,20 @@ func (a *V0alpha1ApiService) AdminDeleteIdentityExecute(r V0alpha1ApiApiAdminDel if localVarHTTPHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept } + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["oryAccessToken"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["Authorization"] = key + } + } + } req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) if err != nil { return nil, err @@ -1315,6 +1343,20 @@ func (a *V0alpha1ApiService) AdminGetIdentityExecute(r V0alpha1ApiApiAdminGetIde if localVarHTTPHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept } + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["oryAccessToken"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["Authorization"] = key + } + } + } req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err @@ -1454,6 +1496,20 @@ func (a *V0alpha1ApiService) AdminListIdentitiesExecute(r V0alpha1ApiApiAdminLis if localVarHTTPHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept } + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["oryAccessToken"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["Authorization"] = key + } + } + } req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err @@ -1581,6 +1637,20 @@ func (a *V0alpha1ApiService) AdminUpdateIdentityExecute(r V0alpha1ApiApiAdminUpd } // body params localVarPostBody = r.adminUpdateIdentityBody + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["oryAccessToken"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["Authorization"] = key + } + } + } req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err diff --git a/internal/httpclient/docs/GenericError.md b/internal/httpclient/docs/GenericError.md index 77d099fc1c9..8a837180398 100644 --- a/internal/httpclient/docs/GenericError.md +++ b/internal/httpclient/docs/GenericError.md @@ -6,7 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Code** | Pointer to **int64** | The status code | [optional] **Debug** | Pointer to **string** | Debug information This field is often not exposed to protect against leaking sensitive information. | [optional] -**Details** | Pointer to **map[string]map[string]interface{}** | Further error details | [optional] +**Details** | Pointer to **map[string]interface{}** | Further error details | [optional] **Message** | **string** | Error message The error's message. | **Reason** | Pointer to **string** | A human-readable reason for the error | [optional] **Request** | Pointer to **string** | The request ID The request ID is often exposed internally in order to trace errors across service architectures. This is often a UUID. | [optional] @@ -83,20 +83,20 @@ HasDebug returns a boolean if a field has been set. ### GetDetails -`func (o *GenericError) GetDetails() map[string]map[string]interface{}` +`func (o *GenericError) GetDetails() map[string]interface{}` GetDetails returns the Details field if non-nil, zero value otherwise. ### GetDetailsOk -`func (o *GenericError) GetDetailsOk() (*map[string]map[string]interface{}, bool)` +`func (o *GenericError) GetDetailsOk() (*map[string]interface{}, bool)` GetDetailsOk returns a tuple with the Details field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. ### SetDetails -`func (o *GenericError) SetDetails(v map[string]map[string]interface{})` +`func (o *GenericError) SetDetails(v map[string]interface{})` SetDetails sets Details field to given value. diff --git a/internal/httpclient/model_generic_error.go b/internal/httpclient/model_generic_error.go index 2efc427038c..958b5fc50cc 100644 --- a/internal/httpclient/model_generic_error.go +++ b/internal/httpclient/model_generic_error.go @@ -22,7 +22,7 @@ type GenericError struct { // Debug information This field is often not exposed to protect against leaking sensitive information. Debug *string `json:"debug,omitempty"` // Further error details - Details map[string]map[string]interface{} `json:"details,omitempty"` + Details map[string]interface{} `json:"details,omitempty"` // Error message The error's message. Message string `json:"message"` // A human-readable reason for the error @@ -116,9 +116,9 @@ func (o *GenericError) SetDebug(v string) { } // GetDetails returns the Details field value if set, zero value otherwise. -func (o *GenericError) GetDetails() map[string]map[string]interface{} { +func (o *GenericError) GetDetails() map[string]interface{} { if o == nil || o.Details == nil { - var ret map[string]map[string]interface{} + var ret map[string]interface{} return ret } return o.Details @@ -126,7 +126,7 @@ func (o *GenericError) GetDetails() map[string]map[string]interface{} { // GetDetailsOk returns a tuple with the Details field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *GenericError) GetDetailsOk() (map[string]map[string]interface{}, bool) { +func (o *GenericError) GetDetailsOk() (map[string]interface{}, bool) { if o == nil || o.Details == nil { return nil, false } @@ -142,8 +142,8 @@ func (o *GenericError) HasDetails() bool { return false } -// SetDetails gets a reference to the given map[string]map[string]interface{} and assigns it to the Details field. -func (o *GenericError) SetDetails(v map[string]map[string]interface{}) { +// SetDetails gets a reference to the given map[string]interface{} and assigns it to the Details field. +func (o *GenericError) SetDetails(v map[string]interface{}) { o.Details = v } diff --git a/spec/api.json b/spec/api.json index dea188d0d70..e108d4c8156 100755 --- a/spec/api.json +++ b/spec/api.json @@ -937,7 +937,7 @@ "type": "string" }, "details": { - "additionalProperties": true, + "additionalProperties": false, "description": "Further error details", "type": "object" }, @@ -2129,9 +2129,9 @@ }, "securitySchemes": { "oryAccessToken": { - "description": "This security mechanism is only applicable when using the [Ory Platform](https://console.ory.sh) by\ncreating an [Ory Personal Access Token](https://www.ory.sh/docs/guides/create-personal-access-token).\nIf you are using the open source version, this security mechanism\nwill not work out of the box as you will need to add a security mechanism yourself.\n", - "scheme": "bearer", - "type": "http" + "in": "header", + "name": "Authorization", + "type": "apiKey" } } },