-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[TT-1417] Custom Key Registration Failing with sha256 enabled when OrgID is empty #7462
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
base: master
Are you sure you want to change the base?
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|
API Changes no api changes detected |
🔍 Code Analysis ResultsThis PR fixes a bug where retrieving a custom key via the Gateway Admin API fails when key hashing (e.g., The fix refactors the key retrieval logic to be more robust. It now systematically attempts to find the key by trying two potential formats in order:
This ensures the key can be found regardless of whether the requestor provides the raw key ID or the hashed key, with or without an Files Changed Analysis
Architecture & Impact Assessment
Scope Discovery & Context Expansion
Metadata
Powered by Visor from Probelabs Last updated: 2025-10-17T13:56:10.918Z | Triggered by: opened | Commit: f723330 💡 TIP: You can chat with Visor using |
🔍 Code Analysis ResultsSecurity Issues (1)
Architecture Issues (1)
Performance Issues (1)
Quality Issues (1)
Style Issues (3)
✅ Dependency Check PassedNo dependency issues found – changes LGTM. ✅ Connectivity Check PassedNo connectivity issues found – changes LGTM. Powered by Visor from Probelabs Last updated: 2025-10-17T13:56:11.570Z | Triggered by: opened | Commit: f723330 💡 TIP: You can chat with Visor using |

User description
TT-1417
Description
Related Issue
Motivation and Context
How This Has Been Tested
Screenshots (if appropriate)
Types of changes
Checklist
PR Type
Bug fix, Tests
Description
Fix key GET to try org-scoped formats
Add comprehensive hash-function test matrix
Support lookup without org_id using returned key
Preserve legacy key format fallback
Diagram Walkthrough
flowchart LR GETReq["GET /tyk/keys/{id}"] -- "try org-scoped key" --> OrgScoped["gw.generateToken(orgID, key)"] GETReq -- "fallback to raw key" --> RawKey["origKeyName"] OrgScoped -- "found" --> OK["200 OK"] RawKey -- "found" --> OK RawKey -- "not found" --> NotFound["404 Not Found"]File Walkthrough
api.go
Robust key GET with org-scoped and raw fallbacksgateway/api.go
generateToken(orgID, origKeyName).origKeyNameif first fails.org_id.api_keys_hander_test.go
Tests cover key retrieval across hash functionsgateway/api_keys_hander_test.go