Repository navigation
feat(auth): enforce role annotation coverage at service startup - #5743
Conversation
service startup
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #5743 +/- ##
============================================
- Coverage 54.60% 54.58% -0.02%
+ Complexity 2927 2925 -2
============================================
Files 1109 1111 +2
Lines 42828 42837 +9
Branches 4608 4611 +3
============================================
- Hits 23385 23383 -2
- Misses 18081 18088 +7
- Partials 1362 1366 +4
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
| config | throughput | MB/s | latency | max Δ latest / 7d | |
|---|---|---|---|---|---|
| 🔴 | bs=10 sw=10 sl=64 | 389 | 0.237 | 24,888/40,334/40,334 us | 🔴 +11.1% / 🔴 +15.3% |
| ⚪ | bs=100 sw=10 sl=64 | 800 | 0.488 | 122,157/146,244/146,244 us | ⚪ within ±5% / 🔴 -10.4% |
| ⚪ | bs=1000 sw=10 sl=64 | 926 | 0.565 | 1,080,422/1,116,583/1,116,583 us | ⚪ within ±5% / 🔴 -11.1% |
Baseline details
Latest main 1c580e5 from same runner
| config | metric | PR | latest main | 7d avg | Δ latest | Δ 7d |
|---|---|---|---|---|---|---|
| bs=10 sw=10 sl=64 | throughput | 389 tuples/sec | 414 tuples/sec | 410.82 tuples/sec | -6.0% | -5.3% |
| bs=10 sw=10 sl=64 | MB/s | 0.237 MB/s | 0.252 MB/s | 0.251 MB/s | -6.0% | -5.5% |
| bs=10 sw=10 sl=64 | p50 | 24,888 us | 22,411 us | 23,785 us | +11.1% | +4.6% |
| bs=10 sw=10 sl=64 | p95 | 40,334 us | 37,449 us | 34,980 us | +7.7% | +15.3% |
| bs=10 sw=10 sl=64 | p99 | 40,334 us | 37,449 us | 34,980 us | +7.7% | +15.3% |
| bs=100 sw=10 sl=64 | throughput | 800 tuples/sec | 819 tuples/sec | 891.94 tuples/sec | -2.3% | -10.3% |
| bs=100 sw=10 sl=64 | MB/s | 0.488 MB/s | 0.5 MB/s | 0.544 MB/s | -2.4% | -10.4% |
| bs=100 sw=10 sl=64 | p50 | 122,157 us | 120,488 us | 112,277 us | +1.4% | +8.8% |
| bs=100 sw=10 sl=64 | p95 | 146,244 us | 142,223 us | 139,802 us | +2.8% | +4.6% |
| bs=100 sw=10 sl=64 | p99 | 146,244 us | 142,223 us | 139,802 us | +2.8% | +4.6% |
| bs=1000 sw=10 sl=64 | throughput | 926 tuples/sec | 901 tuples/sec | 1,041 tuples/sec | +2.8% | -11.0% |
| bs=1000 sw=10 sl=64 | MB/s | 0.565 MB/s | 0.55 MB/s | 0.635 MB/s | +2.7% | -11.1% |
| bs=1000 sw=10 sl=64 | p50 | 1,080,422 us | 1,115,675 us | 972,714 us | -3.2% | +11.1% |
| bs=1000 sw=10 sl=64 | p95 | 1,116,583 us | 1,166,961 us | 1,023,057 us | -4.3% | +9.1% |
| bs=1000 sw=10 sl=64 | p99 | 1,116,583 us | 1,166,961 us | 1,023,057 us | -4.3% | +9.1% |
Raw CSV
config_idx,batch_size,schema_width,string_len,num_batches,total_ms,total_tuples,total_bytes,tuples_per_sec,mb_per_sec,lat_p50_us,lat_p95_us,lat_p99_us
0,10,10,64,20,514.17,200,128000,389,0.237,24888.17,40333.51,40333.51
1,100,10,64,20,2499.14,2000,1280000,800,0.488,122157.13,146244.45,146244.45
2,1000,10,64,20,21604.50,20000,12800000,926,0.565,1080422.05,1116582.64,1116582.64|
/request-review @aglinxinyuan |
Automated Reviewer SuggestionsBased on the
|
enforcement into common/auth
89cc561 to
53bf102
Compare
… added new test case for coverage
There was a problem hiding this comment.
Pull request overview
Adds a shared auth startup safeguard to ensure every JAX-RS HTTP endpoint in the five Dropwizard microservices explicitly declares access control, failing service boot if any endpoint is left unintentionally public.
Changes:
- Introduces
RoleAnnotationEnforcer(reflection-based scan of HTTP-mapped methods) and wires it into service startup after resource registration. - Centralizes common Dropwizard/Jersey auth registrations into
AuthFeatures.register(environment)and updates services to use it. - Adds unit tests for the enforcer and per-service “all registered resources declare access control” guard tests.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
common/auth/src/main/scala/org/apache/texera/auth/RoleAnnotationEnforcer.scala |
Implements reflection-based detection of unannotated HTTP endpoints and enforcement (log + throw). |
common/auth/src/main/scala/org/apache/texera/auth/AuthFeatures.scala |
Adds a shared helper to register the standard JWT/auth stack across services. |
common/auth/src/test/scala/org/apache/texera/auth/RoleAnnotationEnforcerSpec.scala |
Adds coverage for endpoint scanning/enforcement behavior (including ResourceConfig overload). |
common/auth/src/test/scala/org/apache/texera/auth/AuthFeaturesSpec.scala |
Verifies shared auth feature registrations once (instead of per-service). |
common/auth/build.sbt |
Adds provided deps for Dropwizard/Jersey types and Mockito for the new tests. |
config-service/src/main/scala/org/apache/texera/service/ConfigService.scala |
Uses AuthFeatures.register and enforces role-annotation coverage at startup. |
config-service/src/test/scala/org/apache/texera/service/ConfigServiceRunSpec.scala |
Replaces auth-registration mock test with “resources must be access-controlled” guard. |
access-control-service/src/main/scala/org/apache/texera/service/AccessControlService.scala |
Uses AuthFeatures.register and enforces role-annotation coverage at startup. |
access-control-service/src/test/scala/org/apache/texera/service/AccessControlServiceRunSpec.scala |
Keeps run-time registration assertions and adds resource access-control guard. |
computing-unit-managing-service/src/main/scala/org/apache/texera/service/ComputingUnitManagingService.scala |
Uses AuthFeatures.register and enforces role-annotation coverage at startup. |
computing-unit-managing-service/src/test/scala/org/apache/texera/service/ComputingUnitManagingServiceRunSpec.scala |
Replaces auth-registration mock test with resource access-control guard. |
workflow-compiling-service/src/main/scala/org/apache/texera/service/WorkflowCompilingService.scala |
Uses AuthFeatures.register and enforces role-annotation coverage at startup. |
workflow-compiling-service/src/test/scala/org/apache/texera/service/WorkflowCompilingServiceRunSpec.scala |
Replaces auth-registration mock test with resource access-control guard. |
file-service/src/main/scala/org/apache/texera/service/FileService.scala |
Uses AuthFeatures.register and enforces role-annotation coverage at startup. |
file-service/src/test/scala/org/apache/texera/service/FileServiceRunSpec.scala |
Adds a new resource access-control guard test for file-service. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <[email protected]> Signed-off-by: Matthew B. <[email protected]>
What changes were proposed in this PR?
RoleAnnotationEnforcerincommon/auth: a pure, reflection-based check whosefindUnannotatedEndpointsflags every HTTP-mapped resource method (detected generically via the JAX-RS@HttpMethodmeta-annotation, covering GET/POST/PUT/DELETE/PATCH/HEAD/OPTIONS and custom verbs) that lacks@RolesAllowed/@PermitAll/@DenyAllat either the method or its resource class.enforceRoleAnnotations(environment)once every resource has been registered inrun(), reading the live JerseyResourceConfig; an unannotated endpoint now logs and throwsIllegalStateExceptionso the service fails to boot instead of exposing a silent public endpoint.RoleAnnotationEnforcerSpecfor the enforcer logic plus a per-service guard test (over each service's real registered resources) so a forgotten annotation fails in CI without needing a full boot.Any related issues, documentation, discussions?
Closes: #5742
How was this PR tested?
sbt "Auth/testOnly *RoleAnnotationEnforcerSpec", expect 16 cases green. Coverage offindUnannotatedEndpoints: all-annotated passes; an unannotated@GETis flagged; class-level annotation covers methods;@PermitAll/@DenyAllaccepted; non-HTTP methods ignored; no resources returns empty; holes across multiple resources reported as fully-qualifiedClass#method; verbs beyond GET/POST/DELETE (@PUT/@PATCH/@HEAD/@OPTIONS) detected via the@HttpMethodmeta-annotation; a security annotation inherited from a superclass method counts as covered; a subclass class-level annotation covers an inherited endpoint; an inherited unannotated endpoint is flagged against the scanned subclass; duplicate resources are de-duplicated. Coverage ofenforce: throws (message names the service and offending method, and lists every offender) and does not throw on clean input or empty input. Verified locally.sbt "ConfigService/testOnly *ConfigServiceRunSpec"(and the equivalentAccessControlService/ComputingUnitManagingService/WorkflowCompilingService/FileServiceRunSpecs); expect the new "registered resources should all declare access control" guard to pass, confirming each service's real endpoints are fully annotated.@GETwith no role annotation onto any wired resource and start the service (or run that service's RunSpec); expect anIllegalStateExceptionnamingClass#methodand a failed boot.*RunSpeccases cannot mockJerseyEnvironmentand file-service tests hit a JaCoCo 0.8.11 instrumentation crash on an unrelated class; these are pre-existing toolchain issues (baseline fails identically) and run on CI's supported JDK. The new non-mock guard tests were verified locally for config/access-control/computing-unit-managing/workflow-compiling.Was this PR authored or co-authored using generative AI tooling?
Co-authored with Claude Opus 4.8 in compliance with ASF