mengw15 commented on code in PR #5258:
URL: https://github.com/apache/texera/pull/5258#discussion_r3443952454


##########
notebook-migration-service/src/main/scala/org/apache/texera/service/NotebookMigrationService.scala:
##########
@@ -0,0 +1,80 @@
+// 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 com.fasterxml.jackson.module.scala.DefaultScalaModule
+import com.typesafe.scalalogging.LazyLogging
+import io.dropwizard.configuration.{EnvironmentVariableSubstitutor, 
SubstitutingSourceProvider}
+import io.dropwizard.core.Application
+import io.dropwizard.core.setup.{Bootstrap, Environment}
+import org.apache.texera.common.config.StorageConfig
+import org.apache.texera.auth.RequestLoggingFilter
+import org.apache.texera.dao.SqlServer
+import java.nio.file.Path
+import org.apache.texera.service.resource.NotebookMigrationResource
+
+class NotebookMigrationService
+    extends Application[NotebookMigrationServiceConfiguration]
+    with LazyLogging {
+  override def initialize(bootstrap: 
Bootstrap[NotebookMigrationServiceConfiguration]): Unit = {
+    // enable environment variable substitution in YAML config
+    bootstrap.setConfigurationSourceProvider(
+      new SubstitutingSourceProvider(
+        bootstrap.getConfigurationSourceProvider,
+        new EnvironmentVariableSubstitutor(false)
+      )
+    )
+    // Register Scala module to Dropwizard default object mapper
+    bootstrap.getObjectMapper.registerModule(DefaultScalaModule)
+
+    SqlServer.initConnection(
+      StorageConfig.jdbcUrl,
+      StorageConfig.jdbcUsername,
+      StorageConfig.jdbcPassword
+    )
+  }
+
+  override def run(
+      configuration: NotebookMigrationServiceConfiguration,
+      environment: Environment
+  ): Unit = {
+    // Serve backend at /api
+    environment.jersey.setUrlPattern("/api/*")
+
+    environment.jersey.register(classOf[NotebookMigrationResource])
+
+    // Route request logs through SLF4J, controlled by TEXERA_SERVICE_LOG_LEVEL
+    RequestLoggingFilter.register(environment.getApplicationContext)
+  }

Review Comment:
   **All 5 existing Dropwizard services in this repo register the same auth 
stack in `run()`:**
   
   | Service | Registers JWT auth at |
   |---|---|
   | `AccessControlService` | line 80 
(`AuthDynamicFeature(classOf[JwtAuthFilter])`) |
   | `ConfigService` | line 71 |
   | `FileService` | line 92 |
   | `WorkflowCompilingService` | line 101 |
   | `ComputingUnitManagingService` | line 86 |
   
   Same 5 components every time: `AuthDynamicFeature(classOf[JwtAuthFilter])` + 
`RolesAllowedDynamicFeature` + 
`AuthValueFactoryProvider.Binder(classOf[SessionUser])` + 
`UnauthorizedExceptionMapper` + corresponding `@RolesAllowed` / `@Auth user: 
SessionUser` on the resources.
   
   **This service is the only one (1 of 6) without any of that.** Every 
endpoint is fully unauthenticated. `POST /store-notebook-and-mapping` takes 
`wid` from the request body and writes the user-uploaded notebook to that 
workflow, with no check that the caller owns workflow `wid`. Same for `fetch` 
and `set-notebook`. Any client with network access to `:9098` can read/write 
any user's workflow's notebook.
   
   The `NotebookMigrationResource` companion-object comment mentions a 
"per-user pod" k8s deployment model. But (a) the other 5 services run in k8s 
too and still do auth at the service layer, (b) it relies on gateway routing 
being airtight (no internal-cluster client ever talking directly to a pod), (c) 
even with per-user pods, `wid` ownership isn't enforced inside the pod either — 
so a misrouted request could clobber another user's notebook.
   
   Is the intent to add the auth stack in a later PR in the series, or is the 
design genuinely "gateway is the only auth boundary"? Worth either wiring auth 
here to match the other 5 services, or documenting the gateway-trusts model in 
a top-level service comment so the next contributor doesn't assume it's an 
oversight.



##########
notebook-migration-service/src/main/scala/org/apache/texera/service/NotebookMigrationService.scala:
##########
@@ -0,0 +1,80 @@
+// 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 com.fasterxml.jackson.module.scala.DefaultScalaModule
+import com.typesafe.scalalogging.LazyLogging
+import io.dropwizard.configuration.{EnvironmentVariableSubstitutor, 
SubstitutingSourceProvider}
+import io.dropwizard.core.Application
+import io.dropwizard.core.setup.{Bootstrap, Environment}
+import org.apache.texera.common.config.StorageConfig
+import org.apache.texera.auth.RequestLoggingFilter
+import org.apache.texera.dao.SqlServer
+import java.nio.file.Path
+import org.apache.texera.service.resource.NotebookMigrationResource
+
+class NotebookMigrationService
+    extends Application[NotebookMigrationServiceConfiguration]
+    with LazyLogging {
+  override def initialize(bootstrap: 
Bootstrap[NotebookMigrationServiceConfiguration]): Unit = {
+    // enable environment variable substitution in YAML config
+    bootstrap.setConfigurationSourceProvider(
+      new SubstitutingSourceProvider(
+        bootstrap.getConfigurationSourceProvider,
+        new EnvironmentVariableSubstitutor(false)
+      )
+    )
+    // Register Scala module to Dropwizard default object mapper
+    bootstrap.getObjectMapper.registerModule(DefaultScalaModule)
+
+    SqlServer.initConnection(
+      StorageConfig.jdbcUrl,
+      StorageConfig.jdbcUsername,
+      StorageConfig.jdbcPassword
+    )
+  }
+
+  override def run(
+      configuration: NotebookMigrationServiceConfiguration,
+      environment: Environment
+  ): Unit = {
+    // Serve backend at /api
+    environment.jersey.setUrlPattern("/api/*")
+
+    environment.jersey.register(classOf[NotebookMigrationResource])
+
+    // Route request logs through SLF4J, controlled by TEXERA_SERVICE_LOG_LEVEL
+    RequestLoggingFilter.register(environment.getApplicationContext)
+  }

Review Comment:
   **All 5 existing Dropwizard services in this repo register 
`HealthCheckResource` in their `run()`:**
   
   | Service | Line |
   |---|---|
   | `AccessControlService` | 74 |
   | `ConfigService` | 69 |
   | `FileService` | 88 |
   | `WorkflowCompilingService` | 59 |
   | `ComputingUnitManagingService` | 64 |
   
   This service is the only one (1 of 6) without it. Combined with 
`adminConnectors: []` in `notebook-migration-service-web-config.yaml` (which 
disables Dropwizard's built-in admin connector), the service has no external 
liveness/readiness endpoint — the future k8s Deployment manifest (later PR in 
the series) won't have a probe target without back-fill. Easy to add now 
(`environment.jersey.register(classOf[HealthCheckResource])`) to match the 
convention.



-- 
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]

Reply via email to