Skip to content

Commit f3c3e20

Browse files
authored
Default audience to the WIF provider ID (#23)
1 parent 02f3d58 commit f3c3e20

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

README.md

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ See [Examples](#examples) for more examples.
7979
```
8080

8181
- `audience`: (Optional) The value for the audience (`aud`) parameter in the
82-
generated GitHub Actions OIDC token. At present, the only valid value is
83-
`"sigstore"`, but this variable exists in case custom values are permitted
84-
in the future. The default value is `"sigstore"`.
82+
generated GitHub Actions OIDC token. This value defaults to the value of
83+
`workload_identity_provider`, which is also the default value Google Cloud
84+
expects for the audience parameter on the token.
8585

8686
- `create_credentials_file`: (Optional) If true, the action will securely
8787
generate a credentials file which can be used for authentication via gcloud
@@ -331,23 +331,20 @@ the [gcloud][gcloud] command-line tool.
331331
--workload-identity-pool="my-pool" \
332332
--display-name="Demo provider" \
333333
--attribute-mapping="google.subject=assertion.sub,attribute.actor=assertion.actor,attribute.aud=assertion.aud" \
334-
--issuer-uri="https://vstoken.actions.githubusercontent.com" \
335-
--allowed-audiences="sigstore"
334+
--issuer-uri="https://vstoken.actions.githubusercontent.com"
336335
```
337336

338-
- The audience of "sigstore" is currently the only value GitHub allows.
339-
- The attribute mappings map claims in the GitHub Actions JWT to
340-
assertions you can make about the request (like the repository or GitHub
341-
username of the principal invoking the GitHub Action). These can be used
342-
to further restrict the authentication using `--attribute-condition`
343-
flags.
337+
The attribute mappings map claims in the GitHub Actions JWT to assertions
338+
you can make about the request (like the repository or GitHub username of
339+
the principal invoking the GitHub Action). These can be used to further
340+
restrict the authentication using `--attribute-condition` flags.
344341

345-
For example, you can map the attribute repository values (which can be
346-
used later to restrict the authentication to specific repositories):
342+
For example, you can map the attribute repository values (which can be used
343+
later to restrict the authentication to specific repositories):
347344

348-
```sh
349-
--attribute-mapping="google.subject=assertion.sub,attribute.repository=assertion.repository"
350-
```
345+
```sh
346+
--attribute-mapping="google.subject=assertion.sub,attribute.repository=assertion.repository"
347+
```
351348

352349
1. Allow authentications from the Workload Identity Provider to impersonate the
353350
Service Account created above:
@@ -389,7 +386,7 @@ Here is a sample GitHub Token for reference for attribute mappings:
389386
{
390387
"jti": "...",
391388
"sub": "repo:username/reponame:ref:refs/heads/master",
392-
"aud": "sigstore",
389+
"aud": "https://iam.googleapis.com/projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider",
393390
"ref": "refs/heads/master",
394391
"sha": "d11880f4f451ee35192135525dc974c56a3c1b28",
395392
"repository": "username/reponame",

action.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ inputs:
3434
audience:
3535
description: |-
3636
The value for the audience (aud) parameter in GitHub's generated OIDC
37-
token. At present, the only valid value is "sigstore", but this variable
38-
exists in case custom values are permitted in the future.
39-
default: 'sigstore'
37+
token. This value defaults to the value of workload_identity_provider,
38+
which is also the default value Google Cloud expects for the audience
39+
parameter on the token.
40+
default: ''
4041
required: false
4142
create_credentials_file:
4243
description: |-

dist/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ function toCommandProperties(annotationProperties) {
9191
}
9292
return {
9393
title: annotationProperties.title,
94+
file: annotationProperties.file,
9495
line: annotationProperties.startLine,
9596
endLine: annotationProperties.endLine,
9697
col: annotationProperties.startColumn,
@@ -225,7 +226,7 @@ function run() {
225226
required: true,
226227
});
227228
const serviceAccount = core.getInput('service_account', { required: true });
228-
const audience = core.getInput('audience');
229+
const audience = core.getInput('audience') || `https://iam.googleapis.com/${workloadIdentityProvider}`;
229230
const createCredentialsFile = core.getBooleanInput('create_credentials_file');
230231
const activateCredentialsFile = core.getBooleanInput('activate_credentials_file');
231232
const tokenFormat = core.getInput('token_format');

src/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ async function run(): Promise<void> {
3535
required: true,
3636
});
3737
const serviceAccount = core.getInput('service_account', { required: true });
38-
const audience = core.getInput('audience');
38+
const audience =
39+
core.getInput('audience') || `https://iam.googleapis.com/${workloadIdentityProvider}`;
3940
const createCredentialsFile = core.getBooleanInput('create_credentials_file');
4041
const activateCredentialsFile = core.getBooleanInput('activate_credentials_file');
4142
const tokenFormat = core.getInput('token_format');

0 commit comments

Comments
 (0)