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

feat: openapi support for auth usecases #949

Merged
merged 12 commits into from
Jun 4, 2019
Merged

Conversation

praneetap
Copy link
Contributor

@praneetap praneetap commented Jun 3, 2019

Issue #, if available:
#191 #627
Description of changes:
Adding OpenApi 3.0 support for auth use cases. This adds a global/api flag called OpenApiVersion, which when specified as 3.. adds securitySchemes as per OpenApiSpec 3.
Description of how you validated changes:
End to end tests,
unit tests
deployed locally transformed template on Cfn
Checklist:

  • Write/update tests
  • make pr passes
  • Update documentation

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@praneetap praneetap requested a review from keetonian June 3, 2019 21:32
@praneetap praneetap self-assigned this Jun 3, 2019
@praneetap praneetap requested a review from brettstack June 3, 2019 21:32
samtranslator/model/api/api_generator.py Outdated Show resolved Hide resolved
samtranslator/plugins/globals/globals.py Outdated Show resolved Hide resolved
@codecov-io
Copy link

Codecov Report

Merging #949 into develop will decrease coverage by 0.07%.
The diff coverage is 78.57%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #949      +/-   ##
===========================================
- Coverage    94.86%   94.78%   -0.08%     
===========================================
  Files           69       69              
  Lines         3055     3067      +12     
  Branches       573      578       +5     
===========================================
+ Hits          2898     2907       +9     
  Misses          84       84              
- Partials        73       76       +3
Impacted Files Coverage Δ
samtranslator/plugins/globals/globals.py 99% <100%> (ø) ⬆️
samtranslator/model/api/api_generator.py 94.73% <76.92%> (-1.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7859f19...6b69076. Read the comment docs.

Copy link
Contributor

@keetonian keetonian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. This looks good 👍

"""
Convert auth components to openapi 3 in definition body if OpenApiVersion flag is specified.

If there is swagger defined in the definition body, we treat it as a swagger spec and do not
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: If "swagger" is defined... we use the swagger spec and do not...

definition_body['components'] = {}
definition_body['components']['securitySchemes'] = definition_body['securityDefinitions']
del definition_body['securityDefinitions']
return definition_body
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Next question: should we error on an else statement here? (using openapi and not swagger, and the openapi version doesn't match a version we support).

Or is this already caught elsewhere?

StageName: SomeStage
DefinitionBody:
openapi: 3.1.1
swagger: 2.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a user wants to do this, we can let them, and allow them to deal with whatever ApiGateway thinks about it. I think this will be fine (but we definitely don't recommend doing anything of the sort).

@praneetap praneetap merged commit 675fb89 into aws:develop Jun 4, 2019
@praneetap praneetap deleted the oas-deux branch June 4, 2019 23:42
praneetap added a commit to praneetap/serverless-application-model that referenced this pull request Jun 5, 2019
brettstack pushed a commit that referenced this pull request Jun 12, 2019
* chore: update test_translator.py (#933)

* fix: partitionalize arn in StepFunctionsExecutionPolicy (#941)

* fix: fix a deprecation warning from jsonschema 3.x (#946)

For example, in https://travis-ci.org/awslabs/serverless-application-model/jobs/538917819:

/home/travis/build/awslabs/serverless-application-model/.tox/py36/lib/python3.6/site-packages/jsonschema/validators.py:893: DeprecationWarning: The metaschema specified by $schema was not found. Using the latest draft to validate, but this will raise an error in the future.
  cls = validator_for(schema)

* feat: openapi version 3 support non-auth changes (#932)

* feat: openapi support for auth usecases (#949)

* chore: Fixing security alerts on the repo

* addressed cr comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants