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

[TT-12741] Looped ap is wrongfully inherit the caller's authentication key when using url rewrite #6778

Conversation

buraksezer
Copy link
Contributor

@buraksezer buraksezer commented Dec 17, 2024

User description

TT-12741
Summary Looped APIs wrongfully inherit the caller's Authentication key when using URL rewrite
Type Bug Bug
Status In Dev
Points N/A
Labels '24Bugsmash, customer_bug, jira_escalated

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 📝

Relevant files
Enhancement
ctx.go
Add support for managing self-looping state in context     

ctx/ctx.go

  • Added a new constant SelfLooping to the context.
  • Introduced new methods ctxSetSelfLooping and ctxSelfLooping for
    managing self-looping state in requests.
  • +1/-0     
    Bug fix
    api.go
    Update rate limit and quota checks for self-looping requests

    gateway/api.go

  • Modified ctxCheckLimits to skip rate limits and quotas for
    self-looping requests.
  • Added logic to check and set self-looping state in requests.
  • +20/-1   
    api_loader.go
    Set self-looping state for self-referencing requests         

    gateway/api_loader.go

    • Added logic to set self-looping state when the hostname is "self".
    +1/-0     
    Tests
    middleware_test.go
    Enhance tests to cover self-looping and URL rewrite scenarios

    gateway/middleware_test.go

  • Updated TestQuotaNotAppliedWithURLRewrite to include extended paths
    and self-looping scenarios.
  • Added a loader to create a merged API spec for testing.
  • +7/-1     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    @buger
    Copy link
    Member

    buger commented Dec 17, 2024

    I'm a bot and I 👍 this PR title. 🤖

    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Code Smell
    The addition of the SelfLooping constant should be reviewed to ensure it is necessary and aligns with the existing constants. Verify its usage across the codebase for consistency.

    Possible Bug
    The ctxCheckLimits function now skips limit checks if ctxSelfLooping is true. Ensure this logic does not introduce unintended behavior or bypass critical checks.

    Code Smell
    The ctxSetSelfLooping and ctxSelfLooping functions introduce new context handling. Verify their necessity and ensure they follow the existing context management patterns.

    Possible Bug
    The ctxSetSelfLooping call in the ServeHTTP method might have unintended side effects. Ensure that setting this context value does not interfere with other request handling logic.

    Test Coverage
    The test TestQuotaNotAppliedWithURLRewrite has been updated. Ensure that it adequately tests the new behavior introduced by the ctxSetSelfLooping logic and covers edge cases.

    Copy link
    Contributor

    github-actions bot commented Dec 17, 2024

    API Changes

    --- prev.txt	2024-12-19 12:34:28.081919637 +0000
    +++ current.txt	2024-12-19 12:34:23.616824756 +0000
    @@ -6847,6 +6847,7 @@
     	// CacheOptions holds cache options required for cache writer middleware.
     	CacheOptions
     	OASDefinition
    +	SelfLooping
     )
     # Package: ./dlpython
     

    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Add a fallback to handle non-boolean context values in ctxSelfLooping

    Ensure that the ctxSelfLooping function properly handles cases where the context
    value is not a boolean to avoid potential runtime errors.

    gateway/api.go [3275-3279]

     if v := r.Context().Value(ctx.SelfLooping); v != nil {
         if boolVal, ok := v.(bool); ok {
             return boolVal
         }
    +    return false // Handle non-boolean values gracefully
     }
    Suggestion importance[1-10]: 9

    Why: The suggestion addresses a potential runtime error by adding a fallback for non-boolean context values in ctxSelfLooping. This is a critical improvement to ensure robustness and prevent unexpected crashes.

    9
    General
    Improve error handling in the test to ensure failures are reported explicitly

    Ensure that the loader.MakeSpec call in the test handles errors gracefully to
    prevent test failures from unhandled exceptions.

    gateway/middleware_test.go [433-434]

     spec, err := loader.MakeSpec(&model.MergedAPI{APIDefinition: preSpec.APIDefinition}, nil)
    -require.NoError(t, err)
    +if err != nil {
    +    t.Fatalf("Failed to create spec: %v", err) // Handle error explicitly
    +}
    Suggestion importance[1-10]: 8

    Why: The suggestion enhances error handling in the test by explicitly reporting failures, which improves test reliability and debugging. This is a meaningful improvement for maintaining high-quality test coverage.

    8
    Add validation to ensure ctxSetSelfLooping is only invoked for valid hostnames

    Verify that ctxSetSelfLooping is only called when the r.URL.Hostname() value is
    validated to avoid unintended side effects.

    gateway/api_loader.go [601-602]

     if r.URL.Hostname() == "self" {
    -    ctxSetSelfLooping(r, true)
    +    if isValidHostname(r.URL.Hostname()) { // Add validation for hostname
    +        ctxSetSelfLooping(r, true)
    +    }
    +}
    Suggestion importance[1-10]: 7

    Why: Adding validation for the hostname before invoking ctxSetSelfLooping reduces the risk of unintended side effects. While the suggestion is valid and improves code safety, the current implementation may already assume the hostname is valid, slightly reducing its criticality.

    7

    gateway/api.go Outdated Show resolved Hide resolved
    gateway/api.go Outdated Show resolved Hide resolved
    gateway/api.go Outdated

    return false
    }

    func ctxLoopingEnabled(r *http.Request) bool {
    Copy link
    Contributor

    @titpetric titpetric Dec 17, 2024

    Choose a reason for hiding this comment

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

    I think this also can be moved to httpctx if the usage is low (complete looping context global funcs).

    gateway/api.go Outdated Show resolved Hide resolved
    @jeffy-mathew
    Copy link
    Contributor

    Adding this comment here for future reference.
    Rate limit isn't checked while looping unless explicitly specified with check_limits query parameter. Refer https://tyk.io/docs/advanced-configuration/transform-traffic/looping/#rate-limiting-in-looping.

    With the changes related to quota limits not respected while self looping, we added the same check ctxCheckLimits in auth key check to skip auth check.
    Customers were relying on this behaviour to have different authentication key for the second (looped) API.
    So, instead of checking with ctxCheckLimits, use ctxSelfLoop to skip auth check only when the API is using a self loop.
    In other cases, the auth check can happen if it is specified in corresponding API definition.

    @jeffy-mathew jeffy-mathew force-pushed the fix/TT-12741/Looped-APIs-wrongfully-inherit-the-caller's-Authentication-key-when-using-URL-rewrite branch from 3b08d1e to cd0965a Compare December 18, 2024 08:18
    Copy link
    Contributor

    @jeffy-mathew jeffy-mathew left a comment

    Choose a reason for hiding this comment

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

    approving despite the race on tests, considering this comment
    https://github.com/TykTechnologies/tyk/blob/master/gateway/looping_test.go#L4

    gateway/looping_test.go Outdated Show resolved Hide resolved
    gateway/api.go Outdated
    @@ -3177,7 +3177,7 @@ func ctxSetCheckLoopLimits(r *http.Request, b bool) {
    // Should we check Rate limits and Quotas?
    func ctxCheckLimits(r *http.Request) bool {
    // If looping disabled, allow all
    if !ctxLoopingEnabled(r) {
    if ctxLoopLevel(r) == 0 {
    Copy link
    Contributor

    @titpetric titpetric Dec 18, 2024

    Choose a reason for hiding this comment

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

    Behaviour 1: Limits are checked on first (root) request, and not on subsequent children.

    ctxLoopingEnabled => ctxLoopLevel(r) > 0

    It unwraps the function and makes it clearer to read without the negation.

    @@ -649,6 +649,10 @@ func (d *DummyProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {

    d.SH.Spec.SanitizeProxyPaths(r)
    ctxSetVersionInfo(r, nil)

    loopLevelLimit, _ := strconv.Atoi(r.URL.Query().Get("loop_limit")) //nolint
    ctxIncLoopLevel(r, loopLevelLimit)
    Copy link
    Contributor

    @titpetric titpetric Dec 18, 2024

    Choose a reason for hiding this comment

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

    Missed code path for internal routing requests.

    As a request is invoked with tyk:// schema it falls into two code branches; this branch didn't consider incrementing the loop level checks; copied from slightly above.

    Naming of this service object is severely misfortunate: DummyProxyHandler (nothing dummy about it).

    @titpetric titpetric requested a review from a team as a code owner December 18, 2024 22:11
    @titpetric titpetric force-pushed the fix/TT-12741/Looped-APIs-wrongfully-inherit-the-caller's-Authentication-key-when-using-URL-rewrite branch 2 times, most recently from ef8ae44 to 4613b56 Compare December 19, 2024 12:03
    Tit Petric and others added 2 commits December 19, 2024 13:08
    @buraksezer buraksezer merged commit d59ae8c into master Dec 19, 2024
    40 of 41 checks passed
    @buraksezer buraksezer deleted the fix/TT-12741/Looped-APIs-wrongfully-inherit-the-caller's-Authentication-key-when-using-URL-rewrite branch December 19, 2024 12:57
    @buraksezer
    Copy link
    Contributor Author

    /release to release-5.3

    Copy link

    tykbot bot commented Dec 19, 2024

    Working on it! Note that it can take a few minutes.

    tykbot bot pushed a commit that referenced this pull request Dec 19, 2024
    …n key when using url rewrite (#6778)
    
    <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.
    
    ___
    
    Bug fix, Tests
    
    ___
    
    - 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.
    
    ___
    
    <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>&nbsp; &nbsp; &nbsp; </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>&nbsp;
    &nbsp; &nbsp; </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>&nbsp;
    &nbsp; </td>
    
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>api_loader.go</strong><dd><code>Set self-looping state
    for self-referencing requests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    </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>&nbsp;
    &nbsp; &nbsp; </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>&nbsp;
    &nbsp; &nbsp; </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]>
    
    (cherry picked from commit d59ae8c)
    Copy link

    tykbot bot commented Dec 19, 2024

    @buraksezer Succesfully merged PR

    buraksezer added a commit that referenced this pull request Dec 19, 2024
    …e caller's authentication key when using url rewrite (#6778) (#6793)
    
    ### **User description**
    [TT-12741] Looped ap is wrongfully inherit the caller's authentication
    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>&nbsp; &nbsp; &nbsp; </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>&nbsp;
    &nbsp; &nbsp; </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>&nbsp;
    &nbsp; </td>
    
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>api_loader.go</strong><dd><code>Set self-looping state
    for self-referencing requests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    </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>&nbsp;
    &nbsp; &nbsp; </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>&nbsp;
    &nbsp; &nbsp; </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]>
    
    [TT-12741]:
    https://tyktech.atlassian.net/browse/TT-12741?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
    
    
    ___
    
    ### **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 tests to validate self-looping behavior, including scenarios
    with authentication tokens and URL rewrites.
    - Added utilities and unit tests for managing and checking self-looping
    state in requests.
    
    
    
    ___
    
    
    
    ### **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>&nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    ctx/ctx.go
    
    <li>Added a new constant <code>SelfLooping</code> to the context.<br>
    <li> Introduced methods <code>ctxSetSelfLooping</code> and
    <code>ctxSelfLooping</code> for managing <br>self-looping state in
    requests.<br>
    
    
    </details>
    
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6793/files#diff-600f5f552779994b15324fda108549eec7e7be30b1d8a1a16ee8344243e0cbc7">+1/-0</a>&nbsp;
    &nbsp; &nbsp; </td>
    
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>looping.go</strong><dd><code>Add utilities for managing
    self-looping state in requests</code></dd></summary>
    <hr>
    
    internal/httpctx/looping.go
    
    <li>Introduced <code>SetSelfLooping</code> and
    <code>IsSelfLooping</code> methods to manage and <br>check self-looping
    state in requests.<br>
    
    
    </details>
    
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6793/files#diff-bee59f2b12fc6b5ab219a4f90ef17e4f32c0e0a0015a48cea1400345f3381f5f">+19/-0</a>&nbsp;
    &nbsp; </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>Updated <code>ctxCheckLimits</code> to bypass rate limits and quotas
    for <br>self-looping requests.<br> <li> Integrated logic to check and
    set self-looping state in requests.<br>
    
    
    </details>
    
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6793/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+7/-0</a>&nbsp;
    &nbsp; &nbsp; </td>
    
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>api_loader.go</strong><dd><code>Set self-looping state
    for self-referencing requests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    </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/6793/files#diff-cdf0b7f176c9d18e1a314b78ddefc2cb3a94b3de66f1f360174692c915734c68">+2/-0</a>&nbsp;
    &nbsp; &nbsp; </td>
    
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>mw_auth_key.go</strong><dd><code>Skip auth key checks
    for self-looping requests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/mw_auth_key.go
    
    <li>Updated logic to skip authentication key checks for self-looping
    <br>requests.<br>
    
    
    </details>
    
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6793/files#diff-aeba053023a54c723dd9f83837e29ca0b2d9a212bc98fa6ad4bbb062669a1cf0">+6/-7</a>&nbsp;
    &nbsp; &nbsp; </td>
    
    </tr>
    </table></td></tr><tr><td><strong>Tests</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>looping_test.go</strong><dd><code>Add test for
    self-looping with authentication tokens</code>&nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/looping_test.go
    
    <li>Added a new test <code>TestLooping_AnotherAPIWithAuthTokens</code>
    to validate <br>self-looping behavior with authentication tokens.<br>
    
    
    </details>
    
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6793/files#diff-c901365bf00575b31a45f2536c63cbc0c3c31350ce6919214a3647dab90596aa">+95/-0</a>&nbsp;
    &nbsp; </td>
    
    </tr>
    
    <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>Enhanced <code>TestQuotaNotAppliedWithURLRewrite</code> to include
    extended paths <br>and self-looping scenarios.<br>
    
    
    </details>
    
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6793/files#diff-6a09a08e3f82cc5e9d8c6b5c8426d75ea1e5d85e15ab008fca1f512e7c49c1e6">+2/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>looping_test.go</strong><dd><code>Add tests for
    self-looping state management utilities</code>&nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    internal/httpctx/looping_test.go
    
    - Added unit tests for `SetSelfLooping` and `IsSelfLooping` methods.
    
    
    
    </details>
    
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6793/files#diff-80a9999142896e55eb4ba14795930cec1baae48c016351a4f3d48292787e05b6">+19/-0</a>&nbsp;
    &nbsp; </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: Burak Sezer <[email protected]>
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    4 participants