[C++][Qt5] added Authentication Support #8004
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR checklist
./bin/generate-samples.sh
to update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example./bin/generate-samples.sh bin/configs/java*
. For Windows users, please run the script in Git BASH.master
Since the Qt5 generator did not support any security features, I added basic API key authentication. It supports multiple keys as well as key in http header or key as URL query.
EDIT: Added basic authentication with username and password as well.
EDIT2: Updated Readme and added basic bearer token authentication.
Sample headers for verification:
With key in HTTP header:
--> POST /pet HTTP/1.1
--> Host: localhost:3000
--> User-Agent: OpenAPI-Generator/1.0.0/cpp-qt5
--> api_key: special-key
--> Content-Type: application/json
--> Accept-Encoding: identity
--> Content-Length: 75
--> Connection: Keep-Alive
--> Accept-Language: en-US,*
With key in URL query:
--> POST /v2/pet/1606131759633?api_key=special-key HTTP/1.1
--> Host: localhost:3000
--> User-Agent: OpenAPI-Generator/1.0.0/cpp-qt5
--> Content-Type: application/x-www-form-urlencoded
--> Accept-Encoding: identity
--> Content-Length: 20
--> Connection: Keep-Alive
--> Accept-Language: en-US,*
With basic auth (base64 encoding of "demo:p@55w0rd"):
--> POST /v2/pet/1606141504633 HTTP/1.1
--> Host: localhost:3000
--> User-Agent: OpenAPI-Generator/1.0.0/cpp-qt5
--> Authorization: Basic ZGVtbzpwQDU1dzByZA==
--> Content-Type: application/x-www-form-urlencoded
--> Accept-Encoding: identity
--> Content-Length: 20
--> Connection: Keep-Alive
--> Accept-Language: en-US,*
With bearer token ("special-bearer-key"):
--> POST /v2/pet HTTP/1.1
--> Host: localhost:3000
--> User-Agent: OpenAPI-Generator/1.0.0/cpp-qt5
--> Authorization: Bearer special-bearer-key
--> Content-Type: application/json
--> Accept-Encoding: identity
--> Content-Length: 4
--> Connection: Keep-Alive
--> Accept-Language: en-US,*
ping @wing328