Skip to content

Commit eb24002

Browse files
authored
Merge pull request #39259 from github/repo-sync
Repo sync
2 parents 23f8a3b + 25b182d commit eb24002

File tree

7 files changed

+214
-182
lines changed

7 files changed

+214
-182
lines changed

content/actions/concepts/security/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ versions:
99
children:
1010
- /secrets
1111
- /github_token
12-
- /about-security-hardening-with-openid-connect
12+
- /openid-connect
1313
---
1414

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
---
2+
title: OpenID Connect
3+
shortTitle: OpenID Connect
4+
intro: OpenID Connect allows your workflows to exchange short-lived tokens directly from your cloud provider.
5+
versions:
6+
fpt: '*'
7+
ghec: '*'
8+
ghes: '*'
9+
type: tutorial
10+
topics:
11+
- Security
12+
redirect_from:
13+
- /actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect
14+
- /actions/security-for-github-actions/security-hardening-your-deployments/about-security-hardening-with-openid-connect
15+
- /actions/concepts/security/about-security-hardening-with-openid-connect
16+
---
17+
18+
## Overview of OpenID Connect (OIDC)
19+
20+
{% data variables.product.prodname_actions %} workflows are often designed to access a cloud provider (such as AWS, Azure, GCP, HashiCorp Vault, and others) in order to deploy software or use the cloud's services. Before the workflow can access these resources, it will supply credentials, such as a password or token, to the cloud provider. These credentials are usually stored as a secret in {% data variables.product.prodname_dotcom %}, and the workflow presents this secret to the cloud provider every time it runs.
21+
22+
However, using hardcoded secrets requires you to create credentials in the cloud provider and then duplicate them in {% data variables.product.prodname_dotcom %} as a secret.
23+
24+
After you have established a trust connection with a cloud provider that supports OIDC, you can you can configure your workflow to request a short-lived access token directly from the cloud provider.
25+
26+
## Benefits of using OIDC
27+
28+
By updating your workflows to use OIDC tokens, you can adopt the following good security practices:
29+
30+
* **No cloud secrets:** You won't need to duplicate your cloud credentials as long-lived {% data variables.product.github %} secrets. Instead, you can configure the OIDC trust on your cloud provider, and then update your workflows to request a short-lived access token from the cloud provider through OIDC.
31+
* **Authentication and authorization management:** You have more granular control over how workflows can use credentials, using your cloud provider's authentication (authN) and authorization (authZ) tools to control access to cloud resources.
32+
* **Rotating credentials:** With OIDC, your cloud provider issues a short-lived access token that is only valid for a single job, and then automatically expires.
33+
34+
## How OIDC integrates with {% data variables.product.prodname_actions %}
35+
36+
The following diagram gives an overview of how {% data variables.product.github %}'s OIDC provider integrates with your workflows and cloud provider:
37+
38+
![Diagram of how a cloud provider integrates with {% data variables.product.prodname_actions %} through access tokens and JSON web token cloud role IDs.](/assets/images/help/actions/oidc-architecture.png)
39+
40+
1. You establish an OIDC trust relationship in the cloud provider, allowing specific {% data variables.product.github %} workflows to request cloud access tokens on behalf of a defined cloud role.
41+
1. Every time your job runs, {% data variables.product.prodname_dotcom %}'s OIDC provider auto-generates an OIDC token. This token contains multiple claims to establish a security-hardened and verifiable identity about the specific workflow that is trying to authenticate.
42+
1. A step or action in the workflow job can request a token from {% data variables.product.github %}’s OIDC provider, which can then be presented to the cloud provider as proof of the workflow’s identity.
43+
1. Once the cloud provider successfully validates the claims presented in the token, it then provides a short-lived cloud access token that is available only for the duration of the job.
44+
45+
## Understanding the OIDC token
46+
47+
Each job requests an OIDC token from {% data variables.product.prodname_dotcom %}'s OIDC provider, which responds with an automatically generated JSON web token (JWT) that is unique for each workflow job where it is generated. When the job runs, the OIDC token is presented to the cloud provider. To validate the token, the cloud provider checks if the OIDC token's subject and other claims are a match for the conditions that were preconfigured on the cloud role's OIDC trust definition.
48+
49+
The following example OIDC token uses a subject (`sub`) that references a job environment named `prod` in the `octo-org/octo-repo` repository.
50+
51+
```yaml
52+
{
53+
"typ": "JWT",
54+
"alg": "RS256",
55+
"x5t": "example-thumbprint",
56+
"kid": "example-key-id"
57+
}
58+
{
59+
"jti": "example-id",
60+
"sub": "repo:octo-org/octo-repo:environment:prod",
61+
"environment": "prod",
62+
"aud": "{% ifversion ghes %}https://HOSTNAME{% else %}https://github.com{% endif %}/octo-org",
63+
"ref": "refs/heads/main",
64+
"sha": "example-sha",
65+
"repository": "octo-org/octo-repo",
66+
"repository_owner": "octo-org",
67+
"actor_id": "12",
68+
"repository_visibility": "private",
69+
"repository_id": "74",
70+
"repository_owner_id": "65",
71+
"run_id": "example-run-id",
72+
"run_number": "10",
73+
"run_attempt": "2",
74+
"runner_environment": "github-hosted",
75+
"actor": "octocat",
76+
"workflow": "example-workflow",
77+
"head_ref": "",
78+
"base_ref": "",
79+
"event_name": "workflow_dispatch",{% ifversion actions-OIDC-custom-claim-enterprise %}
80+
"enterprise": "avocado-corp",{% endif %}{% ifversion actions-OIDC-enterprise_id-claim %}
81+
"enterprise_id": "2",{% endif %}
82+
"ref_type": "branch",
83+
"job_workflow_ref": "octo-org/octo-automation/.github/workflows/oidc.yml@refs/heads/main",
84+
"iss": "{% ifversion ghes %}https://HOSTNAME/_services/token{% else %}https://token.actions.githubusercontent.com{% endif %}",
85+
"nbf": 1632492967,
86+
"exp": 1632493867,
87+
"iat": 1632493567
88+
}
89+
```
90+
91+
{% ifversion ghec %}
92+
93+
## Establishing OIDC trust with your cloud provider
94+
95+
To use OIDC in your workflows, you must establish a trust relationship between {% data variables.product.github %} and your cloud provider. This trust relationship ensures that only authorized workflows can request access tokens for your cloud resources.
96+
97+
Before granting an access token, your cloud provider checks that the [`subject`](https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims) and any other claims used to set conditions in its trust settings match those in the request's JSON Web Token (JWT). If the trust configuration matches, your cloud provider issues a temporary access token to the workflow.
98+
99+
For steps and syntax for configuring OIDC trust and setting conditions for cloud providers, see [AUTOTITLE](/actions/reference/openid-connect-reference#oidc-claims-used-to-define-trust-conditions-on-cloud-roles).
100+
101+
## Configuring OIDC on {% data variables.enterprise.data_residency_site %}
102+
103+
If you are part of an enterprise that uses {% data variables.enterprise.data_residency %} and you're setting up OIDC on {% data variables.enterprise.data_residency_site %}, you must **substitute certain values** while configuring OIDC.
104+
105+
For more information, see [AUTOTITLE](/enterprise-cloud@latest/actions/reference/openid-connect-reference#substituted-values-on-ghecom).
106+
107+
{% endif %}
108+
109+
## Authenticating custom actions using OIDC
110+
111+
Custom actions use the `getIDToken()` method from the Actions toolkit or a `curl` command to authenticate using OIDC.
112+
113+
For more information, see [AUTOTITLE](/actions/reference/openid-connect-reference#methods-for-requesting-the-oidc-token).
114+
115+
## Updating your workflows for OIDC
116+
117+
{% data variables.product.prodname_actions %} workflows can use OIDC tokens instead of secrets to authenticate with cloud providers. Many popular cloud providers offer official login actions that simplify the process of using OIDC in your workflows. For more information about updating your workflows with specific cloud providers, see [AUTOTITLE](/actions/how-tos/security-for-github-actions/security-hardening-your-deployments).
118+
119+
## Next steps
120+
121+
For more information about configuring OIDC, see [AUTOTITLE](/actions/how-tos/security-for-github-actions/security-hardening-your-deployments).
122+
123+
For reference information about OIDC, see [AUTOTITLE](/actions/reference/openid-connect-reference).

content/actions/how-tos/security-for-github-actions/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Edit the trust policy, adding the `sub` field to the validation conditions. For
6969
}
7070
```
7171

72-
If you use a workflow with an environment, the `sub` field must reference the environment name: `repo:ORG-NAME/REPO-NAME:environment:ENVIRONMENT-NAME`. For more information, see [AUTOTITLE](/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#understanding-the-oidc-token).
72+
If you use a workflow with an environment, the `sub` field must reference the environment name: `repo:ORG-NAME/REPO-NAME:environment:ENVIRONMENT-NAME`. For more information, see [AUTOTITLE](/actions/reference/openid-connect-reference#filtering-for-a-specific-environment).
7373

7474
{% data reusables.actions.oidc-deployment-protection-rules %}
7575

content/actions/reference/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ children:
1919
- /metadata-syntax-reference
2020
- /actions-limits
2121
- /reusable-workflows-reference
22+
- /openid-connect-reference
2223
- /github_token-reference
2324
- /dockerfile-support-for-github-actions
2425
- /github-hosted-runners-reference

0 commit comments

Comments
 (0)