-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor to support access and id tokens (#3)
- Loading branch information
Showing
7 changed files
with
212 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,13 +9,34 @@ on: | |
- 'main' | ||
|
||
jobs: | ||
run: | ||
name: 'test' | ||
unit: | ||
name: 'unit' | ||
runs-on: 'ubuntu-latest' | ||
|
||
steps: | ||
- uses: 'actions/checkout@v2' | ||
|
||
- uses: 'actions/setup-node@master' | ||
with: | ||
node-version: '12.x' | ||
|
||
- name: 'npm install' | ||
run: 'npm install' | ||
|
||
- name: 'npm lint' | ||
run: 'npm run lint' | ||
|
||
- name: 'npm test' | ||
run: 'npm run test' | ||
|
||
access_token: | ||
name: 'access_token' | ||
permissions: | ||
id-token: write | ||
contents: read | ||
runs-on: '${{ matrix.operating-system }}' | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
operating-system: | ||
- 'ubuntu-latest' | ||
|
@@ -28,19 +49,40 @@ jobs: | |
with: | ||
node-version: '12.x' | ||
|
||
- id: 'integration' | ||
- id: 'access-token' | ||
name: 'integration' | ||
uses: './' | ||
with: | ||
token_format: 'access_token' | ||
workload_identity_provider: 'projects/469401941463/locations/global/workloadIdentityPools/github-actions/providers/github-oidc-auth-google-cloud' | ||
service_account: '[email protected]' | ||
id_token_audience: 'foo' | ||
|
||
- name: 'npm install' | ||
run: 'npm install' | ||
id_token: | ||
name: 'id_token' | ||
permissions: | ||
id-token: write | ||
contents: read | ||
runs-on: '${{ matrix.operating-system }}' | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
operating-system: | ||
- 'ubuntu-latest' | ||
- 'windows-latest' | ||
- 'macos-latest' | ||
steps: | ||
- uses: 'actions/checkout@v2' | ||
|
||
- name: 'npm lint' | ||
run: 'npm run lint' | ||
- uses: 'actions/setup-node@master' | ||
with: | ||
node-version: '12.x' | ||
|
||
- name: 'npm test' | ||
run: 'npm run test' | ||
- id: 'id-token' | ||
name: 'integration' | ||
uses: './' | ||
with: | ||
token_format: 'id_token' | ||
workload_identity_provider: 'projects/469401941463/locations/global/workloadIdentityPools/github-actions/providers/github-oidc-auth-google-cloud' | ||
service_account: '[email protected]' | ||
id_token_audience: 'my-aud' | ||
id_token_include_email: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ jobs: | |
name: 'Authenticate to Google Cloud' | ||
uses: 'github.com/sethvargo/oidc-auth-google-cloud' | ||
with: | ||
token_format: 'access_token' | ||
workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider' | ||
service_account: '[email protected]' | ||
|
||
|
@@ -74,23 +75,40 @@ jobs: | |
`"sigstore"`, but this variable exists in case custom values are permitted | ||
in the future. The default value is `"sigstore"`. | ||
|
||
- `token_format`: (Optional) Format of the generated token. For OAuth 2.0 | ||
access tokens, specify "access_token". For OIDC tokens, specify "id_token". | ||
The default value is "access_token". | ||
|
||
- `delegates`: (Optional) List of additional service account emails or unique | ||
identities to use for impersonation in the chain. By default there are no | ||
delegates. | ||
|
||
- `lifetime`: (Optional) Desired lifetime duration of the access token, in | ||
seconds. This must be specified as the number of seconds with a trailing "s" | ||
(e.g. 30s). The default value is 1 hour (3600s). | ||
- `access_token_lifetime`: (Optional) Desired lifetime duration of the access | ||
token, in seconds. This must be specified as the number of seconds with a | ||
trailing "s" (e.g. 30s). The default value is 1 hour (3600s). | ||
|
||
- `access_token_scopes`: (Optional) List of OAuth 2.0 access scopes to be | ||
included in the generated token. This is only valid when "token_format" is | ||
"access_token". The default value is: | ||
|
||
```text | ||
https://www.googleapis.com/auth/cloud-platform | ||
``` | ||
|
||
- `id_token_audience`: (Optional) The audience for the generated ID Token. | ||
|
||
- `id_token_include_email`: (Optional) Optional parameter of whether to | ||
include the service account email in the generated token. If true, the token | ||
will contain "email" and "email_verified" claims. This is only valid when | ||
"token_format" is "access_token". The default value is false. | ||
|
||
## Outputs | ||
|
||
- `access_token`: The authenticated Google Cloud access token for calling | ||
other Google Cloud APIs. | ||
|
||
- `expiration`: The RFC3339 UTC "Zulu" format timestamp when the token | ||
expires. | ||
- `access_token_expiration`: The RFC3339 UTC "Zulu" format timestamp when the | ||
token expires. | ||
|
||
- `id_token`: The authenticated Google Cloud ID token. This token is only | ||
generated when `id_token_audience` input parameter is provided. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.