Add support for missing authorizer members#1426
Merged
jvschneid merged 2 commits intosmithy-lang:mainfrom Oct 3, 2022
Merged
Conversation
This commit adds support for the `authorizerPayloadFormatVersion` and `enableSimpleResponses` members in `apiGateway#authorizers`. These members are used to properly define authorizers for HTTP APIs.
jvschneid
commented
Sep 27, 2022
Comment on lines
+97
to
+118
| private Optional<ValidationEvent> validateEnableSimpleResponsesConfig(Map<String, AuthorizerDefinition> authorizers, | ||
| ServiceShape service) { | ||
| String invalidConfigs = authorizers.entrySet().stream() | ||
| .filter(entry -> entry.getValue().getEnableSimpleResponses().isPresent()) | ||
| .filter(entry -> entry.getValue().getAuthorizerPayloadFormatVersion().isPresent()) | ||
| .filter(entry -> !entry.getValue().getAuthorizerPayloadFormatVersion().get().equals("2.0")) | ||
| .map(Map.Entry::getKey) | ||
| .sorted() | ||
| .collect(Collectors.joining(", ")); | ||
|
|
||
| if (invalidConfigs.isEmpty()) { | ||
| return Optional.empty(); | ||
| } | ||
|
|
||
| AuthorizersTrait authorizersTrait = service.getTrait(AuthorizersTrait.class).get(); | ||
| return Optional.of(error(service, authorizersTrait, String.format( | ||
| "The enableSimpleResponses member of %s is only supported when authorizedPayloadFormatVersion " | ||
| + "is 2.0. The following authorizers are misconfigured: %s", | ||
| AuthorizersTrait.ID, | ||
| invalidConfigs | ||
| ))); | ||
| } |
Author
There was a problem hiding this comment.
I'm not sure if this validator is being overzealous or not.
Contributor
There was a problem hiding this comment.
This isn't being overzealous. We do similar validation to assure compatible properties are set for other traits. The HttpApiKeyAuthTraitValidator does something similar for the @HttpApiKeyAuthTrait's in and scheme properties.
srchase
reviewed
Sep 30, 2022
...-traits/src/test/java/software/amazon/smithy/aws/apigateway/traits/AuthorizersTraitTest.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Chase Coalwell <782571+srchase@users.noreply.github.com>
srchase
approved these changes
Oct 3, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue #, if available: N/A
Description of changes:
This commit adds support for the
authorizerPayloadFormatVersionandenableSimpleResponsesmembers inapiGateway#authorizers. These members are used to properly define authorizers for HTTP APIs.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.