定制 iamxml/fusio-adapter-gcp-zero-trust 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

iamxml/fusio-adapter-gcp-zero-trust

最新稳定版本:v0.2.3

Composer 安装命令:

composer require iamxml/fusio-adapter-gcp-zero-trust

包简介

Fusio adapter providing Cloud Run zero-trust HTTP connection with ID token auth

README 文档

README

Fusio adapter for calling Cloud Run services with automatic Google-signed ID token injection.

Provides a Connection type and a matching Action type that work together:

  • Connection (Google Cloud Run Zero Trust HTTP) — returns a Guzzle HTTP client with ID token middleware
  • Action (Google Cloud Run HTTP) — proxies Fusio requests through that connection to a downstream Cloud Run service

Install

composer require fusio/adapter-gcp-zero-trust
php bin/fusio system:register "Fusio\Adapter\GcpZeroTrust\Adapter"

Setup

Step 1: Create a Connection

Backend > API > Connections > Create

Select type: Google Cloud Run Zero Trust HTTP

Field Description
Base URL Target service URL, e.g. https://my-service-abc123.run.app
Audience Cloud Run audience for the ID token. Usually the same as the base URL. Must be the .run.app URL (custom domains are not supported as audience).
Header Mode Authorization or X-Serverless-Authorization (see below)
Timeout HTTP timeout in seconds (default: 30)
Enable Logging Log outbound requests with method, path, status code, and duration. Never logs tokens or bodies.

Step 2: Create an Action

Backend > API > Actions > Create

Select type: Google Cloud Run HTTP

Field Description
Connection Select the connection created in Step 1 (dropdown of all configured connections)
Method AUTO (forwards the inbound HTTP method), or a fixed method: GET, POST, PUT, PATCH, DELETE
Path Relative path on the target service, e.g. /api/v1/users. Supports {{param}} placeholders resolved from URI fragments.
Forward Headers Comma-separated list of inbound headers to forward, e.g. X-Request-Id, Accept-Language

Step 3: Bind the Action to an Operation

Backend > API > Operations

Point a route to the action. The action will:

  1. Load the configured connection (which returns a Guzzle client with ID token middleware)
  2. Forward the HTTP method, path, query parameters, and request body to the downstream service
  3. Return the downstream response (status code, headers, and body) back through Fusio

Header modes

  • Authorization — Sets Authorization: Bearer <id-token>. Use when the target service has no app-level auth.
  • X-Serverless-Authorization — Sets X-Serverless-Authorization: Bearer <id-token>, leaving Authorization free for app-level auth (e.g. Fusio Bearer tokens). Cloud Run validates this header for IAM, strips it before forwarding to the container, and passes Authorization through untouched. Cloud Run docs.

How authentication works

The adapter uses Google Application Default Credentials to fetch ID tokens:

  • On Cloud Run: Uses the metadata server automatically. The calling service's service account must have roles/run.invoker on the target service.
  • Locally: Uses credentials from gcloud auth application-default login.

Tokens are cached in-process for ~55 minutes (tokens are valid for 1 hour) using google/auth's FetchAuthTokenCache with MemoryCacheItemPool.

Example: Dockerfile for a custom Fusio image

FROM fusio/fusio:5.2.5

WORKDIR /var/www/html/fusio

RUN composer require fusio/adapter-gcp-zero-trust:^0.2 \
    --no-interaction --no-progress

RUN php bin/fusio system:register \
    "Fusio\\Adapter\\GcpZeroTrust\\Adapter"

Requirements

  • PHP >= 8.1
  • Fusio Engine ^6.0 (ships with fusio/fusio v5.2+)
  • google/auth ^1.50
  • guzzlehttp/guzzle ^7.0

Development

make install    # Install dependencies
make test       # Run tests (PHPUnit)
make lint       # Static analysis (phpstan level 6)

License

Apache-2.0

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2026-03-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固