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

[Feature] [OpenAPI] Support OpenAPI 3 securitySchemes #1725

Merged
merged 8 commits into from Nov 1, 2019

Conversation

@eliasmeire
Copy link
Contributor

eliasmeire commented Oct 12, 2019

Add support for importing securitySchemes from OpenApi v3

Specification: https://swagger.io/docs/specification/authentication/

This PR partially implements #1698

This PR adds support for the following Open API security types

  • HTTP Basic authentication (docs)
  • API keys (docs)
  • Cookies (docs)

These types are not handled (yet)

@welcome

This comment has been minimized.

Copy link

welcome bot commented Oct 12, 2019

💖 Thanks for opening this pull request! 💖

To help make this a smooth process, please be sure you have first read the
contributing guidelines.

@eliasmeire eliasmeire changed the title <!-- Please open an [Issue](https://github.com/getinsomnia/insomnia/issues/new) first to discuss new features or non-trivial changes. Please provide as much detail as possible on the change as possible including general description, implementation details, potential shortcommings, etc. [Feature] Support OpenAPI 3 securitySchemes Oct 12, 2019
@eliasmeire eliasmeire changed the title [Feature] Support OpenAPI 3 securitySchemes [Feature] [OpenAPI] Support OpenAPI 3 securitySchemes Oct 12, 2019
@@ -16,7 +16,7 @@ describe('Fixtures', () => {
const prefix = input.replace(/-input\.[^.]+/, '');
const output = `${prefix}-output.json`;

if (!prefix.includes('simple')) {

This comment has been minimized.

Copy link
@eliasmeire

eliasmeire Oct 12, 2019

Author Contributor

Not sure why this is here, but it was skipping all the open api fixtures. I changed the logic to only skip that failing curl test. Let me know if this needs changes 😄

This comment has been minimized.

Copy link
@gschier

gschier Oct 31, 2019

Contributor

Ah, woops. I must have accidentally committed this. What you've done looks good :)

Elias Meire
Copy link
Contributor

gschier left a comment

This is awesome! And thanks for updating the test fixtures too. Just a couple comments 💯

@@ -16,7 +16,7 @@ describe('Fixtures', () => {
const prefix = input.replace(/-input\.[^.]+/, '');
const output = `${prefix}-output.json`;

if (!prefix.includes('simple')) {

This comment has been minimized.

Copy link
@gschier

gschier Oct 31, 2019

Contributor

Ah, woops. I must have accidentally committed this. What you've done looks good :)

const httpAuth = supportedSchemes.find(
scheme => scheme.type === SECURITY_TYPE.HTTP && scheme.scheme === 'basic',
)
? { username: '{{ httpUsername }}', password: '{{ httpPassword }}' }

This comment has been minimized.

Copy link
@gschier

gschier Oct 31, 2019

Contributor

The authentication attribute also requires a type parameter so this should have type: 'basic'.

Here's a list of accepted authentication types:

AUTH_NONE = 'none';
AUTH_OAUTH_2 = 'oauth2';
AUTH_OAUTH_1 = 'oauth1';
AUTH_BASIC = 'basic';
AUTH_DIGEST = 'digest';
AUTH_BEARER = 'bearer';
AUTH_NTLM = 'ntlm';
AUTH_HAWK = 'hawk';
AUTH_AWS_IAM = 'iam';
AUTH_NETRC = 'netrc';
AUTH_ASAP = 'asap';

This comment has been minimized.

Copy link
@eliasmeire

eliasmeire Nov 1, 2019

Author Contributor

Added "type": "basic" 😄

* @param {Object} securitySchemes - Open API security schemes
* @returns {Object} Insomnia environment variables containing security information
*/
function getSecurityEnvVariables(securitySchemes) {

This comment has been minimized.

Copy link
@gschier

gschier Oct 31, 2019

Contributor

Nice, I love the use of environments for this.

@gschier
gschier approved these changes Nov 1, 2019
Copy link
Contributor

gschier left a comment

Awesome! So glad to have this in here

@gschier gschier merged commit 414e35e into Kong:develop Nov 1, 2019
0 of 2 checks passed
0 of 2 checks passed
continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build failed
Details
@Lyra2108

This comment has been minimized.

Copy link

Lyra2108 commented Dec 4, 2019

Thanks from me as well :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.