Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TT-12741] Looped ap is wrongfully inherit the caller's authenticatio…
…n key when using url rewrite (#6778) ### **User description** <details open> <summary><a href="https://tyktech.atlassian.net/browse/TT-12741" title="TT-12741" target="_blank">TT-12741</a></summary> <br /> <table> <tr> <th>Summary</th> <td>Looped APIs wrongfully inherit the caller's Authentication key when using URL rewrite</td> </tr> <tr> <th>Type</th> <td> <img alt="Bug" src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10303?size=medium" /> Bug </td> </tr> <tr> <th>Status</th> <td>In Dev</td> </tr> <tr> <th>Points</th> <td>N/A</td> </tr> <tr> <th>Labels</th> <td><a href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20'24Bugsmash%20ORDER%20BY%20created%20DESC" title="'24Bugsmash">'24Bugsmash</a>, <a href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20customer_bug%20ORDER%20BY%20created%20DESC" title="customer_bug">customer_bug</a>, <a href="https://tyktech.atlassian.net/issues?jql=project%20%3D%20TT%20AND%20labels%20%3D%20jira_escalated%20ORDER%20BY%20created%20DESC" title="jira_escalated">jira_escalated</a></td> </tr> </table> </details> <!-- do not remove this marker as it will break jira-lint's functionality. added_by_jira_lint --> --- PR to see CI/CD result, please don't merge it. ___ ### **PR Type** Bug fix, Tests ___ ### **Description** - Introduced a new context constant `SelfLooping` and methods `ctxSetSelfLooping` and `ctxSelfLooping` to manage self-looping state in requests. - Updated `ctxCheckLimits` to bypass rate limits and quotas for self-looping requests. - Modified API loader to set self-looping state for self-referencing requests. - Enhanced the test `TestQuotaNotAppliedWithURLRewrite` to include scenarios for self-looping and URL rewrite, ensuring proper behavior. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>ctx.go</strong><dd><code>Add support for managing self-looping state in context</code> </dd></summary> <hr> ctx/ctx.go <li>Added a new constant <code>SelfLooping</code> to the context.<br> <li> Introduced new methods <code>ctxSetSelfLooping</code> and <code>ctxSelfLooping</code> for <br>managing self-looping state in requests.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6778/files#diff-600f5f552779994b15324fda108549eec7e7be30b1d8a1a16ee8344243e0cbc7">+1/-0</a> </td> </tr> </table></td></tr><tr><td><strong>Bug fix</strong></td><td><table> <tr> <td> <details> <summary><strong>api.go</strong><dd><code>Update rate limit and quota checks for self-looping requests</code></dd></summary> <hr> gateway/api.go <li>Modified <code>ctxCheckLimits</code> to skip rate limits and quotas for <br>self-looping requests.<br> <li> Added logic to check and set self-looping state in requests.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6778/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+20/-1</a> </td> </tr> <tr> <td> <details> <summary><strong>api_loader.go</strong><dd><code>Set self-looping state for self-referencing requests</code> </dd></summary> <hr> gateway/api_loader.go - Added logic to set self-looping state when the hostname is "self". </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6778/files#diff-cdf0b7f176c9d18e1a314b78ddefc2cb3a94b3de66f1f360174692c915734c68">+1/-0</a> </td> </tr> </table></td></tr><tr><td><strong>Tests</strong></td><td><table> <tr> <td> <details> <summary><strong>middleware_test.go</strong><dd><code>Enhance tests to cover self-looping and URL rewrite scenarios</code></dd></summary> <hr> gateway/middleware_test.go <li>Updated <code>TestQuotaNotAppliedWithURLRewrite</code> to include extended paths <br>and self-looping scenarios.<br> <li> Added a loader to create a merged API spec for testing.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6778/files#diff-6a09a08e3f82cc5e9d8c6b5c8426d75ea1e5d85e15ab008fca1f512e7c49c1e6">+7/-1</a> </td> </tr> </table></td></tr></tr></tbody></table> ___ > 💡 **PR-Agent usage**: Comment `/help "your question"` on any pull request to receive relevant information --------- Co-authored-by: Tit Petric <[email protected]> Co-authored-by: Tit Petric <[email protected]>
- Loading branch information