# Add an identity provider

Register an OIDC issuer, such as GitHub Actions or {{product}} CI, whose tokens a role's trust policy can then accept.

An identity provider is an issuer of OIDC tokens. Registering one accepts nothing by itself: a
role's trust policy still has to name the provider and the workloads it admits (see
[Set a trust policy](set-a-trust-policy.md)).

## Prerequisites

- Permission for `iam:CreateOpenIdConnectProvider`.
- In the console, also `iam:ListOpenIdConnectProviders`: without it **Identity providers** shows
  only "You do not have permission to list identity providers".

## Add the provider

**Console**
1. Open **Identity**, then choose **Identity providers**.
2. Choose **Add GitHub Actions**, or **Add Deutsche Cloud CI** for jobs that run on Deutsche Cloud's
   runners. To register another issuer, choose **Custom issuer**, enter the **Issuer URL** and at
   least one audience under **Audiences (comma-separated)**, then choose **Add provider**.

The provider is listed with its **Provider RN (Principal.Federated in a trust policy)** and
**Accepted audiences**.

**CLI**
```sh
dcloud iam oidc-providers create --url https://token.actions.githubusercontent.com
```

**API**
```http
POST /iam/api/oidc-providers
{ "url": "https://token.actions.githubusercontent.com" }
```

**Terraform**
```hcl
resource "dcloud_iam_oidc_provider" "github" {
  url = "https://token.actions.githubusercontent.com"
}
```

## Result

- **GitHub Actions** registers `https://token.actions.githubusercontent.com`.
- **Deutsche Cloud CI** registers the console's own issuer, `https://<console host>/ci/api/oidc`.
- Without audiences (the two **Add** buttons, and the CLI, API or Terraform without
  `audiences`), the provider accepts one: the console's own origin, such as
  `https://console.example.com`. The **Custom issuer** form needs at least one; left empty, it is
  refused with 400 `audiences: …`. A job must request a token for one of the accepted audiences.
  Up to 10 audiences are accepted.
- The issuer URL must equal the `iss` claim of the tokens exactly. The platform reads
  `/.well-known/openid-configuration` and the signing keys from it, so it must be a public
  `https://` address.

## Change the audiences

The console does not change audiences. With the CLI or the API, the list you send replaces the
whole list. This needs `iam:UpdateOpenIdConnectProvider`.

```sh
dcloud iam oidc-providers update provider-id --audiences https://console.example.com
```

## Delete a provider

On **Identity providers**, choose the provider's delete icon, then **Delete provider**. Roles whose
trust policy names it can no longer be assumed with its tokens; credentials already issued stay
valid until they expire, at most one hour. The trust policies themselves are left unchanged.

```sh
dcloud iam oidc-providers delete provider-id
```

This needs `iam:DeleteOpenIdConnectProvider`.

## If the provider is refused

- 400 `The issuer must be a public https:// URL on the default port, without credentials, query or fragment`
- 409 `An identity provider for this issuer already exists`
- 409 `Quota exceeded: OIDC identity providers (iam.oidc-providers) — …`

## Related

- [Web identity federation](web-identity-federation.md)
- [Set a trust policy](set-a-trust-policy.md)
- `iam.oidc-providers.create` · `dcloud iam oidc-providers create` · `dcloud_iam_oidc_provider`
