# Secrets or federation: how a CI job proves who it is

> Why a pasted cloud secret is a copied house key, and how a federated credential lets a CI job prove who it is with a short-lived token instead.

- URL: https://iamops.dev/secrets-vs-federated-credentials/
- Language: en
- Author: Argo
- Published: 2026-11-25
- Category: Knowledge
- Depth: Explainer
- Audience: Security leaders and architects
- Time: 5 min
- Topics: Secrets, Workload identity, Basics

## TL;DR

- A [secret](https://iamops.dev/secrets-vs-federated-credentials/#the-copied-key) is a password or key that works from anywhere, for anyone who holds it, until someone rotates it.
- A [federated credential](https://iamops.dev/secrets-vs-federated-credentials/#federation-the-issuers-stamp) lets the cloud trust a token from a known issuer, so no long-lived value sits in the repository.
- The cloud matches the [subject of the token](https://iamops.dev/secrets-vs-federated-credentials/#what-the-token-says) against a trust rule, so a run from another repository or branch is refused.
- [The trust rule](https://iamops.dev/secrets-vs-federated-credentials/#the-trust-rule-is-the-real-lock) is the real lock. A loose rule lets the wrong workflow in, even with no secret at all.

A copied house key works for whoever holds it. A doorman with a guest list works only for the people on it, and only for tonight. Those two ideas are the whole difference between a secret and a federated credential.

**Before you start:** a token is a short piece of signed data that proves a claim, such as who the caller is. You do not need to know its format yet.

## The copied key

A deployment job needs to log in to the cloud. The old way is to create a credential in the cloud, copy it into the repository's secrets, and let the job send it on every run. The secret then lives in two places, and it stays valid until someone rotates it. If it leaks from a log, a fork or a laptop, it works from anywhere.

The GitHub documentation describes this exact problem. Hardcoded secrets mean you create credentials in the cloud and then duplicate them in GitHub. Every copy is one more place to lose it.

## Federation: the issuer's stamp

Federation changes who vouches for the job. The cloud is told once that it trusts tokens from a known issuer, here GitHub's OpenID Connect provider. Every time a job runs, that issuer creates a token for that run. The job asks for the token, presents it to the cloud, and gets a cloud access token that lasts for the job only.

Nothing long-lived is stored in the repository. The job proves who it is with a stamp from the issuer, and the stamp expires.

## What the token says

The token is a <abbr title="JavaScript Object Notation">JSON</abbr> web token, which is a <abbr title="JavaScript Object Notation">JSON</abbr> payload signed by the issuer. The field that matters most is the subject, called `sub`. In the GitHub example it reads like `repo:octo-org/octo-repo:environment:prod`, which names the repository and the environment the job runs in.

The GitHub documentation notes a change for repositories created after 15 July 2026. Their default subject now includes the owner and repository <abbr title="identifier">ID</abbr>s. That makes a name-based match less useful than it used to be, so the trust rule needs to match the new format.

![Sequence diagram: a CI job asks the token service for a token, receives a short-lived token, presents it to the cloud, and the cloud refuses a subject that does not match the trust rule.](https://iamops.dev/img/secrets-vs-federated-credentials.svg)

*Federated login. The cloud refuses a run whose subject is not in its trust rule.*

## The trust rule is the real lock

Without a secret, the trust rule is the only check. If the rule says "any run from this organisation", then any repository in it can deploy. If it names one repository and one environment, a fork or another branch is refused. Write the rule as narrowly as the job needs, and test it with a run that should fail.

My view for beginners: the switch from secrets to federation removes the copied key, but it moves the risk into the trust rule. Review that rule like a guest list, not like a setting.

## Where to go next

For the lab that signs a GitHub workflow in to Azure with no secret, read [GitHub Actions to Azure with workload identity federation](https://iamops.dev/github-actions-azure-workload-identity-federation/). For the newer subject format and what changed, read [workload identity news: the immutable sub claim](https://iamops.dev/workload-identity-news-immutable-sub-entra-wildcards-workos/). For the agent side of the same question, read [a secretless agent on Azure with a managed identity](https://iamops.dev/secretless-agent-managed-identity-container-app/).

## Sources

- [GitHub Docs, About security hardening with OpenID Connect](https://docs.github.com/en/actions/concepts/security/openid-connect)

Discuss: [X](https://x.com/iamopsdev) | [LinkedIn](https://www.linkedin.com/company/iamops-dev/)
