Skip to content

[UNOMI-962] Harden 3.1 REST API: V2 compat auth, missing-resource 404s, and export validation - #822

Closed
sergehuber wants to merge 3 commits into
masterfrom
fix/v2-compat-karaf-admin-permissions
Closed

[UNOMI-962] Harden 3.1 REST API: V2 compat auth, missing-resource 404s, and export validation#822
sergehuber wants to merge 3 commits into
masterfrom
fix/v2-compat-karaf-admin-permissions

Conversation

@sergehuber

@sergehuber sergehuber commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Plain-language summary

Unomi 3.1 release validation found several REST API problems. In V2 compatibility mode, Karaf admin users could not call some private endpoints such as /cxs/privacy/info, which broke health checks and migration tooling. Other endpoints returned server errors (HTTP 500) when a resource was simply missing, or when export configuration was incomplete. This PR fixes those server-side issues so clients get correct HTTP status codes and clear errors. V3 authentication behavior outside V2 compat mode is unchanged.

What changed

  • V2 compat auth: Karaf admin on private endpoints gets the tenant admin roles needed for persistence operations (e.g. AGGREGATE on /cxs/privacy/info). Integration test added in V2CompatibilityModeIT.
  • Missing resources → 404: Value types, goals, goal reports, and events return HTTP 404 when the id does not exist (REST layer + goal report null guard in service).
  • Export hardening: Profile CSV export handles missing segment metadata without NPE; router export validates segment and mapping before processing.
  • OpenSearch parity: Property conditions with null/missing values throw IllegalArgumentException, matching Elasticsearch behavior.
  • Blueprint: Inject contextManager into UserListServiceImpl.
  • Logging: Duplicate property mapping messages downgraded from WARN to DEBUG on ES/OS persistence.
  • Unit tests: MissingResourceEndpointsTest, GoalsServiceImplTest, ProfileServiceImplTest, ProfileExportServiceImplTest, PropertyConditionOSQueryBuilderTest.

Test plan

  • V2CompatibilityModeIT — includes GET /cxs/privacy/info under V2 compat
  • MissingResourceEndpointsTest (REST unit)
  • GoalsServiceImplTest#testGetGoalReportMissingGoalReturnsNull
  • ProfileServiceImplTest#testExportProfilesPropertiesToCsv_missingSegmentDefinition_usesSegmentId
  • ProfileExportServiceImplTest
  • PropertyConditionOSQueryBuilderTest
  • mvn clean install -P integration-tests on CI
  • Rebuild Unomi Docker image and run unomi-rest-api-tests on 3.1-es, 3.1-os, 3.1-es-v2compat stacks

References

UNOMI-962, UNOMI-875, UNOMI-904

sergehuber and others added 3 commits July 13, 2026 09:19
…e endpoints.

Grant tenant admin roles when merging JAAS auth in V2 compat mode so endpoints
like GET /cxs/privacy/info can run AGGREGATE queries, and add an IT assertion.
Any successfully JAAS-authenticated Karaf user (not just admins) was being
merged with tenant-admin permissions for the default tenant. Deny access
unless the JAAS subject actually holds ROLE_UNOMI_ADMIN, and drop the now
unused TenantPrincipal import.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…arch queries

Return 404 for missing value types, goals, goal reports, and events instead
of server errors. Validate router export configuration, guard goal reports and
profile CSV export against missing metadata, align OpenSearch null property
values with Elasticsearch, inject UserListService contextManager, and add unit
tests for each fix area.
@sergehuber sergehuber changed the title [UNOMI-875] Fix V2 compat Karaf admin permissions on private endpoints [UNOMI-962] Harden 3.1 REST API: V2 compat auth, missing-resource 404s, and export validation Jul 13, 2026
@sergehuber sergehuber closed this Jul 13, 2026
@sergehuber
sergehuber deleted the fix/v2-compat-karaf-admin-permissions branch July 13, 2026 11:53
@sergehuber

Copy link
Copy Markdown
Contributor Author

Superseded by #823 after branch rename to fix/UNOMI-962-rest-api-hardening and widened scope for UNOMI-962.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant