Skip to content

[GO] Bad Multiple Authentication Key setting #797

@emreakca

Description

@emreakca
Description

Multiple Authentication settings won't work, since the API is setting the same key for multiple Headers.

openapi-generator version

3.1

OpenAPI declaration file content or url

in yaml:

[...]
security:
  - ApiKeyAuth1: []
  - ApiKeyAuth2: []
[...]
components:
  securitySchemes:
    ApiKeyAuth1:
      type: apiKey
      in: header
      name: X-Auth-Key-1
    ApiKeyAuth2:
      type: apiKey
      in: header
      name: X-Auth-Key-2

in go:

	if ctx != nil {
		// API Key Authentication
		if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
			var key string
			if auth.Prefix != "" {
				key = auth.Prefix + " " + auth.Key
			} else {
				key = auth.Key
			}
			localVarHeaderParams["X-Auth-Key-1"] = key
		}
	}

	if ctx != nil {
		// API Key Authentication
		if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
			var key string
			if auth.Prefix != "" {
				key = auth.Prefix + " " + auth.Key
			} else {
				key = auth.Key
			}
			localVarHeaderParams["X-Auth-Key-2"] = key
		}
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions