Skip to content

Commit c9f3ab2

Browse files
authored
Add custom aud claims (#841)
* Add custom aud claims Added description for single/multiple custom audience claima * Update oidc-pipelines.md replaced aud claim with audience * Update oidc-pipelines.md * Update oidc-pipelines.md * Update oidc-pipelines.md Implemented more feedback from daniel * Update oidc-pipelines.md * Update oidc-pipelines.md Content edits
1 parent ba9cb71 commit c9f3ab2

File tree

1 file changed

+56
-21
lines changed

1 file changed

+56
-21
lines changed

_docs/integrations/oidc-pipelines.md

Lines changed: 56 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Codefresh supports a subset of standard claims which are listed below. Generally
4848

4949

5050
* **audience (`aud`) claim**
51-
The `aud` claim is the Client ID, which is the URL of the Codefresh platform instance.
51+
The `aud` claim is the Client ID, which is by default the URL of the Codefresh platform instance. You can also configure a custom audience as a single-value string, or a list of custom audiences as an array of strings. See examples in [Step 3: Obtain OIDC ID token from OIDC provider](#step-3-obtain-oidc-id-token-from-oidc-provider).
5252
* **subject (`sub`) claim**
5353
The `sub` claim is a string value concatenated from the different claims representing the precise authentication and authorization required for access.
5454
* **issuer (`iss`) claim**
@@ -145,19 +145,26 @@ The first step is to integrate Codefresh as an OIDC identity provider in the clo
145145
Make sure you define the following settings:
146146

147147
1. **Provider type**: OIDC
148-
1. **Provider URL**: The URL of the OIDC provider's authorization server, which is the Codefresh OIDC domain, `https//oidc.codefresh.io`. <!--- You can configure one provider URL -->
149-
1. **Client ID**: The URL of the Codefresh platform. For SaaS, `https://g.codefresh.io`.
150-
For on-premises, this is the URL of your Codefresh instance, for example, `https://<my.company.com>/codefresh.io`.
148+
1. **Provider URL**: The URL of the OIDC provider's authorization server, which is the Codefresh OIDC domain:
149+
* For SaaS customers this would be `https//oidc.codefresh.io`.
150+
* For on-premises customers, this would be your on-premises instance of Codefresh, for example, `https//oidc.<my.company.com>/codefresh`.
151+
1. **Client ID**: The URL of the Codefresh platform:
152+
* For SaaS customers this would be `https://g.codefresh.io`.
153+
* For on-premises customers, this would be the URL of your Codefresh instance, for example, `https://<my.company.com>/codefresh`.
154+
>**NOTE**:
155+
The Client ID must align with the value set for `audience`. The provided URLs are valid for the default audience.
156+
For custom audiences, ensure that the Client ID corresponds to the specific custom audience you've configured.
151157

152158

153-
### Step 2: Create trust and configure claims for Codefresh OIDC identity provider
159+
### Step 2: Create trust for Codefresh OIDC identity provider
154160

155161
Once you've added Codefresh as an OIDC provider, the next step is to establish trust between your cloud provider and the OIDC provider, Codefresh in our case.
156162

157163
To create trust, define the claims, and configure the conditions for each claim.
158164

159165
* For Codefresh pipelines, the claims depend on the type of trigger.
160-
* The syntax to create the `sub` claim is similar for all identity providers, and is a concatenation of different claims, separated by colons. These generally include the account, pipeline, initiator, and for Git triggers, SCM (Source Code Management) data such as the repo URL or branch, and for PRs, the target branch to merge to.
166+
* The `sub` claim is a concatenation of different properties that encapsulate essential metadata on the authenticated entity.
167+
These properties include the account, pipeline, workflow, and if the workflow was triggered by a Git webhook or manually. Git triggers include also SCM (Source Code Management) data such as the repo URL or branch, and for PRs, the target branch to merge to.
161168

162169
See [Custom Codefresh claims](#custom-codefresh-claims) and [Codefresh trigger types for Subject claims](#codefresh-trigger-types-for-subject-claims) in this article.
163170

@@ -174,7 +181,6 @@ You can move on to the Codefresh platform to obtain and use the OIDC ID token in
174181
Obtain the ID token from the Codefresh OIDC provider to authenticate and authorize pipeline actions. Codefresh makes this simple by offering a dedicated Marketplace step, the `obtain-oidc-id-token` step, which you can seamlessly add to your pipeline, without the need for additional configuration or parameters on your part.
175182

176183

177-
178184
{% include
179185
image.html
180186
lightbox="true"
@@ -191,19 +197,18 @@ max-width="60%"
191197

192198
The step:
193199

194-
1. Makes an API call to the Codefresh OIDC provider passing the `CF_OIDC_REQUEST_TOKEN` and the `CF_OIDC_REQUEST_URL` variables.
195-
196-
>**NOTE**:
197-
Codefresh injects these two variables for every pipeline build, ensuring their availability for use, regardless of the cloud provider's authentication mechanism, whether it's OIDC ID tokens or static credentials.
198-
199-
200+
1. Makes an API call to the Codefresh OIDC provider passing the `CF_OIDC_REQUEST_TOKEN` and the `CF_OIDC_REQUEST_URL` variables.
200201
Example:
201202
`curl -H "Authorization: $CF_OIDC_REQUEST_TOKEN" "$CF_OIDC_REQUEST_URL"`
202203
where:
203-
* `CF_OIDC_REQUEST_TOKEN` is an access token used to request the OIDC ID token for the OIDC provider.
204-
* `CF_OIDC_REQUEST_URL` is the URL from which to request the ID token.
204+
* `CF_OIDC_REQUEST_TOKEN` is an access token used to request the OIDC ID token for the OIDC provider.
205+
* `CF_OIDC_REQUEST_URL` is the URL from which to request the ID token.
205206

206-
You can also insert the `curl` command as an API call in a freestyle step to get the same result.
207+
You can also insert the `curl` command as an API call in a `freestyle` step to get the same result.
208+
209+
>**NOTE**:
210+
Codefresh injects these two variables into every pipeline build, ensuring their availability for use in steps.
211+
207212

208213
{:start="2"}
209214
1. Sets the ID token in the `ID_TOKEN` environment variable.
@@ -230,6 +235,36 @@ steps:
230235
type: obtain-oidc-id-token
231236
```
232237
238+
239+
<br>
240+
241+
**Custom audiences with the `obtain-oidc-id-token` step**
242+
243+
Instead of using the default audience which is the Codefresh platform URL, you can pass single or multiple custom audiences in the `obtain-oidc-id-token` step.
244+
245+
Here are examples of single and multiple audiences in the `obtain-oidc-id-token` step.
246+
247+
* Single custom audience
248+
```yaml
249+
obtain_id_token:
250+
title: Obtain ID Token
251+
type: obtain-oidc-id-token
252+
arguments:
253+
AUDIENCE: "cosign"
254+
```
255+
256+
* Multiple custom audiences
257+
```yaml
258+
obtain_id_token:
259+
title: Obtain ID Token
260+
type: obtain-oidc-id-token
261+
arguments:
262+
AUDIENCE: "cosign,acme,custom"
263+
```
264+
265+
If you are using an API call in a `freestyle` step, you can pass the custom audience as a query parameter after `$CF_OIDC_REQUEST_URL`, for example, `"$CF_OIDC_REQUEST_URL?audience=cosign"`.
266+
`curl -H "Authorization: $CF_OIDC_REQUEST_TOKEN" "$CF_OIDC_REQUEST_URL?audience=cosign"`
267+
233268
### Step 4: Add steps to perform actions in the cloud provider
234269
Add steps to the pipeline YAML to perform the required actions in the cloud provider. The specific steps required depend on the cloud provider you choose.
235270

@@ -260,9 +295,12 @@ max-width="50%"
260295
1. In the Add an Identity Provider form, do the following:
261296
1. Select Provider type as **OpenID Connect**.
262297
1. Enter a meaningful name for the Provider.
263-
1. In the **Provider URL** field, enter the client ID for Codefresh:
298+
1. In the **Provider URL** field, enter the client ID for Codefresh:
264299
For SaaS customers, this is `https://g.codefresh.io`.
265-
For on-premises customers, this is the URL of their Codefresh instance.
300+
For on-premises, this is the URL of their codefresh instance.
301+
>**NOTE**:
302+
The Client ID must align with the value set for `audience`. The provided URLs are valid for the default audience.
303+
For custom audiences, ensure that the Client ID corresponds to the specific custom audience you've configured.
266304
1. Click **Add provider**.
267305

268306
{% include
@@ -446,9 +484,6 @@ assume_role:
446484
- aws s3 ls "s3://$BUCKET_NAME/"
447485
```
448486
>**NOTE:**
449-
450-
451-
452487
The cloud provider uses the ID token to authenticate the request to assume the role, after which the pipeline’s build performs the permitted action for the role, such as listing the objects in the S3 bucket.
453488

454489

0 commit comments

Comments
 (0)