Merging to release-5.14.0: [TT-17585] MinTokenLength: apply the default floor of 3 to the create-time guard (#8346)#8376
Conversation
🎯 Recommended Merge TargetsBased on JIRA ticket TT-17585: [Innersource] Create custom key API doesn't respect default minimum token length Fix Version: Tyk 5.8.15Required:
Fix Version: Tyk 5.13.1Required:
Fix Version: Tyk 5.14.0Required:
Recommended:
📋 Workflow
|
|
This pull request addresses a bug where the gateway would accept custom API keys shorter than the default minimum length of 3 characters during creation, only for them to be unusable at authentication time. The fix introduces a consistent validation floor of 3 characters for token length at both creation and authentication, preventing the creation of invalid keys. Files Changed AnalysisThe changes are localized to three files within the
Architecture & Impact Assessment
Validation FlowThe following diagram illustrates how the new shared function ensures consistent validation across both key creation and authentication. graph TD
subgraph "Shared Logic (middleware.go)"
A[effectiveMinTokenLength] --> B{Is min_token_length configured?};
B -- No (is 0) --> C[Return default: 3];
B -- Yes --> D[Return configured value];
end
subgraph "Key Creation (api.go)"
E[POST /tyk/keys/{custom_id}] --> F[handleAddOrUpdate];
F --> G[Call effectiveMinTokenLength];
G --> H{Is len(custom_id) < result?};
H -- Yes --> I["Reject (400 Bad Request)"];
H -- No --> J[Create Key];
end
subgraph "Key Authentication (middleware.go)"
K[API Request with token] --> L[CheckSessionAndIdentityForValidKey];
L --> M[Call effectiveMinTokenLength];
M --> N{Is len(token) < result?};
N -- Yes --> O["Reject (401/403)"];
N -- No --> P[Continue Auth];
end
Scope Discovery & Context ExpansionThe impact of this change is confined to the
Metadata
Powered by Visor from Probelabs Last updated: 2026-06-25T13:35:44.154Z | Triggered by: pr_updated | Commit: 4c50912 💡 TIP: You can chat with Visor using |
✅ Security Check PassedNo security issues found – changes LGTM. ✅ Security Check PassedNo security issues found – changes LGTM. \n\n✅ Architecture Check PassedNo architecture issues found – changes LGTM. ✅ Performance Check PassedNo performance issues found – changes LGTM. Powered by Visor from Probelabs Last updated: 2026-06-25T13:35:31.850Z | Triggered by: pr_updated | Commit: 4c50912 💡 TIP: You can chat with Visor using |
…44069358ca82a7bac0ee284c1ce/TT-17585
|
SentinelOne CNS Hardcoded Secret Detector SentinelOne CNS is a cloud-agnostic, agentless CSPM & CWPP solution that continuously detects and prevents vulnerabilities that have the highest probability of being exploited in Azure, AWS, Google Cloud, and Kubernetes. |
🚨 Jira Linter FailedCommit: The Jira linter failed to validate your PR. Please check the error details below: 🔍 Click to view error detailsNext Steps
This comment will be automatically deleted once the linter passes. |
|



TT-17585 MinTokenLength: apply the default floor of 3 to the create-time guard (#8346)