Skip to content

Commit

Permalink
Default audience to the WIF provider ID (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
sethvargo authored Oct 4, 2021
1 parent 02f3d58 commit f3c3e20
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
31 changes: 14 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ See [Examples](#examples) for more examples.
```

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

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

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

For example, you can map the attribute repository values (which can be
used later to restrict the authentication to specific repositories):
For example, you can map the attribute repository values (which can be used
later to restrict the authentication to specific repositories):

```sh
--attribute-mapping="google.subject=assertion.sub,attribute.repository=assertion.repository"
```
```sh
--attribute-mapping="google.subject=assertion.sub,attribute.repository=assertion.repository"
```

1. Allow authentications from the Workload Identity Provider to impersonate the
Service Account created above:
Expand Down Expand Up @@ -389,7 +386,7 @@ Here is a sample GitHub Token for reference for attribute mappings:
{
"jti": "...",
"sub": "repo:username/reponame:ref:refs/heads/master",
"aud": "sigstore",
"aud": "https://iam.googleapis.com/projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider",
"ref": "refs/heads/master",
"sha": "d11880f4f451ee35192135525dc974c56a3c1b28",
"repository": "username/reponame",
Expand Down
7 changes: 4 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ inputs:
audience:
description: |-
The value for the audience (aud) parameter in GitHub's generated OIDC
token. At present, the only valid value is "sigstore", but this variable
exists in case custom values are permitted in the future.
default: 'sigstore'
token. This value defaults to the value of workload_identity_provider,
which is also the default value Google Cloud expects for the audience
parameter on the token.
default: ''
required: false
create_credentials_file:
description: |-
Expand Down
3 changes: 2 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ function toCommandProperties(annotationProperties) {
}
return {
title: annotationProperties.title,
file: annotationProperties.file,
line: annotationProperties.startLine,
endLine: annotationProperties.endLine,
col: annotationProperties.startColumn,
Expand Down Expand Up @@ -225,7 +226,7 @@ function run() {
required: true,
});
const serviceAccount = core.getInput('service_account', { required: true });
const audience = core.getInput('audience');
const audience = core.getInput('audience') || `https://iam.googleapis.com/${workloadIdentityProvider}`;
const createCredentialsFile = core.getBooleanInput('create_credentials_file');
const activateCredentialsFile = core.getBooleanInput('activate_credentials_file');
const tokenFormat = core.getInput('token_format');
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ async function run(): Promise<void> {
required: true,
});
const serviceAccount = core.getInput('service_account', { required: true });
const audience = core.getInput('audience');
const audience =
core.getInput('audience') || `https://iam.googleapis.com/${workloadIdentityProvider}`;
const createCredentialsFile = core.getBooleanInput('create_credentials_file');
const activateCredentialsFile = core.getBooleanInput('activate_credentials_file');
const tokenFormat = core.getInput('token_format');
Expand Down

0 comments on commit f3c3e20

Please sign in to comment.