Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C++][Qt5] added Authentication Support #8004

Merged
merged 6 commits into from
Nov 28, 2020
Merged

[C++][Qt5] added Authentication Support #8004

merged 6 commits into from
Nov 28, 2020

Conversation

basyskom-dege
Copy link
Contributor

@basyskom-dege basyskom-dege commented Nov 23, 2020

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • If contributing template-only or documentation-only changes which will change sample output, build the project beforehand.
  • Run the shell script ./bin/generate-samples.shto 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.
  • File the PR against the correct branch: master
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

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

@basyskom-dege basyskom-dege changed the title [C++][Qt5] added API Key Authentication [C++][Qt5] added Authentication Support Nov 24, 2020
@wing328
Copy link
Member

wing328 commented Nov 25, 2020

cc @ravinikam (2017/07) @stkrwork (2017/07) @etherealjoy (2018/02) @MartinDelille (2018/03) @muttleyxd (2019/08)

@wing328 wing328 added this to the 5.0.0 milestone Nov 28, 2020
@wing328 wing328 merged commit cb1a620 into OpenAPITools:master Nov 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants