Default audience to the WIF provider ID (#23)

This commit is contained in:
Seth Vargo 2021-10-04 12:14:08 -04:00 committed by GitHub
parent 02f3d58995
commit f3c3e206c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 22 deletions

View File

@ -79,9 +79,9 @@ See [Examples](#examples) for more examples.
``` ```
- `audience`: (Optional) The value for the audience (`aud`) parameter in the - `audience`: (Optional) The value for the audience (`aud`) parameter in the
generated GitHub Actions OIDC token. At present, the only valid value is generated GitHub Actions OIDC token. This value defaults to the value of
`"sigstore"`, but this variable exists in case custom values are permitted `workload_identity_provider`, which is also the default value Google Cloud
in the future. The default value is `"sigstore"`. expects for the audience parameter on the token.
- `create_credentials_file`: (Optional) If true, the action will securely - `create_credentials_file`: (Optional) If true, the action will securely
generate a credentials file which can be used for authentication via gcloud generate a credentials file which can be used for authentication via gcloud
@ -331,23 +331,20 @@ the [gcloud][gcloud] command-line tool.
--workload-identity-pool="my-pool" \ --workload-identity-pool="my-pool" \
--display-name="Demo provider" \ --display-name="Demo provider" \
--attribute-mapping="google.subject=assertion.sub,attribute.actor=assertion.actor,attribute.aud=assertion.aud" \ --attribute-mapping="google.subject=assertion.sub,attribute.actor=assertion.actor,attribute.aud=assertion.aud" \
--issuer-uri="https://vstoken.actions.githubusercontent.com" \ --issuer-uri="https://vstoken.actions.githubusercontent.com"
--allowed-audiences="sigstore"
``` ```
- The audience of "sigstore" is currently the only value GitHub allows. The attribute mappings map claims in the GitHub Actions JWT to assertions
- The attribute mappings map claims in the GitHub Actions JWT to you can make about the request (like the repository or GitHub username of
assertions you can make about the request (like the repository or GitHub the principal invoking the GitHub Action). These can be used to further
username of the principal invoking the GitHub Action). These can be used restrict the authentication using `--attribute-condition` flags.
to further restrict the authentication using `--attribute-condition`
flags.
For example, you can map the attribute repository values (which can be For example, you can map the attribute repository values (which can be used
used later to restrict the authentication to specific repositories): later to restrict the authentication to specific repositories):
```sh ```sh
--attribute-mapping="google.subject=assertion.sub,attribute.repository=assertion.repository" --attribute-mapping="google.subject=assertion.sub,attribute.repository=assertion.repository"
``` ```
1. Allow authentications from the Workload Identity Provider to impersonate the 1. Allow authentications from the Workload Identity Provider to impersonate the
Service Account created above: Service Account created above:
@ -389,7 +386,7 @@ Here is a sample GitHub Token for reference for attribute mappings:
{ {
"jti": "...", "jti": "...",
"sub": "repo:username/reponame:ref:refs/heads/master", "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", "ref": "refs/heads/master",
"sha": "d11880f4f451ee35192135525dc974c56a3c1b28", "sha": "d11880f4f451ee35192135525dc974c56a3c1b28",
"repository": "username/reponame", "repository": "username/reponame",

View File

@ -34,9 +34,10 @@ inputs:
audience: audience:
description: |- description: |-
The value for the audience (aud) parameter in GitHub's generated OIDC The value for the audience (aud) parameter in GitHub's generated OIDC
token. At present, the only valid value is "sigstore", but this variable token. This value defaults to the value of workload_identity_provider,
exists in case custom values are permitted in the future. which is also the default value Google Cloud expects for the audience
default: 'sigstore' parameter on the token.
default: ''
required: false required: false
create_credentials_file: create_credentials_file:
description: |- description: |-

3
dist/index.js vendored
View File

@ -91,6 +91,7 @@ function toCommandProperties(annotationProperties) {
} }
return { return {
title: annotationProperties.title, title: annotationProperties.title,
file: annotationProperties.file,
line: annotationProperties.startLine, line: annotationProperties.startLine,
endLine: annotationProperties.endLine, endLine: annotationProperties.endLine,
col: annotationProperties.startColumn, col: annotationProperties.startColumn,
@ -225,7 +226,7 @@ function run() {
required: true, required: true,
}); });
const serviceAccount = core.getInput('service_account', { 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 createCredentialsFile = core.getBooleanInput('create_credentials_file');
const activateCredentialsFile = core.getBooleanInput('activate_credentials_file'); const activateCredentialsFile = core.getBooleanInput('activate_credentials_file');
const tokenFormat = core.getInput('token_format'); const tokenFormat = core.getInput('token_format');

View File

@ -35,7 +35,8 @@ async function run(): Promise<void> {
required: true, required: true,
}); });
const serviceAccount = core.getInput('service_account', { 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 createCredentialsFile = core.getBooleanInput('create_credentials_file');
const activateCredentialsFile = core.getBooleanInput('activate_credentials_file'); const activateCredentialsFile = core.getBooleanInput('activate_credentials_file');
const tokenFormat = core.getInput('token_format'); const tokenFormat = core.getInput('token_format');