Yicong-Huang commented on code in PR #5199:
URL: https://github.com/apache/texera/pull/5199#discussion_r3330685743
##########
config-service/src/main/scala/org/apache/texera/service/ConfigService.scala:
##########
@@ -71,6 +72,9 @@ class ConfigService extends
Application[ConfigServiceConfiguration] with LazyLog
new
io.dropwizard.auth.AuthValueFactoryProvider.Binder(classOf[SessionUser])
)
+ // Enforce @RolesAllowed annotations on resource methods
+ environment.jersey.register(classOf[RolesAllowedDynamicFeature])
Review Comment:
Done in 91f589b66 — extracted `ConfigService.registerAuthFeatures` mirroring
the other two services. `ConfigServiceRunSpec` now targets the helper directly
the same way the peer specs do, which also lets it drop the
`intercept[Exception]` / SqlServer-throws short-circuit it needed before.
##########
computing-unit-managing-service/src/test/scala/org/apache/texera/service/ComputingUnitManagingServiceRunSpec.scala:
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.service
+
+import io.dropwizard.auth.{AuthDynamicFeature, AuthValueFactoryProvider}
+import io.dropwizard.core.setup.Environment
+import io.dropwizard.jersey.setup.JerseyEnvironment
+import org.glassfish.jersey.server.filter.RolesAllowedDynamicFeature
+import org.mockito.Mockito.{mock, verify, when}
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
+
+class ComputingUnitManagingServiceRunSpec extends AnyFlatSpec with Matchers {
+
+ // Verifies that the @RolesAllowed annotations on resource methods are
actually
+ // enforced by Jersey, which requires RolesAllowedDynamicFeature,
AuthDynamicFeature,
+ // and AuthValueFactoryProvider.Binder to be registered on the Jersey
environment.
+ "ComputingUnitManagingService.registerAuthFeatures" should "register auth +
RolesAllowedDynamicFeature on the Jersey environment" in {
Review Comment:
Agreed — these RunSpec mocks only prove the registration line ran, not that
any specific endpoint is actually protected, and a new endpoint missing a role
annotation would slip past them. Filed #5301 to add a startup-time scan that
fails fast when a Jersey-registered HTTP method has no `@RolesAllowed` /
`@PermitAll` / `@DenyAll`. Keeping the RunSpec tests as-is in this PR to keep
the scope to the #5049 reapply + bootstrap fix.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]