NEWn1n v2.0.1 is live! Enterprise Unified LLM API Gateway with 500+ AI Models, up to 90% off, Try now

Keyless AI Agents on Google Cloud: Implementing Agent Identity and Auth Manager

Authors
  • avatar
    Name
    Nino
    Occupation
    Senior Tech Editor

The architecture of modern AI agents is rapidly evolving from simple prompt-response loops to complex, autonomous systems that interact with sensitive enterprise data. However, most agent prototypes still rely on a 'flat-trust' security model: sharing a single service account across multiple workloads, embedding static API keys in environment variables, and relying on broad perimeter rules. This approach is inherently brittle and poses a significant risk for production deployments.

At the Google Cloud Security Summit, a paradigm shift was introduced with the general availability of Agent Identity and Auth Manager. These tools, combined with identity-based VPC Service Controls (VPC-SC), allow developers to build 'keyless' agents. This means no more pasting client secrets or service account JSON files. Instead, each agent receives its own verifiable identity and a brokered authentication layer. For developers utilizing high-performance LLMs through n1n.ai, integrating these security layers is critical for maintaining data integrity and compliance.

The Problem with Flat-Trust AI Architectures

In traditional setups, several agents often share one Service Account. When an audit log shows a sensitive BigQuery table was accessed, it is impossible to distinguish which specific agent—or which user prompt—triggered the action. Furthermore, static secrets (like Jira or Salesforce API keys) stored in Secret Manager are still within the 'reach' of the agent. If an agent is compromised via prompt injection, those secrets can be exfiltrated.

By contrast, the new Google Cloud framework ensures:

  1. Granular Auditing: Every agent has a unique SPIFFE-based identity.
  2. Secret Abstraction: The agent never 'sees' the raw credential; Auth Manager handles the exchange.
  3. Context-Aware Perimeters: VPC-SC rules can now understand IAM roles, not just IP ranges or service names.

Building Block 1: Agent Identity (SPIFFE-based)

Agent Identity provides each workload with a strongly attested identity based on the SPIFFE (Secure Production Identity Framework for Everyone) standard. Unlike standard service accounts, agent identities cannot be easily impersonated and do not support long-lived keys. They are uniquely bound to the runtime, whether it is Cloud Run, GKE, or the Vertex AI Agent Runtime.

When deploying a containerized agent on Cloud Run, enabling this identity is a simple 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 developers using the Vertex AI SDK to manage engines, the configuration is equally straightforward:

from google.cloud import aiplatform

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

By using n1n.ai to aggregate your model calls, you can ensure that the underlying LLM requests (to models like Claude 3.5 Sonnet or DeepSeek-V3) are initiated by a secure, identified principal, streamlining your governance across multiple providers.

Building Block 2: Auth Manager and 2-Legged OAuth

Auth Manager acts as a managed vault for external credentials. It handles the complexities of OAuth, including token refresh and secure storage. If your agent needs to call a Jira MCP (Model Context Protocol) server, you no longer store the CLIENT_SECRET in your code.

First, 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"

Then, grant the specific agent's SPIFFE principal the roles/agentidentity.user role. This ensures that only that specific agent can request tokens from the provider. This is a massive improvement over environment variables where any process in the container could read the secret.

Building Block 3: Identity-Based VPC Service Controls

Security teams often struggle with VPC-SC because rules are typically written per service and method, leading to overly broad exceptions. With identity-based rules, you can scope ingress and egress by IAM roles.

For example, you can create a rule that only allows the roles/bigquery.dataViewer role to access a specific dataset, but only when the request originates from a verified Agent Identity. This creates a 'perimeter of identity' that travels with the workload.

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

Cross-Cloud Authentication via OIDC

One of the most powerful features currently in preview is the support for Agent Identity JWTs. This allows an agent to prove its identity to external services (like AWS or on-premise APIs) without needing Google Cloud credentials on the receiving end. The agent requests an OIDC ID token signed by Google, which the receiver verifies using public JWKS endpoints.

In Python, this is handled by the google-auth library:

from google.auth.transport.requests import AuthorizedSession
from google.oauth2 import id_token

target_audience = "https://api.external-service.com"
credentials = id_token.fetch_id_token_credentials(audience=target_audience)
session = AuthorizedSession(credentials)

# The session automatically handles token inclusion
resp = session.post("https://api.external-service.com/v1/task", json={"status": "active"})

Integration with n1n.ai for Enterprise LLMs

When building production-ready agents, the choice of LLM is as important as the security framework. n1n.ai provides a unified API to access the world's most powerful models, including DeepSeek-V3, OpenAI o3, and Claude 3.5 Sonnet. By combining the keyless identity features of Google Cloud with the high-speed, stable API of n1n.ai, enterprises can achieve:

  • Reduced Latency: n1n.ai optimizes routing to ensure latency < 200ms for most global regions.
  • Simplified Pricing: One bill for all LLM providers, coupled with Google Cloud's predictable infrastructure costs.
  • Enhanced RAG: Securely connect your RAG pipelines to BigQuery using identity-based perimeters while fetching embeddings from n1n.ai.

Summary of Best Practices

  • Minimize Blast Radius: Never grant project-wide roles. Bind roles to the specific Auth Provider or BigQuery dataset.
  • Monitor Token Binding: Agent Identity tokens are often bound to X.509 certificates. Ensure your service-to-service calls use mTLS endpoints (e.g., *.mtls.run.app) to avoid authentication failures.
  • Audit Regularly: Use Cloud Logging to filter by the unique agent principal. This allows you to track exactly which prompt led to which external API call.

The shift to keyless AI agents is not just a security upgrade; it is a fundamental requirement for scaling AI in the enterprise. By removing the 'human' element of secret management, you reduce the risk of accidental leaks and malicious exploitation.

Get a free API key at n1n.ai