-
Notifications
You must be signed in to change notification settings - Fork 140
feat: Add Python Virtual Environment Support: Add k8s Gateway Configuration #5138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d997beb
661a04c
c38d532
6c36784
503cd74
9e1b8a5
4b6c6ca
419cc32
ec6508e
4a5f7ae
aa2c269
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ import com.fasterxml.jackson.module.scala.DefaultScalaModule | |
| import com.typesafe.scalalogging.LazyLogging | ||
| import jakarta.ws.rs.client.{Client, ClientBuilder, Entity} | ||
| import jakarta.ws.rs.core._ | ||
| import jakarta.ws.rs.{Consumes, GET, POST, Path, Produces} | ||
| import jakarta.ws.rs.{Consumes, DELETE, GET, POST, Path, Produces} | ||
| import org.apache.texera.auth.JwtParser.parseToken | ||
| import org.apache.texera.auth.SessionUser | ||
| import org.apache.texera.auth.util.{ComputingUnitAccess, HeaderField} | ||
|
|
@@ -43,6 +43,10 @@ object AccessControlResource extends LazyLogging { | |
| private val wsapiWorkflowWebsocket: Regex = """.*/wsapi/workflow-websocket.*""".r | ||
| private val apiExecutionsStats: Regex = """.*/api/executions/[0-9]+/stats/[0-9]+.*""".r | ||
| private val apiExecutionsResultExport: Regex = """.*/api/executions/result/export.*""".r | ||
| private val pveRoute: Regex = """.*/(?:api/|wsapi/)?pve(?:/.*)?""".r | ||
| // Path patterns whose cuid lives in the URL path rather than the query string. | ||
| private val pvePvesCuidPath: Regex = """.*/pve/pves/([0-9]+).*""".r | ||
| private val pvePackagesCuidPath: Regex = """.*/pve/([0-9]+)/[^/]+/packages/.+""".r | ||
|
|
||
| /** | ||
| * Authorize the request based on the path and headers. | ||
|
|
@@ -60,7 +64,8 @@ object AccessControlResource extends LazyLogging { | |
| logger.info(s"Authorizing request for path: $path") | ||
|
|
||
| path match { | ||
| case wsapiWorkflowWebsocket() | apiExecutionsStats() | apiExecutionsResultExport() => | ||
| case wsapiWorkflowWebsocket() | apiExecutionsStats() | apiExecutionsResultExport() | | ||
| pveRoute() => | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PR description says "Tested manually." Worth adding a small unit test on
|
||
| checkComputingUnitAccess(uriInfo, headers, bodyOpt) | ||
| case _ => | ||
| logger.warn(s"No authorization logic for path: $path. Denying access.") | ||
|
|
@@ -95,7 +100,14 @@ object AccessControlResource extends LazyLogging { | |
| qToken.orElse(hToken).orElse(bToken).getOrElse("") | ||
| } | ||
| logger.info(s"token extracted from request $token") | ||
| val cuid = queryParams.getOrElse("cuid", "") | ||
|
|
||
| val cuid = queryParams.get("cuid").filter(_.nonEmpty).getOrElse { | ||
| uriInfo.getPath match { | ||
| case pvePvesCuidPath(c) => c | ||
| case pvePackagesCuidPath(c) => c | ||
| case _ => "" | ||
| } | ||
| } | ||
| val cuidInt = | ||
| try { | ||
| cuid.toInt | ||
|
|
@@ -213,6 +225,15 @@ class AccessControlResource extends LazyLogging { | |
| logger.info("Request body: " + body) | ||
| AccessControlResource.authorize(uriInfo, headers, Option(body).map(_.trim).filter(_.nonEmpty)) | ||
| } | ||
|
|
||
| @DELETE | ||
| @Path("/{path:.*}") | ||
| def authorizeDelete( | ||
| @Context uriInfo: UriInfo, | ||
| @Context headers: HttpHeaders | ||
| ): Response = { | ||
| AccessControlResource.authorize(uriInfo, headers) | ||
| } | ||
| } | ||
|
|
||
| @Path("/chat") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,12 +36,10 @@ class PveResource { | |
| @GET | ||
| @Path("/system") | ||
| @Produces(Array(MediaType.APPLICATION_JSON)) | ||
| def getSystemPackages: util.Map[String, util.List[String]] = { | ||
| def getSystemPackages( | ||
| @QueryParam("isLocal") isLocal: Boolean | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| ): util.Map[String, util.List[String]] = { | ||
| try { | ||
|
|
||
| // TODO: Support Kubernetes environment handling | ||
| val isLocal = true | ||
|
|
||
| val systemPkgs = | ||
| PveManager.getSystemPackages(isLocal).toList.asJava | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested by Claude:
.*/(?:api/|wsapi/)?pve(?:/.*)?is overly permissive — the leading.*/will match any path ending in…/pveor…/pve/anything, not just the expected/api/pve//wsapi/pve//pveshapes. Consistent with howwsapiWorkflowWebsocket/apiExecutionsStatsare written above, so not out of line for this file, but the PVE routes here are well-defined enough to anchor more tightly, e.g.:Also applies to
pvePvesCuidPathandpvePackagesCuidPathbelow. Worth double-checking whetheruriInfo.getPathhere includes theauth/prefix from the enclosing@Path("/auth")resource — your manual test probably already covered this, but the regex shape depends on it.