Keyless AI Agents on Google Cloud: A Practical Guide to Agent Identity, Auth Manager and Identity-Based VPC Service Controls

2026-11-24来源 dev.toEnglish
Keyless AI Agents on Google Cloud: A Practical Guide to Agent Identity, Auth Manager and Identity-Based VPC Service Controls

How to stop pasting API keys and service account JSON into agents, and give each agent its own verifiable identity, brokered OAuth tokens and a perimeter that knows who it is

The problem: agents inherit the worst habits of backend services

Most agent prototypes I see follow the same pattern. The agent runs on Cloud Run or Agent Runtime under a shared service account, a Jira or Salesforce client secret sits in an environment variable or Secret Manager, and calls to another cloud use a long-lived access key. It works, but it is a flat-trust design:

  • Several agents share one service account, so audit logs cannot tell you which agent did what.
  • Static secrets live inside the agent's reach, which matters when the agent is driven by untrusted prompts and tool output.
  • Perimeter rules are written per service and method, so security teams end up adding broad exceptions just to make agents work.

At the Google Cloud Security Summit in November 2026, Google announced a set of controls aimed squarely at this: Auth Manager (part of Agent Identity) is now generally available, Agent Identity JWT (OIDC ID token) support is in preview, and VPC Service Controls ingress and egress rules that use IAM roles are generally available. This article walks through how the pieces fit together and how to wire them up with the documented CLI and client libraries.

The architecture in one picture

Architecture diagram: end user, agent, Auth Manager, Google Cloud APIs inside VPC-SC, SaaS tool and external cloud via OIDC ID token

There are three building blocks:

  • Agent Identity gives each agent a strongly attested identity based on the SPIFFE standard. Per the docs, agent identities are not shared by multiple workloads by default, cannot be impersonated, and do not allow long-lived keys. Access tokens for Google Cloud are bound to the agent's unique X.509 certificate to reduce token theft. Supported runtimes are Agent Runtime, Gemini Enterprise, Cloud Run and GKE.
  • Auth Manager stores OAuth client credentials and user-delegated tokens in a Google-managed vault governed by IAM. It handles 2-legged OAuth (client credentials, agent's own authority) and 3-legged OAuth (on behalf of a user), so you do not write token-refresh code. ADK can retrieve and inject the token into tool calls for you.
  • Identity-based VPC Service Controls let ingress and egress rules be scoped by IAM roles rather than only by lists of services and methods, which makes least-privilege perimeters for agent traffic far easier to express.

The useful mental model is: the agent proves who it is with its own identity, Auth Manager decides which external credentials it may use, and the perimeter decides what data it may touch and from where.

Hands-on

The snippets below follow the official documentation as of November 2026. Several features are in preview, so treat the code as illustrative and check the current docs before running it. Replace the upper-case placeholders.

1. Deploy an agent with its own identity

For a containerised agent on Cloud Run, Agent Identity is a deploy-time flag:

gcloud run deploy support-agent \ --image=REGION-docker.pkg.dev/PROJECT_ID/agents/support-agent:latest \ --identity-type=agent-identity \ --no-allow-unauthenticated 

For Agent Runtime, set the identity type when you create the engine with the Vertex AI SDK:

remote_app = client.agent_engines.create( agent=app, config={ "identity_type": types.IdentityType.AGENT_IDENTITY, "requirements": ["google-cloud-aiplatform[agent_engines,adk]"], }, ) 

From here, grant IAM roles to the agent's principal, not to a shared service account. That one change gives you per-agent audit trails.

2. Move SaaS secrets into Auth Manager (2-legged OAuth)

Say the agent calls a Jira MCP server using client credentials. Instead of storing the secret with the agent, create a 2-legged auth provider:

gcloud agent-identity auth-providers create jira-mcp-2lo \ --location="us-central1" \ --two-legged-oauth-client-id="CLIENT_ID" \ --two-legged-oauth-client-secret="CLIENT_SECRET" \ --two-legged-oauth-token-url="TOKEN_URL" gcloud agent-identity auth-providers list \ --project="PROJECT_ID" --location="us-central1" 

Then allow only this agent to retrieve credentials from that provider by granting roles/agentidentity.user on the provider resource to the agent's SPIFFE principal:

gcloud agent-identity auth-providers add-iam-policy-binding jira-mcp-2lo \ --project="PROJECT_ID" \ --location="us-central1" \ --role="roles/agentidentity.user" \ --member="principal://agents.global.org-ORGANIZATION_ID.system.id.goog/resources/aiplatform/projects/PROJECT_NUMBER/locations/us-central1/reasoningEngines/ENGINE_ID" 

The member string above is the documented format for an Agent Runtime agent. For local testing with adk web, the docs also show binding the same role to user:YOUR_EMAIL. When the tool needs to act as a specific person (their Jira tasks, their GitHub repos), use a 3-legged provider instead, and Auth Manager handles the consent flow and token refresh.

Note the IAM API name: the docs recommend the Agent Identity API and say the earlier IAM Connectors API (preview) will not become generally available, so migrate if you started there.

3. Call another cloud with an OIDC ID token, no access keys

This is the part I find most interesting for multi-cloud architects. With Agent Identity JWT support (preview), the agent requests an OIDC ID token for a target audience. The token asserts the agent's SPIFFE identity and is signed by keys for the agent's trust domain. Receivers verify it through public, unauthenticated endpoints on sts.googleapis.com (/.well-known/openid-configuration and /openid/jwks), so they need no Google Cloud credentials at all.

In the agent, the google-auth library does the work, including caching and renewal from the metadata server:

from google.auth.transport.requests import AuthorizedSession from google.oauth2 import id_token target_audience = "https://api.example.com" credentials = id_token.fetch_id_token_credentials(audience=target_audience) session = AuthorizedSession(credentials) resp = session.post("https://api.example.com/v1/tickets", json={"summary": "Created by agent"}) 

The issuer your receiver must trust is the workload identity pool for the agent's trust domain, for example https://sts.googleapis.com/v1/organizations/ORGANIZATION_ID/locations/global/workloadIdentityPools/TRUST_DOMAIN.

On the AWS side, a standard pattern is to register that issuer as an IAM OIDC identity provider and let the agent exchange its token with AssumeRoleWithWebIdentity. The following is an illustrative sketch built from the generic AWS OIDC federation flow, not from a Google worked example, so validate the claim names against a real token first:

# Illustrative only aws iam create-open-id-connect-provider \ --url "https://sts.googleapis.com/v1/organizations/ORGANIZATION_ID/locations/global/workloadIdentityPools/TRUST_DOMAIN" \ --client-id-list "sts.amazonaws.com" 

Then write the role trust policy to match aud and the agent's sub (its SPIFFE ID) exactly, so that only this one agent can assume the role.

Two details from the docs worth knowing:

  • Client libraries bind ID tokens to the agent's X.509 certificate by default via the cnf (x5t#S256) claim. Receivers may validate it over mTLS or ignore it.
  • Cloud Run enforces that binding when the claim is present. If your agent calls another Cloud Run service with a bound token, call its *.mtls.run.app endpoint over mTLS, or opt out per request (bind_id_token=False in Python) or with GOOGLE_API_ENABLE_RUNTIME_BOUND_TOKEN=false.

4. Scope the perimeter by role, not by an ever-growing method list

If the agent's data lives in BigQuery or Cloud Storage inside a VPC-SC perimeter, an ingress rule can now name IAM roles rather than enumerating every method. The documented YAML shape is:

- ingressFrom: identities: - PRINCIPAL_IDENTIFIER sources: - accessLevel: ACCESS_LEVEL ingressTo: roles: - roles/bigquery.dataViewer resources: - projects/PROJECT_NUMBER 

The rule then only allows actions covered by that role's permissions. Before relying on a role, check it is supported:

gcloud access-context-manager supported-permissions describe roles/bigquery.dataViewer 

Custom roles in the projects/PROJECT_ID/roles/... format are not accepted in these rules, so plan to use predefined or organisation-level custom roles.

Trade-offs, cost and security notes

  • Preview versus GA. Auth Manager and IAM roles in VPC-SC rules are GA. OIDC ID tokens for external services are preview under Pre-GA terms, so I would not make a cross-cloud production path depend on them without a fallback.
  • Blast radius. Per-agent identities make least privilege practical, but only if you resist granting broad project roles to every agent principal. Bind roles on the narrowest resource: the auth provider, the dataset, the bucket.
  • Token binding surprises. Certificate-bound tokens are a strong defence against replay, but they change how service-to-service calls work on Cloud Run. Test the mTLS path early rather than disabling binding globally.
  • Operational ownership. Moving secrets into Auth Manager shifts rotation to whoever owns the auth provider. Decide who that is and alert on provider state.
  • Cost. I have not found separate pricing for these identity features in the sources below. Check the current pricing pages for Agent Identity, the runtimes and VPC-SC before you estimate.
  • Defence in depth. Identity does not stop a prompt-injected agent from misusing access it legitimately has. Pair it with Agent Gateway policies and content controls such as Model Armor.

Conclusion

The shift here is small in syntax and large in effect: a --identity-type=agent-identity flag, a handful of gcloud agent-identity commands and a role-scoped perimeter rule replace shared service accounts, pasted secrets and long-lived cross-cloud keys. If you are building agents on Google Cloud today, I would start by giving one agent its own identity, moving one SaaS secret into Auth Manager, and seeing how much cleaner the audit log becomes.

References

原文:https://www.a8q9.cn/en/article/keyless-ai-agents-on-google-cloud-a-practical-guide-to-agent-identity-auth-manag-6665a1.html

相关文章