Skip to content

Commit 267b25b

Browse files
CopilotSteve-GlassCopilothubwriter
authored
docs(actions): Add OIDC repository custom properties claims (Public Preview) (#60122)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Steve-Glass <84886334+Steve-Glass@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: hubwriter <hubwriter@github.com>
1 parent acceeee commit 267b25b

4 files changed

Lines changed: 121 additions & 1 deletion

File tree

375 KB
Loading

content/actions/concepts/security/openid-connect.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ The following example OIDC token uses a subject (`sub`) that references a job en
7575
"base_ref": "",
7676
"event_name": "workflow_dispatch",{% ifversion actions-OIDC-custom-claim-enterprise %}
7777
"enterprise": "avocado-corp",{% endif %}{% ifversion actions-OIDC-enterprise_id-claim %}
78-
"enterprise_id": "2",{% endif %}
78+
"enterprise_id": "2",{% endif %}{% ifversion oidc-custom-properties %}
79+
"repo_property_workspace_id": "ws-abc123",{% endif %}
7980
"ref_type": "branch",
8081
"job_workflow_ref": "octo-org/octo-automation/.github/workflows/oidc.yml@refs/heads/main",
8182
"iss": "{% ifversion ghes %}https://HOSTNAME/_services/token{% else %}https://token.actions.githubusercontent.com{% endif %}",
@@ -113,6 +114,50 @@ For more information, see [AUTOTITLE](/actions/reference/openid-connect-referenc
113114

114115
{% 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).
115116

117+
{% ifversion oidc-custom-properties %}
118+
119+
## Using repository custom properties as OIDC claims
120+
121+
> [!NOTE]
122+
> This feature is currently in public preview and is subject to change.
123+
124+
Organization and enterprise admins can include repository custom properties as claims in OIDC tokens. Once added, every repository in the organization or enterprise that has a value set for that custom property will automatically include it in its OIDC tokens, prefixed with `repo_property_`.
125+
126+
This allows you to create granular access policies that bind directly to your repository metadata, reducing configuration drift and eliminating the need to duplicate governance information across multiple systems.
127+
128+
### Prerequisites
129+
130+
* Custom properties must already be defined at the organization or enterprise level.
131+
* You must be an organization admin or enterprise admin.
132+
133+
### Adding a custom property to OIDC token claims
134+
135+
To include a custom property in OIDC tokens, use the REST API or the settings UI for your organization or enterprise.
136+
137+
**Using the settings UI:** Navigate to your organization or enterprise's Actions OIDC settings page to view and manage which custom properties are included in OIDC tokens.
138+
139+
![Screenshot of the OIDC settings for an organization or enterprise.](/assets/images/help/actions/actions-oidc-settings.png)
140+
141+
142+
* **Using the REST API:** Send a `POST` request to add a custom property to the OIDC token claims for your organization:
143+
144+
### Example OIDC token with a custom property
145+
146+
The following example shows an OIDC token that includes the `workspace_id` custom property:
147+
148+
```json
149+
{
150+
"sub": "repo:my-org/my-repo:ref:refs/heads/main",
151+
"aud": "https://github.com/my-org",
152+
"repository": "my-org/my-repo",
153+
"repo_property_workspace_id": "ws-abc123"
154+
}
155+
```
156+
157+
You can use the `repo_property_*` claims in your cloud provider's trust conditions to create flexible, attribute-based access control policies. For more information, see [AUTOTITLE](/actions/reference/openid-connect-reference#including-repository-custom-properties-in-oidc-tokens).
158+
159+
{% endif %}
160+
116161
## OIDC support for {% data variables.product.prodname_dependabot %}
117162

118163
{% data variables.product.prodname_dependabot %} can use OIDC to authenticate with private registries, eliminating the need to store long-lived credentials as repository secrets. With OIDC-based authentication, {% data variables.product.prodname_dependabot %} update jobs can dynamically obtain short-lived credentials from your cloud identity provider.

content/actions/reference/security/oidc.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ The OIDC token includes the following claims.
6868
| `repository_id`| The ID of the repository from where the workflow is running. |
6969
| `repository_owner`| The name of the organization in which the `repository` is stored. |
7070
| `repository_owner_id`| The ID of the organization in which the `repository` is stored. |
71+
| {% ifversion oidc-custom-properties %} |
72+
| `repo_property_*`| Custom properties defined at the organization or enterprise level that are included as claims in the OIDC token, prefixed with `repo_property_`. For more information, see [AUTOTITLE](#including-repository-custom-properties-in-oidc-tokens). |
73+
| {% endif %} |
7174
| `run_id`| The ID of the workflow run that triggered the workflow. |
7275
| `run_number`| The number of times this workflow has been run. |
7376
| `run_attempt`| The number of times this workflow run has been retried. |
@@ -177,6 +180,9 @@ You can security harden your OIDC configuration by customizing the claims that a
177180
* You can customize values for {% ifversion ghec %}`issuer` or {% endif %}`audience` claims. See {% ifversion ghec %}[Customizing the `issuer` value for an enterprise](#customizing-the-issuer-value-for-an-enterprise) and {% endif %}[Customizing the `audience` value](#customizing-the-audience-value).
178181
* You can customize the format of your OIDC configuration by setting conditions on the subject (`sub`) claim that require JWT tokens to originate from a specific repository, reusable workflow, or other source.
179182
* You can define granular OIDC policies by using additional OIDC token claims, such as `repository_id` and `repository_visibility`. See [AUTOTITLE](/actions/concepts/security/openid-connect#understanding-the-oidc-token).
183+
{% ifversion oidc-custom-properties %}
184+
* You can include repository custom properties as claims in OIDC tokens, enabling attribute-based access control policies. See [AUTOTITLE](#including-repository-custom-properties-in-oidc-tokens).
185+
{% endif %}
180186

181187
### Customizing the `audience` value
182188

@@ -214,6 +220,52 @@ After this setting is applied, the JWT will contain the updated `iss` value. In
214220

215221
{% endif %}
216222

223+
{% ifversion oidc-custom-properties %}
224+
225+
### Including repository custom properties in OIDC tokens
226+
227+
> [!NOTE]
228+
> This feature is currently in public preview and is subject to change.
229+
230+
Organization and enterprise admins can select repository custom properties to include as claims in Actions OIDC tokens. Once a custom property is added to the OIDC configuration, every repository in the organization or enterprise that has a value set for that property will automatically include it in its OIDC tokens. The property name appears in the token prefixed with `repo_property_`.
231+
232+
This allows you to create attribute-based access control (ABAC) policies in your cloud provider that bind directly to your repository metadata, reducing configuration drift and eliminating the need to manage separate access configuration for each repository.
233+
234+
#### Prerequisites for including custom properties
235+
236+
* Custom properties must already be defined at the organization or enterprise level.
237+
* You must be an organization admin or enterprise admin.
238+
* After adding a custom property to the OIDC configuration, all repositories in the organization or enterprise that have a value set for that property will automatically include it in their OIDC tokens.
239+
240+
#### Adding a custom property to OIDC token claims
241+
242+
You can manage which custom properties are included in OIDC tokens using the settings UI or the REST API.
243+
244+
* **Using the settings UI:**
245+
246+
Navigate to your organization's or enterprise's Actions OIDC settings to view and configure which custom properties are included in OIDC tokens.
247+
248+
* **Using the REST API:**
249+
250+
To add a custom property to your organization's OIDC token claims, send a `POST` request to:
251+
252+
#### Example token with a custom property
253+
254+
After a custom property is added to the OIDC configuration, repositories with a value set for that property will include it in their tokens. In the following example, the `workspace_id` custom property appears as `repo_property_workspace_id` in the token:
255+
256+
```json
257+
{
258+
"sub": "repo:my-org/my-repo:ref:refs/heads/main",
259+
"aud": "https://github.com/my-org",
260+
"repository": "my-org/my-repo",
261+
"repo_property_workspace_id": "ws-abc123"
262+
}
263+
```
264+
265+
You can use these `repo_property_*` claims as conditions in your cloud provider's trust policy. For an example, see [Example: Filtering on a repository custom property](#example-filtering-on-a-repository-custom-property).
266+
267+
{% endif %}
268+
217269
### Customizing the subject claims for an organization or repository
218270

219271
To help improve security, compliance, and standardization, you can customize the standard claims to suit your required access conditions. If your cloud provider supports conditions on subject claims, you can create a condition that checks whether the `sub` value matches the path of the reusable workflow, such as `"job_workflow_ref:octo-org/octo-automation/.github/workflows/oidc.yml@refs/heads/main"`. The exact format will vary depending on your cloud provider's OIDC configuration. To configure the matching condition on {% data variables.product.prodname_dotcom %}, you can use the REST API to require that the `sub` claim must always include a specific custom claim, such as `job_workflow_ref`. You can use the REST API to apply a customization template for the OIDC subject claim; for example, you can require that the `sub` claim within the OIDC token must always include a specific custom claim, such as `job_workflow_ref`. For more information, see [AUTOTITLE](/rest/actions/oidc).
@@ -368,6 +420,26 @@ This example demonstrates how to handle context value with `:`. For example, whe
368420
In your cloud provider's OIDC configuration, configure the `sub` condition to require that claims must include a specific value for `environment` and `repository_owner`. For example: `"sub": "environment:production%3Aeastus:repository_owner:octo-org"`.
369421
{% endif %}
370422

423+
{% ifversion oidc-custom-properties %}
424+
425+
#### Example: Filtering on a repository custom property
426+
427+
This example template allows the `sub` claim to include a repository custom property claim. Custom properties included in OIDC tokens appear prefixed with `repo_property_` in the token, but the `include_claim_keys` value uses the full claim name as it appears in the token.
428+
429+
{% data reusables.actions.use-request-body-api %}
430+
431+
```json
432+
{
433+
"include_claim_keys": [
434+
"repo_property_workspace_id"
435+
]
436+
}
437+
```
438+
439+
In your cloud provider's OIDC configuration, configure the `sub` condition to require that claims must include a specific value for `repo_property_workspace_id`. For example: `"sub": "repo_property_workspace_id:ws-abc123"`.
440+
441+
{% endif %}
442+
371443
#### Resetting organization template customizations
372444

373445
This example template resets the subject claims to the default format. This template effectively opts out of any organization-level customization policy.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
versions:
2+
fpt: '*'
3+
ghec: '*'

0 commit comments

Comments
 (0)