Overview

A federation service is a project resource that represents one relying party, such as an AWS account or a GCP workload identity pool. Its canonical name, e.g. deploy@services.payments.id.prism.example.com, is the audience (aud) of every token minted for it, so the cloud side can trust tokens for this service and nothing else.

FlowPrism sideCloud side
AWS from code or CLIservices mint-federation-tokenIAM OIDC provider, sts:AssumeRoleWithWebIdentity
AWS console for peopleauth aws-saml-loginIAM SAML provider, sts:AssumeRoleWithSAML
Google Cloudservices mint-federation-tokenWorkload identity pool with an OIDC provider

Prism generates the cloud-side setup for you: prism integrations setup … prints the aws/gcloud commands, or Terraform with --format terraform. It reads issuer details from the server but does not change anything in the cloud.

Minted tokens

A federation token is an ES256-signed JWT that lives at most one hour:

{
  "iss": "https://prism.example.com/api/v1/organizations/acme",
  "sub": "payments-api@service-accounts.payments.id.prism.example.com",
  "aud": "deploy@services.payments.id.prism.example.com",
  "org": "acme",
  "project": "payments",
  "groups": ["operators@groups.payments.id.prism.example.com"],
  "iat": 1794432105,
  "exp": 1794432705,
  "jti": "…"
}

groups lists the caller's groups in the project, so cloud policies can condition on them. --group operators additionally sets a single group claim (the caller must be a member), and --as-service-account mints as a service account the caller may act as, with the caller recorded in an actor claim.

Create the federation service

A service's canonical name is always one of its audiences, and the default. Add other audiences when a relying party expects a fixed value (--audience, repeatable), and pick the default with --default-audience. The SAML provider ARN is only needed for AWS console logins.

prism services create --project payments --name deploy --description "Deploy to AWS"

# Who may mint tokens for it: a service account, a user or a group
prism services add-grant --project payments --service deploy \
  --principal payments-api --effect allow --permission services.mint_federation_token

# Later changes keep the service's grants
prism services update deploy --project payments \
  --audience https://ledger.internal.example.com
prism services update deploy --project payments \
  --saml-provider-arn arn:aws:iam::123456789012:saml-provider/prism-payments-deploy

Callers pick an audience with mint-federation-token --audience; it must be one of the service's audiences.

  1. AWS: assume a role with a federation token

    Generate and apply the AWS setup (OIDC provider and role trust policy):

    prism integrations setup aws-openid --project payments --service deploy \
      --aws-account-id 123456789012 --thumbprint <sha1-of-issuer-tls-cert> --validate

    It prints, among other things, a trust policy that accepts only this service's audience:

    "Action": "sts:AssumeRoleWithWebIdentity",
    "Condition": {
      "StringEquals": {
        "prism.example.com/api/v1/organizations/acme:aud": "deploy@services.payments.id.prism.example.com"
      }
    }

    Attach permissions to the role prism-payments-deploy as usual. Then, as a principal with the mint grant:

    TOKEN=$(prism --output json services mint-federation-token \
      --project payments --service deploy | jq -r .token)
    
    aws sts assume-role-with-web-identity \
      --role-arn arn:aws:iam::123456789012:role/prism-payments-deploy \
      --role-session-name payments-api \
      --web-identity-token "$TOKEN"

    AWS SDKs can do the exchange themselves: write the token to a file and set AWS_WEB_IDENTITY_TOKEN_FILE and AWS_ROLE_ARN. Re-mint the token before it expires.

  2. AWS console: sign in with SAML

    Generate the SAML provider and role setup. It uses the service's SAML metadata, and the service needs the provider's ARN (prism services update deploy --saml-provider-arn …):

    prism integrations setup aws-saml --project payments --service deploy \
      --aws-account-id 123456789012 --role-name prism-payments-console
    
    # Includes, among others:
    prism services aws-saml-metadata --project payments --service deploy > prism-payments-deploy-metadata.xml
    aws iam create-saml-provider --name prism-payments-deploy \
      --saml-metadata-document file://prism-payments-deploy-metadata.xml

    Console roles are attached to service accounts, and people get them by being allowed to act as the service account:

    prism service-accounts create -p payments -n aws-admin
    prism service-accounts aws-roles create -p payments --service-account aws-admin \
      --role-arn arn:aws:iam::123456789012:role/prism-payments-console \
      --session-duration-seconds 14400
    
    prism service-accounts add-grant -p payments --service-account aws-admin \
      --principal operators --effect allow --permission service_accounts.act_as

    An operator then gets a single-use sign-in URL, valid for five minutes:

    prism auth aws-saml-login --service deploy@services.payments.id.prism.example.com
    # url: https://prism.example.com/api/v1/auth/aws-saml?session=…
    open "$(prism --output json auth aws-saml-login \
      --service deploy@services.payments.id.prism.example.com | jq -r .url)"

    The page posts a signed SAML assertion to AWS, which shows the roles of all service accounts the caller may act as. By default every service account in the project with AWS roles is considered; create the service with --aws-role-source-mode assigned_service_accounts and use prism services service-accounts set to limit it to specific ones.

  3. Google Cloud: workload identity federation

    prism integrations setup gcp-workload-identity --project payments --service deploy \
      --gcp-project-id acme-prod --gcp-project-number 123456789012 --format terraform

    This creates a workload identity pool with an OIDC provider whose allowed audience is the service's canonical name, a GCP service account, and a roles/iam.workloadIdentityUser binding for tokens with that audience. A workload exchanges a minted token at Google's STS, then impersonates the GCP service account:

    TOKEN=$(prism --output json services mint-federation-token \
      --project payments --service deploy | jq -r .token)
    
    ACCESS=$(curl -fsS https://sts.googleapis.com/v1/token \
      -d audience=//iam.googleapis.com/projects/123456789012/locations/global/workloadIdentityPools/POOL/providers/PROVIDER \
      -d grant_type=urn:ietf:params:oauth:grant-type:token-exchange \
      -d requested_token_type=urn:ietf:params:oauth:token-type:access_token \
      -d scope=https://www.googleapis.com/auth/cloud-platform \
      -d subject_token_type=urn:ietf:params:oauth:token-type:jwt \
      -d subject_token="$TOKEN" | jq -r .access_token)
    
    curl -fsS -X POST -H "Authorization: Bearer $ACCESS" -H 'Content-Type: application/json' \
      -d '{"scope":["https://www.googleapis.com/auth/cloud-platform"]}' \
      "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/SA_EMAIL:generateAccessToken"

    Use the pool, provider and service account names printed by the setup command.

Your own APIs

Federation tokens work with any relying party that verifies JWTs through OIDC discovery, not only cloud providers. An internal API can accept Prism callers by checking the signature against https://prism.example.com/api/v1/organizations/acme/jwks, the issuer, and that aud is its own identifier (an audience you added to the service), then authorizing on sub or groups:

# Caller
TOKEN=$(prism --output json services mint-federation-token --project payments --service deploy \
  --audience https://ledger.internal.example.com --expires-in-seconds 300 | jq -r .token)
curl -H "Authorization: Bearer $TOKEN" https://ledger.internal.example.com/v1/entries

# Discovery document for the API's JWT library
curl https://prism.example.com/api/v1/organizations/acme/.well-known/openid-configuration

Combine with other identities

The principal minting the token can itself be federated: a GitHub Actions job or an EC2 instance assumes a Prism service account, then mints AWS or GCP tokens. One set of Prism grants then controls access to several clouds.

Notes