Retrieve api spec documents from protected URIs by using overrides config
Problem
API security is able to consume specification documents (HAR/Postman/OpenApi) from URLs. Some URLs are protected thus they are not available to anyone with just the URL. The API security does not support any mechanism to allow consuming documents from protected URLs.
A customer is running into this issue currently. See linked issue.
Solution
Reuse Overrides configuration when requesting specification document (HAR/Postman/OpenApi) from a URL.
Remark
- OpenApi files can be split into multiple files using
$ref. The support for$refin OpenApi3.xis based on JSON Schema, while in OpenApi2.0is limited to specific sections of the document. It may be required to research how to load external resources which are protected. - Postman Collection specification may use a complementary file Postman Variables file. It may be required to load complimentary files from a protected location.
Proposal
-
MR to update FileLoader-
Add a FileLoader.LoadUrloverload that accepts aOverrideDocumentinstance-
If OverrideDocumentinstance is provided then modify instance ofHttpRequestMessageto override:-
headers with OverrideDocument.Headers -
cookies with OverrideDocument.Cookies -
query string with OverrideDocument.Query
-
-
Add Unit test(s). If HTTP access is required consider using in-process TestHttpListener(e.g.CreateTargetServer). -
Test each override option -
For OverrideDocument.Querytest if overwrites an existing query-string parameter
-
-
-
-
MR to update Overrides-
Modify the Overridesservice to-
allow retrieving OverrideDocumentinstance.-
If the service is running, it could retrieve last updated instance. -
If the service is not running, it should not start the service, but load the document. -
document could be loaded from the file. The file may not exist but be generated by using override_cmd. -
document could be loaded from env var.
-
-
-
Add unit(s) test for new method/property which retrieves OverrideDocumentinstance
-
-
-
MR to update Readers andValidators-
Update Readerto useOverrideDocumentwhen callingFileLoader.Loadfor HAR, OpenAPI ($ref), Postman (postman variables), GraphQL.-
Follow rules from note to decide whether or not to pass OverrideDocument. -
Add unit tests for each format and related files
-
-
Update Validatorto useOverrideDocumentwhen callingFileLoader.Loadfor HAR, OpenAPI ($ref), Postman (postman variables), GraphQL. Follow rules from note-
Follow rules from note to decide whether or not to pass OverrideDocument. -
Add unit tests for each format and related files
-
-
Integration tests -
Update flask/graphql target to reject API spec document and related files. e.g. look for a specific token in Header, Cookie, or Query. If the token is provided then the content is delivered, otherwise, 4xx should be returned. -
Add integration test for each API spec format (each test using related files, e.g. postman variables)
-
-
Edited by 🤖 GitLab Bot 🤖