OpenID Connect (OIDC) Federation

OpenID Connect (OIDC) Federation

Secure backend access with OIDC federation is available on all plans.

When you create long-lived, persistent credentials in your backend to allow access from your web applications, you increase the security risk of these credentials being leaked and hacked. You can mitigate this risk with OpenID Connect (OIDC) federation which issues short-lived, non-persistent tokens that are signed by Vercel's OIDC Identity Provider (IdP).

Cloud providers such as Amazon Web Services, Google Cloud Platform, and Microsoft Azure can trust these tokens and exchange them for short-lived credentials. This way, you can avoid storing long-lived credentials as Vercel environment variables.

Benefits

Getting started

To securely connect your deployment with your backend, configure your backend to trust Vercel's OIDC Identity Provider and connect to it from your Vercel deployment:

Issuer mode

There are two options available for configuring the token's issuer URL (iss):

  1. Team (Recommended): The issuer URL is bespoke to your team e.g. https://oidc.vercel.com/acme.
  2. Global: The issuer URL is generic e.g. https://oidc.vercel.com.

To change the issuer mode:

How OIDC token federation works

In Builds

When you run a build, Vercel automatically generates a new token and assigns it to the VERCEL_OIDC_TOKEN environment variable. You can then exchange the token for short-lived access tokens with your cloud provider.

In Vercel Functions

When your application invokes a Vercel Function, the OIDC token is set to the x-vercel-oidc-token header on the Function's Request object.

Vercel does not generate a fresh OIDC token for each execution. It reuses a token for up to 90 minutes. Function tokens have a Time to Live (TTL) of two hours. The remaining 30 minutes ensures the token stays valid throughout a Function's maximum execution duration.

In Local Development

You can download the VERCEL_OIDC_TOKEN straight to your local development environment using the CLI command vercel env pull. Link your project first if you haven't already; vercel env pull requires a linked project (or VERCEL_ORG_ID and VERCEL_PROJECT_ID to be set).

vercel link
vercel env pull

This writes the VERCEL_OIDC_TOKEN environment variable and other environment variables targeted to development to the .env.local file of your project folder. See the CLI docs for more information.