[GO] Bad Multiple Authentication Key setting
See original GitHub issueDescription
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
}
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Use a security key for 2-Step Verification - Google Account Help
Security keys can be used with 2-Step Verification to help you keep hackers out ... If you have other second steps set up,...
Read more >Common problems with two-step verification for a work or ...
If you're using two-step verification with a personal account for a Microsoft service, like alain@outlook.com, you can turn the feature on and off....
Read more >Two-factor authentication for Apple ID
On your iPhone, iPad, or iPod touch: Go to Settings > your name > Password & Security. Tap Turn On Two-Factor Authentication.
Read more >How do I turn two-factor authentication on Instagram for ...
How do I turn two-factor authentication on Instagram for multiple devices on or off? ; 1. Tap or your profile picture in the...
Read more >How To Set Up Multi-Factor Authentication for SSH on Ubuntu ...
If you need to log in to your server but don't have access to your TOTP app to get your verification code, you...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I added a second commit to the compare link from my last message. I’m not personally using
Prefix
and I wasn’t able to find docs surrounding its use case, so I’m not sure if I’m missing something surrounding that. The second commit I made is based off of @adamdecaf’s suggestion and just means you have to set the context value for each key you want to pass in.Hey @wing328 👋 Do you know if this is being actively worked on? I started looking into it to see if I could offer a contribution (my first 😄). I think one approach to resolving this would be to make the APIKey struct have one field per APIKey attribute from the openapi spec. I have the start of something thats working locally for me here - https://github.com/OpenAPITools/openapi-generator/compare/master...nmuesch:nick/fix_go_api_key?expand=1 Its not quite ready for a full PR yet so I wanted to post it here and get some thoughts!
A caveat I noticed here is that:
Would appreciate any feedback/thoughts 🙇