Repository navigation
UNOMI-1001: Restore 3.0 peer abilities in compatibility mode - #914
Merged
Merged
Conversation
A valid X-Unomi-Peer key from an allowed IP again grants setEventId, chooseProfileId, mergeOnLogin and updateOtherProfiles on public endpoints only, without administrator roles. Harden provider keys (length, example key, constant-time compare) and honor X-Forwarded-For only behind trusted proxies.
Add unit and IT coverage for non-compat peer no-op, ability subsets, XFF behind trusted proxies, and peer-denied private endpoints. Document operator guidance for ipAddresses and trustedProxies.
Deleting org.apache.unomi.thirdparty left later suite tests with no providers, so login stopped being protected. Snapshot/restore instead, and wait for persisted peer event ids.
Peer configuration no longer fails open: abilities that name no known ability disable the provider, an empty abilities value grants none, and a provider without an IP allowlist is refused from every address, as in Unomi 3.0. X-Forwarded-For is read from the last entry backwards so a client-supplied leading entry is ignored, and a rejected X-Unomi-Peer header is logged with its reason. Add requireSecureTransport (off by default): when on, a private key or administrator login may only merge profiles or make other identity claims over HTTPS, or behind a trusted proxy reporting it. Peer keys in compatibility mode are not affected. Clear any leftover subject at the start of REST and GraphQL requests, restore the scheduler thread's subject after a merge task, and make hasCompatPeerAbility a default method so other SecurityService implementations keep working. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
Peer abilities in compatibility mode
X-Unomi-Peerkey from an allowed IP again grants the Unomi 3.0 peer abilities on public endpoints only: set event id, choose body profile id, merge on login, update other profiles (segments/scores/consents/systemProperties). No administrator roles; private endpoints unchanged.Provider configuration fails closed
allowExampleKey=true. Keys are compared in constant time.abilitiesomitted grants all four (3.0 behaviour); an empty value grants none; a value that names no known ability (for example a misspelt one) disables the provider with an error.ipAddressesis refused from every address, as in Unomi 3.0.1. The key alone is never enough.X-Forwarded-Foris used only when the direct address is intrustedProxies, and is read from the last entry backwards, skipping trusted proxies, so a client-supplied leading entry is ignored.X-Unomi-Peerheader is logged at WARN with its reason (unknown key, or IP not in the allowlist). MalformedipAddresses/trustedProxiesentries are reported at startup.Profile merge protection
org.apache.unomi.plugins.base.requireSecureTransport(UNOMI_REQUIRE_SECURE_TRANSPORT),falseby default. When on, a tenant private key or administrator login may only merge profiles, record a merge identifier, update another profile or writesystemPropertieson a request received over HTTPS (HttpServletRequest.isSecure()), or from a proxy inorg.apache.unomi.ip.trustedProxiesthat sendsX-Forwarded-Proto: https.X-Unomi-Peerkeys in compatibility mode are not affected.API
CompatPeerPrincipal(final; rejects unknown ability names; an empty set means no abilities).InsecureTransportPrincipal, a marker for a request subject whose request was not encrypted.SecurityService.hasCompatPeerAbility(String)andSecurityService.recordRequestTransport(...), bothdefaultmethods so other implementations keep working.Behaviour changes to note
provider1uses the example key, so it is disabled unless the key is replaced orallowExampleKey=trueis set.ipAddresseslist no longer accepts its key from any address.Test plan
mvn -pl api,services-common,rest,plugins/baseplugin,graphql/cxs-impl -am testhttps://issues.apache.org/jira/browse/UNOMI-1001
🤖 Generated with Claude Code