Skip to content

attestation-service: enable CORS support in restful-as for browser scenarios#185

Merged
jialez0 merged 1 commit into
openanolis:mainfrom
jialez0:trustee/coco-pickup-restful-as-cors
Jun 9, 2026
Merged

attestation-service: enable CORS support in restful-as for browser scenarios#185
jialez0 merged 1 commit into
openanolis:mainfrom
jialez0:trustee/coco-pickup-restful-as-cors

Conversation

@jialez0

@jialez0 jialez0 commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

背景

吸收上游 confidential-containers/trustee 的 restful-as CORS 支持,便于浏览器类客户端(如 Open-WebUI)跨域调用 attestation REST API。

  • 上游 commit:confidential-containers/trustee 52a71bbc(Enable CORS support in trustee for browser scenario)

改动内容

  • attestation-service/src/bin/restful-as.rs:新增可选 --allowed_origin-r)CLI 参数与 configure_cors();为 App 挂上 CORS 层,允许指定 origin 的 POST/GET/OPTIONS + Content-Type/Authorization。
  • attestation-service/Cargo.toml:新增可选依赖 actix-cors,gated 在已有的 restful-bin feature 下。

适配说明(相对上游)

  • 手工塞入本 fork restful-as.rs 中更完整的 App::new() service 链(本 fork 多 delete_policy/get_certificate/get_jwks/get_openid_configuration 等 service)。
  • actix-cors 固定为 =0.7.0:0.7.1 会拉入 derive_more 2.x(要求 rustc ≥ 1.81),与本 fork 的 1.76 工具链冲突;0.7.0 使用 derive_more 0.99,可正常构建。待 MSRV 提升后再 bump。

兼容性

  • 默认关闭:不传 --allowed_origin 时不允许任何跨域 origin,行为与现状一致。
  • 不新增/修改/删除任何现有 API 或配置项。
  • actix-cors 为可选依赖,仅在 restful-bin feature 下引入。
  • 现有部署不受影响。

验证

  • cargo check -p attestation-service --bin restful-as 通过(rustc 1.76)。

@shankailun-aliyun

Copy link
Copy Markdown
Collaborator

@jialez0 ,您好,您的请求已接收,请耐心等待结果。

@shankailun-aliyun

Copy link
Copy Markdown
Collaborator

@jialez0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start

Add an optional `--allowed_origin` (`-r`) CLI flag to the restful-as
binary. When one or more origins are given, a CORS layer is installed that
permits POST/GET/OPTIONS with Content-Type/Authorization headers from those
origins; this lets browser-based clients (e.g. Open-WebUI) call the
attestation REST API across origins. When the flag is not provided (the
default), no origins are allowed and behaviour is unchanged.

Adapted from confidential-containers/trustee 52a71bbc8037de998465bb5f0f6f4dfb304aef39.
`actix-cors` is added as an optional dependency, gated behind the existing
`restful-bin` feature. No existing API, config, or default behaviour changes.

Signed-off-by: Jiale Zhang <xinjian.zjl@alibaba-inc.com>
@jialez0 jialez0 force-pushed the trustee/coco-pickup-restful-as-cors branch from 685ef39 to 5c9ad24 Compare June 8, 2026 08:17
@shankailun-aliyun

Copy link
Copy Markdown
Collaborator

@jialez0 ,您好,您的请求已接收,请耐心等待结果。

@shankailun-aliyun

Copy link
Copy Markdown
Collaborator

@jialez0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start

@jialez0 jialez0 merged commit 58da7b3 into openanolis:main Jun 9, 2026
5 checks passed
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.

2 participants