Repository navigation
feat(access-control-service): add access-control-service to authorize the requests to /wsapi and Computing Unit endpoints - #3598
Merged
Merged
Conversation
# Conflicts: # core/computing-unit-managing-service/src/main/scala/edu/uci/ics/texera/service/resource/ComputingUnitManagingResource.scala
chenlica
reviewed
Oct 5, 2025
chenlica
left a comment
Contributor
There was a problem hiding this comment.
Please check those comments.
Contributor
|
This PR has 16 files. Can we divide it into smaller PRs? |
aicam
added a commit
that referenced
this pull request
Oct 8, 2025
## Update This PR fixes formatting issues that introduce redundant file changes in the core [PR](#3598).
SarahAsad23
pushed a commit
to madisonmlin/texera
that referenced
this pull request
May 20, 2026
…ro service (apache#3767) ## Overview This PR is fixing the first part of [apache#3634](apache#3634). The full [PR](apache#3598) had so many changes so we broke it down into two PRs. This PR is the first one that introduce Access Control Service only without its usage in any part of the system. ## Test cases - Empty authorization token - Wrong CUID format - Request access for a user without access to the computing unit - Request access for a user with access to the computing unit ## Changes Currently, the folder named `access-control-service` is added with its dependencies to `auth` folder. Currently, it has test cases to make sure its functionality is working correctly. <img width="1382" height="554" alt="Screenshot from 2025-09-25 15-46-55" src="https://github.com/user-attachments/assets/25da27b4-5018-4a47-bccc-6ba2adacbfb4" /> | Component/Flow | File | Description | | :--- | :--- | :--- | | **New `AccessControl` Service** | `core/access-control-service/...` | A new Dropwizard-based microservice responsible for authorizing user requests to computing units. This includes its build configuration, application setup (`AccessControlService.scala`), configuration model (`AccessControlServiceConfiguration.scala`), authorization logic, REST endpoint (`AccessControlResource.scala`), and unit tests (`AccessControlResourceSpec.scala`). | | **Database Access Logic** | `core/auth/src/main/scala/edu/uci/ics/texera/auth/util/ComputingUnitAccess.scala` | Implements the logic to query the PostgreSQL database and determine a user's access privilege (`READ`, `WRITE`, `NONE`) for a given Computing Unit. | | | `core/auth/src/main/scala/edu/uci/ics/texera/auth/util/HeaderField.scala` | Defines constants for the custom HTTP headers (`x-user-cu-access`, `x-user-id`, etc.) that are injected by the Access Control Service. |
SarahAsad23
pushed a commit
to madisonmlin/texera
that referenced
this pull request
May 20, 2026
## Update This PR fixes formatting issues that introduce redundant file changes in the core [PR](apache#3598).
SarahAsad23
pushed a commit
to madisonmlin/texera
that referenced
this pull request
May 20, 2026
…ze the requests to `/wsapi` and `Computing Unit` endpoints (apache#3598) ## Access Control Service This service is currently used only by envoy as authorization service. It act as a third party service to authorize any request sent to the computing unit to get socket connection through `/wsapi`. It parses the `user-token` from URL parameters and then check user access to the computing unit by checking the database and add the corresponding information to the following headers: - x-user-cu-access - x-user-id - x-user-name - x-user-email If the service can not parse the token or fail for any reason, the access to computing unit is denied by envoy. If the authorization succeed, the user is directly connected to computing unit using `Upgrade` on the first `HTTP` handshake request so the latency will not change. ## The new connection flow <img width="1282" height="577" alt="489656839-e09b06ee-3915-4c18-9584-e880bc06011d" src="https://github.com/user-attachments/assets/f7b0d29e-f30b-4e7f-9a0d-966f52d8d48a" /> 1. A user initiates an `HTTP` request to connect to a specific Computing Unit. 2. The request is first routed through the **Gateway** to **Envoy**. 3. Envoy pauses the request and sends a query to the **Access Control Service** to get an authorization decision. 4. The Access Control Service verifies the user's token and checks a PostgreSQL database to see if the user has the necessary permissions for the target Computing Unit. 5. **If authorized**, the service injects specific HTTP headers (`x-user-cu-access`, `x-user-id`, `x-user-name`) into the request and sends an approval back to Envoy. 6. Envoy then forwards the approved request to the Computing Unit. 7. The connection is then upgraded to a WebSocket, establishing a secure, interactive session. If authorization fails at any point, Envoy immediately denies the connection request, and the user is prevented from accessing the Computing Unit. This new process provides **enhanced security**, a **centralized authorization logic**, and is designed to have **no performance impact** on the established WebSocket connection since the check is performed only on the initial handshake. ## Summary of file changes | Component/Flow | File | Description | | :--- | :--- | :--- | | **Database Access Logic** | `core/auth/src/main/scala/edu/uci/ics/texera/auth/util/ComputingUnitAccess.scala` | Implements the logic to query the PostgreSQL database and determine a user's access privilege (`READ`, `WRITE`, `NONE`) for a given Computing Unit. | | | `core/auth/src/main/scala/edu/uci/ics/texera/auth/util/HeaderField.scala` | Defines constants for the custom HTTP headers (`x-user-cu-access`, `x-user-id`, etc.) that are injected by the Access Control Service. | | **WebSocket Connection Handling** | `core/amber/src/main/scala/edu/uci/ics/texera/web/ServletAwareConfigurator.scala` | Modified to read the new authorization headers during the WebSocket handshake. If headers are present, it creates the `User` object from them; otherwise, it falls back to the old method of parsing the JWT from URL parameters for single-node mode. | | | `core/amber/src/main/scala/edu/uci/ics/texera/web/SessionState.scala` | Updated to store the user's access privilege level for the current computing unit within the session. | | | `core/amber/src/main/scala/edu/uci/ics/texera/web/resource/WorkflowWebsocketResource.scala` | Enforces the access control by checking if the user has `WRITE` privilege before allowing a `WorkflowExecuteRequest`. | | **Deployment & Routing** | `deployment/access-control-service.dockerfile` | New Dockerfile for building and containerizing the Access Control Service. | | | `deployment/k8s/texera-helmchart/templates/access-control-service-deployment.yaml` | New Kubernetes manifest to deploy the Access Control Service. | | | `deployment/k8s/texera-helmchart/templates/access-control-service-service.yaml` | New Kubernetes service manifest to expose the Access Control Service within the cluster. | | | `deployment/k8s/texera-helmchart/templates/envoy-config.yaml` | **Key change:** Configures Envoy to use the new service as an external authorization filter (`ext_authz`). It intercepts relevant requests, forwards them for an authorization check, and then passes the injected headers to the upstream service (AmberMaster). | | | `deployment/k8s/texera-helmchart/values.yaml` | Adds the configuration parameters for the new Access Control Service to the Helm chart. | | **Frontend UI** | `core/gui/src/app/workspace/component/menu/menu.component.ts` & `.html`| The frontend is updated to disable the "Run" button if the connected user does not have `WRITE` access to the selected Computing Unit, providing immediate visual feedback. | | **Build & Configuration** | `core/build.sbt` | The root SBT build file is updated to include the new `AccessControlService` module. | | | `core/config/src/main/scala/edu/uci/ics/amber/util/PathUtils.scala` | Adds a path helper for the new service's directory structure. | --------- Co-authored-by: Ali Risheh <[email protected]>
bobbai00
pushed a commit
to bobbai00/texera
that referenced
this pull request
Jun 16, 2026
…nd use Envoy Gateway for distributed CUs (apache#5629) ### What changes were proposed in this PR? Make the in-cluster address of a computing unit come from a single source of truth — the URI recorded when its pod is created — and ensure that URI is complete (includes the port). This lets the gateway route a user to a computing unit located **anywhere it can reach** (in the local cluster, another cluster, or an external host), instead of being limited to a reconstructed in-cluster address. See apache#5630. Two related changes: **1. Include the port in the generated pod URI** (`computing-unit-managing-service`) `KubernetesClient.generatePodURI` builds the address stored as the computing unit's `uri` (via `setUri` in `ComputingUnitManagingResource`) and returned to clients as `nodeAddresses`. The pod's container listens on `KubernetesConfig.computeUnitPortNumber` (declared with `withContainerPort(...)` in the same file), but the generated URI omitted the port, so the persisted address was not directly connectable. The port is now appended: ```scala s"...svc.cluster.local:${KubernetesConfig.computeUnitPortNumber}" ``` **2. Route using the recorded URI** (`access-control-service`) `AccessControlResource` rebuilt the computing unit's address from `KubernetesConfig` on every authorization request, duplicating the construction logic in `generatePodURI` and pinning every CU to the local cluster. It now reads the URI recorded for the unit and returns it as the `Host` for the gateway to route to. If no URI has been recorded, the unit is not routable and the request is **refused with `403`** (no in-cluster fallback, per review). ### Routing flow The access-control service is the gateway's external authorizer; the `Host` it returns is the upstream Envoy forwards the (upgraded) connection to. Because that host comes from the unit's recorded URI, the same gateway can reach computing units in different locations: ```mermaid flowchart LR FE["Frontend<br/>(/wsapi?cuid=N)"] --> GW["Envoy Gateway"] GW -. "ext-auth: authorize + get Host" .-> ACS["access-control-service"] ACS -- "read recorded uri for CU N" --> DB[("workflow_computing_unit")] ACS -- "Host = recorded uri<br/>(or 403 if none)" --> GW GW == "dynamic forward proxy<br/>to returned Host" ==> R{Where the CU lives} R --> CU1["In-cluster CU pod<br/>computing-unit-N...svc.cluster.local:port"] R --> CU2["CU in another cluster"] R --> CU3["External / remote CU host:port"] ``` ### Any related issues, documentation, discussions? - Closes apache#5630. - Builds on the Envoy Gateway / ext-auth routing introduced in apache#4191 (unified Envoy Gateway) and apache#3598 (access-control-service as the ext-auth service for computing-unit traffic). ### How was this PR tested? On live deployment. <img width="1835" height="960" alt="Screenshot from 2026-06-13 13-31-00" src="https://github.com/user-attachments/assets/d56a48f9-b99d-4d36-827a-0a4ce54995fd" /> ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Opus 4.8) --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
yangzhang75
pushed a commit
to yangzhang75/texera
that referenced
this pull request
Jun 22, 2026
…ro service (apache#3767) ## Overview This PR is fixing the first part of [apache#3634](apache#3634). The full [PR](apache#3598) had so many changes so we broke it down into two PRs. This PR is the first one that introduce Access Control Service only without its usage in any part of the system. ## Test cases - Empty authorization token - Wrong CUID format - Request access for a user without access to the computing unit - Request access for a user with access to the computing unit ## Changes Currently, the folder named `access-control-service` is added with its dependencies to `auth` folder. Currently, it has test cases to make sure its functionality is working correctly. <img width="1382" height="554" alt="Screenshot from 2025-09-25 15-46-55" src="https://github.com/user-attachments/assets/25da27b4-5018-4a47-bccc-6ba2adacbfb4" /> | Component/Flow | File | Description | | :--- | :--- | :--- | | **New `AccessControl` Service** | `core/access-control-service/...` | A new Dropwizard-based microservice responsible for authorizing user requests to computing units. This includes its build configuration, application setup (`AccessControlService.scala`), configuration model (`AccessControlServiceConfiguration.scala`), authorization logic, REST endpoint (`AccessControlResource.scala`), and unit tests (`AccessControlResourceSpec.scala`). | | **Database Access Logic** | `core/auth/src/main/scala/edu/uci/ics/texera/auth/util/ComputingUnitAccess.scala` | Implements the logic to query the PostgreSQL database and determine a user's access privilege (`READ`, `WRITE`, `NONE`) for a given Computing Unit. | | | `core/auth/src/main/scala/edu/uci/ics/texera/auth/util/HeaderField.scala` | Defines constants for the custom HTTP headers (`x-user-cu-access`, `x-user-id`, etc.) that are injected by the Access Control Service. |
yangzhang75
pushed a commit
to yangzhang75/texera
that referenced
this pull request
Jun 22, 2026
## Update This PR fixes formatting issues that introduce redundant file changes in the core [PR](apache#3598).
yangzhang75
pushed a commit
to yangzhang75/texera
that referenced
this pull request
Jun 22, 2026
…ze the requests to `/wsapi` and `Computing Unit` endpoints (apache#3598) ## Access Control Service This service is currently used only by envoy as authorization service. It act as a third party service to authorize any request sent to the computing unit to get socket connection through `/wsapi`. It parses the `user-token` from URL parameters and then check user access to the computing unit by checking the database and add the corresponding information to the following headers: - x-user-cu-access - x-user-id - x-user-name - x-user-email If the service can not parse the token or fail for any reason, the access to computing unit is denied by envoy. If the authorization succeed, the user is directly connected to computing unit using `Upgrade` on the first `HTTP` handshake request so the latency will not change. ## The new connection flow <img width="1282" height="577" alt="489656839-e09b06ee-3915-4c18-9584-e880bc06011d" src="https://github.com/user-attachments/assets/f7b0d29e-f30b-4e7f-9a0d-966f52d8d48a" /> 1. A user initiates an `HTTP` request to connect to a specific Computing Unit. 2. The request is first routed through the **Gateway** to **Envoy**. 3. Envoy pauses the request and sends a query to the **Access Control Service** to get an authorization decision. 4. The Access Control Service verifies the user's token and checks a PostgreSQL database to see if the user has the necessary permissions for the target Computing Unit. 5. **If authorized**, the service injects specific HTTP headers (`x-user-cu-access`, `x-user-id`, `x-user-name`) into the request and sends an approval back to Envoy. 6. Envoy then forwards the approved request to the Computing Unit. 7. The connection is then upgraded to a WebSocket, establishing a secure, interactive session. If authorization fails at any point, Envoy immediately denies the connection request, and the user is prevented from accessing the Computing Unit. This new process provides **enhanced security**, a **centralized authorization logic**, and is designed to have **no performance impact** on the established WebSocket connection since the check is performed only on the initial handshake. ## Summary of file changes | Component/Flow | File | Description | | :--- | :--- | :--- | | **Database Access Logic** | `core/auth/src/main/scala/edu/uci/ics/texera/auth/util/ComputingUnitAccess.scala` | Implements the logic to query the PostgreSQL database and determine a user's access privilege (`READ`, `WRITE`, `NONE`) for a given Computing Unit. | | | `core/auth/src/main/scala/edu/uci/ics/texera/auth/util/HeaderField.scala` | Defines constants for the custom HTTP headers (`x-user-cu-access`, `x-user-id`, etc.) that are injected by the Access Control Service. | | **WebSocket Connection Handling** | `core/amber/src/main/scala/edu/uci/ics/texera/web/ServletAwareConfigurator.scala` | Modified to read the new authorization headers during the WebSocket handshake. If headers are present, it creates the `User` object from them; otherwise, it falls back to the old method of parsing the JWT from URL parameters for single-node mode. | | | `core/amber/src/main/scala/edu/uci/ics/texera/web/SessionState.scala` | Updated to store the user's access privilege level for the current computing unit within the session. | | | `core/amber/src/main/scala/edu/uci/ics/texera/web/resource/WorkflowWebsocketResource.scala` | Enforces the access control by checking if the user has `WRITE` privilege before allowing a `WorkflowExecuteRequest`. | | **Deployment & Routing** | `deployment/access-control-service.dockerfile` | New Dockerfile for building and containerizing the Access Control Service. | | | `deployment/k8s/texera-helmchart/templates/access-control-service-deployment.yaml` | New Kubernetes manifest to deploy the Access Control Service. | | | `deployment/k8s/texera-helmchart/templates/access-control-service-service.yaml` | New Kubernetes service manifest to expose the Access Control Service within the cluster. | | | `deployment/k8s/texera-helmchart/templates/envoy-config.yaml` | **Key change:** Configures Envoy to use the new service as an external authorization filter (`ext_authz`). It intercepts relevant requests, forwards them for an authorization check, and then passes the injected headers to the upstream service (AmberMaster). | | | `deployment/k8s/texera-helmchart/values.yaml` | Adds the configuration parameters for the new Access Control Service to the Helm chart. | | **Frontend UI** | `core/gui/src/app/workspace/component/menu/menu.component.ts` & `.html`| The frontend is updated to disable the "Run" button if the connected user does not have `WRITE` access to the selected Computing Unit, providing immediate visual feedback. | | **Build & Configuration** | `core/build.sbt` | The root SBT build file is updated to include the new `AccessControlService` module. | | | `core/config/src/main/scala/edu/uci/ics/amber/util/PathUtils.scala` | Adds a path helper for the new service's directory structure. | --------- Co-authored-by: Ali Risheh <[email protected]>
yangzhang75
pushed a commit
to yangzhang75/texera
that referenced
this pull request
Jun 22, 2026
…nd use Envoy Gateway for distributed CUs (apache#5629) ### What changes were proposed in this PR? Make the in-cluster address of a computing unit come from a single source of truth — the URI recorded when its pod is created — and ensure that URI is complete (includes the port). This lets the gateway route a user to a computing unit located **anywhere it can reach** (in the local cluster, another cluster, or an external host), instead of being limited to a reconstructed in-cluster address. See apache#5630. Two related changes: **1. Include the port in the generated pod URI** (`computing-unit-managing-service`) `KubernetesClient.generatePodURI` builds the address stored as the computing unit's `uri` (via `setUri` in `ComputingUnitManagingResource`) and returned to clients as `nodeAddresses`. The pod's container listens on `KubernetesConfig.computeUnitPortNumber` (declared with `withContainerPort(...)` in the same file), but the generated URI omitted the port, so the persisted address was not directly connectable. The port is now appended: ```scala s"...svc.cluster.local:${KubernetesConfig.computeUnitPortNumber}" ``` **2. Route using the recorded URI** (`access-control-service`) `AccessControlResource` rebuilt the computing unit's address from `KubernetesConfig` on every authorization request, duplicating the construction logic in `generatePodURI` and pinning every CU to the local cluster. It now reads the URI recorded for the unit and returns it as the `Host` for the gateway to route to. If no URI has been recorded, the unit is not routable and the request is **refused with `403`** (no in-cluster fallback, per review). ### Routing flow The access-control service is the gateway's external authorizer; the `Host` it returns is the upstream Envoy forwards the (upgraded) connection to. Because that host comes from the unit's recorded URI, the same gateway can reach computing units in different locations: ```mermaid flowchart LR FE["Frontend<br/>(/wsapi?cuid=N)"] --> GW["Envoy Gateway"] GW -. "ext-auth: authorize + get Host" .-> ACS["access-control-service"] ACS -- "read recorded uri for CU N" --> DB[("workflow_computing_unit")] ACS -- "Host = recorded uri<br/>(or 403 if none)" --> GW GW == "dynamic forward proxy<br/>to returned Host" ==> R{Where the CU lives} R --> CU1["In-cluster CU pod<br/>computing-unit-N...svc.cluster.local:port"] R --> CU2["CU in another cluster"] R --> CU3["External / remote CU host:port"] ``` ### Any related issues, documentation, discussions? - Closes apache#5630. - Builds on the Envoy Gateway / ext-auth routing introduced in apache#4191 (unified Envoy Gateway) and apache#3598 (access-control-service as the ext-auth service for computing-unit traffic). ### How was this PR tested? On live deployment. <img width="1835" height="960" alt="Screenshot from 2026-06-13 13-31-00" src="https://github.com/user-attachments/assets/d56a48f9-b99d-4d36-827a-0a4ce54995fd" /> ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Opus 4.8) --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Access Control Service
This service is currently used only by envoy as authorization service. It act as a third party service to authorize any request sent to the computing unit to get socket connection through
/wsapi. It parses theuser-tokenfrom URL parameters and then check user access to the computing unit by checking the database and add the corresponding information to the following headers:If the service can not parse the token or fail for any reason, the access to computing unit is denied by envoy. If the authorization succeed, the user is directly connected to computing unit using
Upgradeon the firstHTTPhandshake request so the latency will not change.The new connection flow
HTTPrequest to connect to a specific Computing Unit.x-user-cu-access,x-user-id,x-user-name) into the request and sends an approval back to Envoy.If authorization fails at any point, Envoy immediately denies the connection request, and the user is prevented from accessing the Computing Unit. This new process provides enhanced security, a centralized authorization logic, and is designed to have no performance impact on the established WebSocket connection since the check is performed only on the initial handshake.
Summary of file changes
core/auth/src/main/scala/edu/uci/ics/texera/auth/util/ComputingUnitAccess.scalaREAD,WRITE,NONE) for a given Computing Unit.core/auth/src/main/scala/edu/uci/ics/texera/auth/util/HeaderField.scalax-user-cu-access,x-user-id, etc.) that are injected by the Access Control Service.core/amber/src/main/scala/edu/uci/ics/texera/web/ServletAwareConfigurator.scalaUserobject from them; otherwise, it falls back to the old method of parsing the JWT from URL parameters for single-node mode.core/amber/src/main/scala/edu/uci/ics/texera/web/SessionState.scalacore/amber/src/main/scala/edu/uci/ics/texera/web/resource/WorkflowWebsocketResource.scalaWRITEprivilege before allowing aWorkflowExecuteRequest.deployment/access-control-service.dockerfiledeployment/k8s/texera-helmchart/templates/access-control-service-deployment.yamldeployment/k8s/texera-helmchart/templates/access-control-service-service.yamldeployment/k8s/texera-helmchart/templates/envoy-config.yamlext_authz). It intercepts relevant requests, forwards them for an authorization check, and then passes the injected headers to the upstream service (AmberMaster).deployment/k8s/texera-helmchart/values.yamlcore/gui/src/app/workspace/component/menu/menu.component.ts&.htmlWRITEaccess to the selected Computing Unit, providing immediate visual feedback.core/build.sbtAccessControlServicemodule.core/config/src/main/scala/edu/uci/ics/amber/util/PathUtils.scala