Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TT-13271, fix for token metadata not being cached (#6689)
### **User description** Currently when the token is cached into redis we are not cacheing the extra metadata so only the initial request gets populated with the requiered fields. <details open> <summary><a href="https://tyktech.atlassian.net/browse/TT-13271" title="TT-13271" target="_blank">TT-13271</a></summary> <br /> <table> <tr> <th>Summary</th> <td>Add support for custom OAuth server response fields</td> </tr> <tr> <th>Type</th> <td> <img alt="Story" src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10315?size=medium" /> Story </td> </tr> <tr> <th>Status</th> <td>Ready for Testing</td> </tr> <tr> <th>Points</th> <td>N/A</td> </tr> <tr> <th>Labels</th> <td>-</td> </tr> </table> </details> <!-- do not remove this marker as it will break jira-lint's functionality. added_by_jira_lint --> --- <!-- Provide a general summary of your changes in the Title above --> ## Description <!-- Describe your changes in detail --> ## Related Issue <!-- This project only accepts pull requests related to open issues. --> <!-- If suggesting a new feature or change, please discuss it in an issue first. --> <!-- If fixing a bug, there should be an issue describing it with steps to reproduce. --> <!-- OSS: Please link to the issue here. Tyk: please create/link the JIRA ticket. --> ## Motivation and Context <!-- Why is this change required? What problem does it solve? --> ## How This Has Been Tested <!-- Please describe in detail how you tested your changes --> <!-- Include details of your testing environment, and the tests --> <!-- you ran to see how your change affects other areas of the code, etc. --> <!-- This information is helpful for reviewers and QA. --> ## Screenshots (if appropriate) ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply --> <!-- If there are no documentation updates required, mark the item as checked. --> <!-- Raise up any additional concerns not covered by the checklist. --> - [ ] I ensured that the documentation is up to date - [ ] I explained why this PR updates go.mod in detail with reasoning why it's required - [ ] I would like a code coverage CI quality gate exception and have explained why ___ ### **PR Type** enhancement, bug fix ___ ### **Description** - Introduced a new `TokenData` struct to encapsulate token and extra metadata, improving the structure and readability of the code. - Added functions `createTokenDataBytes` and `unmarshalTokenData` to handle JSON marshaling and unmarshaling of token data, enhancing the robustness of data handling. - Modified the caching mechanism to store both token and metadata, ensuring that metadata is preserved and accessible when retrieving tokens from the cache. - Improved the handling of extra metadata by using a map, allowing for more flexible and efficient metadata management. ___ ### **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>mw_oauth2_auth.go</strong><dd><code>Improve token caching and metadata handling in OAuth2</code> </dd></summary> <hr> gateway/mw_oauth2_auth.go <li>Introduced a new <code>TokenData</code> struct to handle token and metadata.<br> <li> Added functions to marshal and unmarshal token data.<br> <li> Modified caching logic to store and retrieve token data with metadata.<br> <li> Enhanced metadata handling by using a map for extra metadata.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6689/files#diff-a90347c3ad28f06a7bd1c5554ce63448774cb486cf4e9961af2323423ce8209d">+85/-17</a> </td> </tr> </table></td></tr></tr></tbody></table> ___ > 💡 **PR-Agent usage**: Comment `/help "your question"` on any pull request to receive relevant information
- Loading branch information