Skip to content

Add as-restful support for TDX-based Open-webui #826

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RodgerZhu
Copy link
Contributor

[Background]:
We are working on a Confidential AI project(https://github.com/intel/confidential-computing-zoo/tree/main/cczoo/confidential_ai),which is built based-on TDX + Open-webui. We will leverage attestation service (restful api) in trustee to do the attestation related work. Open-webui(https://github.com/open-webui/open-webui) is an open-sourced project which provide a webui for AI services.

[Issue]
When Open-webui tries to access as via http, it will show below error message:
Access to XMLHttpRequest at 'http://xxxx:8080/attestation' from origin 'http://xxxx:18080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.

[Fix]
Add CORS policy to permit the access from open-webui request.

[Background]:
We are working on a Confidential AI project(https://github.com/intel/confidential-computing-zoo/tree/main/cczoo/confidential_ai),which is built based-on TDX + Open-webui.
We will leverage attestation service (restful api) in trustee to do the attestation related work.
Open-webui(https://github.com/open-webui/open-webui) is an open-sourced project which provide a webui for AI services.

[Issue]
When Open-webui tries to access as via http, it will show below error message:
    Access to XMLHttpRequest at 'http://xxxx:8080/attestation' from origin 'http://xxxx:18080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.

[Fix]
Add CORS policy to permit the access from open-webui request.

Signed-off-by: RodgerZhu <[email protected]>
@RodgerZhu RodgerZhu requested a review from a team as a code owner June 19, 2025 02:35
Copy link
Member

@Xynnn007 Xynnn007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the new feature and nice to hear that other projects are integrating CoCoAS now @RodgerZhu ! Some design considerations. Also, let's make the CI happy

@@ -65,6 +65,7 @@ tokio.workspace = true
tonic = { workspace = true, optional = true }
uuid = { version = "1.1.2", features = ["v4"] }
verifier = { path = "../deps/verifier", default-features = false }
actix-cors = "0.7"
Copy link
Member

@Xynnn007 Xynnn007 Jun 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's reorder it with alphabet order. And we can use

Suggested change
actix-cors = "0.7"
actix-cors = { version = "0.7", optional = true }

and enable this dependency only when we are building restful-as (the front)

restful-bin = ["actix-cors", "actix-web/openssl", "clap", "env_logger"]

@@ -96,7 +97,9 @@ async fn main() -> Result<(), RestfulError> {

let attestation_service = web::Data::new(Arc::new(RwLock::new(attestation_service)));
let server = HttpServer::new(move || {
let cors = Cors::permissive();
Copy link
Member

@Xynnn007 Xynnn007 Jun 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The official document says permissive(): All origins, methods, request headers and exposed headers allowed. (Not recommended for production use.)

It would be a good choice to add a parameter for restful named --allowed-origin or something similar to set manually when launching. If this parameter is not given, we fully forbid oras.

The reference of parameter definition is here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree with @Xynnn007. Cors::permissive() is not a proper fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants