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.
Previously Teletraan looks for the request body for AuthZ resource identifier. However it has a security flaw for some endpoints. This PR address the issue by using the identifier from request path parameter for those affected resources.
Details of the issue
Some Teletraan endpoints follows a pattern that requires the resource identifier in the path parameter, while the request body also contains the same ID field. The ID in the path parameter is used for later processing. Therefore it's possible for a request to contain 2 resource IDs and the one used for authorization can be different from the resource being changed.
Changes
First of all some interface change. Previously the annotation
ResourceAuthZInfo.type
expects the type of the extracted resource. Now it's the type of the input resource. This will reduce some confusion because it matches the method it annotates.When appropriate, a path resource extractor replaces the previously used body resource extractor. New implementations of resource extractors are added.
The most change happen in the EnvStageBodyExtractor.java. This is the result of the interface change. The implementation are split into individual extractors.
Tests and validation
Close to 100% test coverage for this change.