[TT-17176] PRM auto-migration — deprecate legacy struct, pin runtime guarantees#8247
Conversation
|
This pull request prepares the gateway to support a non-destructive, automated migration of Protected Resource Metadata (PRM) configuration. It accomplishes this by formally deprecating the legacy top-level PRM structure and adding a suite of tests to guarantee specific runtime behaviors, ensuring a safe transition for users upgrading and the ability to downgrade without data loss. Files Changed AnalysisThe changes are focused entirely on API definitions and testing, with no modifications to the core runtime logic:
Architecture & Impact Assessment
Configuration Migration FlowThis PR supports the transition from a single, top-level PRM block to a more flexible, per-security-scheme definition. During the migration, both can coexist, with the gateway prioritizing the new structure but falling back to the legacy one for safety. graph TD
subgraph "Old Structure"
A["authentication"] -- contains --> B["protectedResourceMetadata"];
end
subgraph "Migrated Structure (Coexistence)"
C["authentication"] -- contains --> D["protectedResourceMetadata (legacy, deprecated)"];
C -- contains --> E["securitySchemes"];
E --|scheme_name|--> F["OAuth2"];
F -- contains --> G["protectedResourceMetadata (new)"];
end
style D fill:#f9f,stroke:#333,stroke-width:2px
Scope Discovery & Context ExpansionThis PR is a companion to a migration feature in the The key context is that the migration is non-destructive, meaning the original data is left in place for downgrade safety. This PR ensures the gateway handles this dual-state correctly by:
The changes introduce no new runtime behavior and carry minimal risk, as they consist solely of documentation, schema updates, and tests that enforce existing functionality. Metadata
Powered by Visor from Probelabs Last updated: 2026-06-08T10:52:45.219Z | Triggered by: pr_updated | Commit: f56cfb0 💡 TIP: You can chat with Visor using |
✅ Security Check PassedNo security issues found – changes LGTM. ✅ Performance Check PassedNo performance issues found – changes LGTM. ✅ Quality Check PassedNo quality issues found – changes LGTM. Powered by Visor from Probelabs Last updated: 2026-06-08T10:52:37.892Z | Triggered by: pr_updated | Commit: f56cfb0 💡 TIP: You can chat with Visor using |
…guarantees Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
e2c1512 to
79c1105
Compare
f537eee to
59e142a
Compare
🎯 Recommended Merge TargetsBased on JIRA ticket TT-17176: Protected Resource Metadata — auto-migration of existing customers Fix Version: Tyk 5.14.0
Required:
📋 Workflow
|
🚨 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. |
Summary
Companion gateway PR for the Story 05 PRM auto-migration in tyk-analytics. The dashboard migration (TT-17176 PR #5657) is non-destructive — it leaves the deprecated top-level
authentication.protectedResourceMetadatain place and adds the newsecuritySchemes[<name>].oauth2.protectedResourceMetadataalongside, so the gateway must continue to honour both shapes during the transition.This PR:
staticcheck SA1019, OpenAPI Generator, Stoplight, Redocly, and the dashboard form generator all surface the deprecation.Authentication.ProtectedResourceMetadataand theProtectedResourceMetadatatype each carry// Deprecated:doc comments; all fourx-tyk-api-gatewayschema variants (apidef/oas/schema/x-tyk-api-gateway.json,…strict.json,apidef/mcp/schema/x-tyk-api-gateway.json,apidef/streams/schema/x-tyk-api-gateway.json) carry"deprecated": trueon the legacy type definition.oauth2.enabled: false+oauth2.protectedResourceMetadata.enabled: truewithout silently turning on authentication that wasn't there before.No behaviour change. Pure backwards-compatible documentation + test surface.
Story
Companion PRs
tyk-analytics— #5657 — dashboard startup migration + Python e2e.tyk-analytics-ui(webclient) — no PR for this story; the optional UI banner / read-only legacy form is deferred.Test plan
go test ./apidef/oas/... -run TestProtectedResourceMetadata_SchemaMarkedDeprecated -count=1go test ./apidef/oas/... -run TestOAS_PRMBothBlocksRoundTrip -count=1— both blocks survive marshal/unmarshal with the OAuth2 master stayingfalse.go test ./gateway/... -run TestOAuth2PRM_ServesWhenOAuth2MasterDisabled -count=1go test ./gateway/... -run TestOAuth2PRM_FallsBackToLegacyWhenNewBlockAbsent -count=1Risk
"deprecated": trueis advisory metadata; clients that don't read it see no change.Authentication.PRMMigratedToOAuth2marker field that has since been removed in favour of presence-based idempotency on the dashboard side — that PR was closed; this PR replaces it with a strictly narrower scope (deprecation + runtime-guarantee tests, no marker field).🤖 Generated with Claude Code
Ticket Details
TT-17176
Generated at: 2026-05-27 18:07:46