UNOMI-904: V2 API compatibility mode#762
Open
sergehuber wants to merge 3 commits into
Open
Conversation
Let V2 client applications run on the V3 multi-tenant platform without rewriting authentication first: compatibility mode can be toggled at runtime, legacy third-party API keys and IP/X-Unomi-Peer checks apply for protected events, and public endpoints such as /context.json stay usable without tenant API keys while V3 tenant auth remains the default when the mode is off. - V2ThirdPartyConfigService wired to org.apache.unomi.thirdparty.cfg - REST authentication filter and config for V2 compatibility routing - Event collector allowlist checks in RestServiceUtilsImpl - Karaf packaging for org.apache.unomi.rest.authentication.cfg - V2CompatibilityModeIT in the integration test suite
testV2CompatibilityModeWithProtectedEvents loads events/viewEvent.json; resource was missing after V peel (Appendix J peel-fix).
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked PR (merge order)
UNOMI-139-platform(#760)UNOMI-904-v2-api-compatibilityMerge #760 first (multi-tenant platform). This PR adds V2 compatibility on top of that line.
JIRA: UNOMI-904 — V2 API Compatibility mode (sub-task of UNOMI-875)
Problem
Unomi 3.x uses tenant-scoped API keys for REST access. Existing V2 clients expect:
/cxs/context.json) with no authenticationkaraf/karaf)X-Unomi-Peer, using legacy third-party provider configurationWithout a compatibility path, every client must be rewritten before a V3 rollout—high risk, no incremental migration, and no way to validate V3 with production-like V2 traffic.
Solution
This PR introduces an optional V2 compatibility mode (off by default) on the REST layer:
Configuration — OSGi
org.apache.unomi.rest.authentication.cfg, Karaf system properties, and environment variables (UNOMI_REST_AUTHENTICATION_V2COMPATIBILITYMODEENABLED,UNOMI_REST_AUTHENTICATION_V2COMPATIBILITYDEFAULTTENANTID). Mode can be toggled at runtime via Configuration Admin without restarting bundles.Authentication behaviour (when enabled) —
AuthenticationFilter+DefaultRestAuthenticationConfig:V2ThirdPartyConfigServicereads legacyorg.apache.unomi.thirdpartysettings (provider key, allowed IPs, allowed event types) and validates IP +X-Unomi-Peerlike V2Packaging — REST auth config is deployed from the
unomi-restKaraf feature; defaults are documented in the cfg file and overridable incustom.system.properties.Mapping to UNOMI-904 acceptance criteria
X-Unomi-PeerV2ThirdPartyConfigServicev2.compatibilitymode.defaultTenantIdBroader REST surface (profiles, segments, rules, schemas) continues to use the same CXS endpoints; with compatibility mode on, V2 auth rules apply before tenant API-key enforcement. Dedicated IT coverage focuses on context, configuration persistence, default tenant, and protected events.
Configuration (summary)
v2.compatibilitymode.enabledfalsev2.compatibilitymode.defaultTenantIddefaultThird-party providers (protected events):
thirdparty.{name}.key,.ipAddresses,.allowedEventsinorg.apache.unomi.thirdparty.cfg(unchanged V2 layout).Tests
V2CompatibilityModeIT— registered inAllITs; Pax Exam / Karaf integration tests:viewevent + third-party config)Licence