Skip to content

Commit cfa8793

Browse files
authored
Switch to OIDC Federation Service instead of GitHub App (#2794)
Currently, the [Gardener GitHub-Actions App](https://github.com/apps/gardener-github-actions) is used to provide more privileged access than available via the default `GITHUB_TOKEN`, for example to circumvent branch protection rules (GitHub Apps can be configured as bypassers) or cross repository privileges. To prevent sharing the GitHub App secret with each and every repository/workflow which requires usage of it, the [GitHub OIDC Federation Service](https://github.com/gardener/github-oidc-federation) has been developed. In essence, it holds the credentials for a central GitHub App and creates short-lived access tokens with a configured scope based on a centrally configured OIDC configuration. See related changes which have been necessary for this repository: - gardener/.github-oidc@1cc1fe4 Signed-off-by: Jonas Brand (i538859) <j.brand@sap.com>
1 parent b4a72dc commit cfa8793

File tree

6 files changed

+33
-40
lines changed

6 files changed

+33
-40
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ jobs:
1919
version-commit-callback-action-path: .github/actions/prepare-release
2020
checkout-fetch-depth: 0
2121
permissions:
22-
contents: read
23-
pull-requests: write
22+
id-token: write
2423

2524
oci-images:
2625
name: Build OCI-Images

.github/workflows/cherry-pick-reusable.yaml

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@ on:
1111
description: 'The comment body containing cherry-pick commands'
1212
required: true
1313
type: string
14-
secrets:
15-
GARDENER_GITHUB_ACTIONS_PRIVATE_KEY:
16-
description: 'Private key for the Gardener GitHub Actions app'
17-
required: true
1814

1915
permissions:
20-
contents: none # we rely on the GitHub App token instead
16+
id-token: write # required for GitHub OIDC Federation Service token
2117

2218
jobs:
2319
parse-branches:
@@ -26,12 +22,14 @@ jobs:
2622
branches: ${{ steps.parse.outputs.branches }}
2723
has-branches: ${{ steps.parse.outputs.has-branches }}
2824
steps:
29-
- uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
25+
- uses: gardener/cc-utils/.github/actions/github-auth@master
3026
id: token
3127
with:
32-
app-id: ${{ vars.GARDENER_GITHUB_ACTIONS_APP_ID }}
33-
private-key: ${{ secrets.GARDENER_GITHUB_ACTIONS_PRIVATE_KEY }}
34-
permission-pull-requests: write
28+
token-server: ${{ vars.FEDERATED_GITHUB_ACCESS_TOKEN_SERVER }}
29+
repositories: ${{ github.event.repository.name }}
30+
permissions: |
31+
contents: read
32+
pull-requests: write
3533
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3634
with:
3735
ref: ${{ github.event.repository.default_branch }}
@@ -53,14 +51,15 @@ jobs:
5351
target-branch: ${{ fromJson(needs.parse-branches.outputs.branches) }}
5452
fail-fast: false
5553
steps:
56-
- uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
54+
- uses: gardener/cc-utils/.github/actions/github-auth@master
5755
id: token
5856
with:
59-
app-id: ${{ vars.GARDENER_GITHUB_ACTIONS_APP_ID }}
60-
private-key: ${{ secrets.GARDENER_GITHUB_ACTIONS_PRIVATE_KEY }}
61-
permission-contents: write
62-
permission-pull-requests: write
63-
permission-workflows: write
57+
token-server: ${{ vars.FEDERATED_GITHUB_ACCESS_TOKEN_SERVER }}
58+
repositories: ${{ github.event.repository.name }}
59+
permissions: |
60+
contents: write
61+
pull-requests: write
62+
workflows: write
6463
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
6564
with:
6665
ref: ${{ github.event.repository.default_branch }}
@@ -77,12 +76,14 @@ jobs:
7776
needs: [parse-branches, cherry-pick]
7877
if: always() && needs.parse-branches.outputs.has-branches == 'true'
7978
steps:
80-
- uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
79+
- uses: gardener/cc-utils/.github/actions/github-auth@master
8180
id: token
8281
with:
83-
app-id: ${{ vars.GARDENER_GITHUB_ACTIONS_APP_ID }}
84-
private-key: ${{ secrets.GARDENER_GITHUB_ACTIONS_PRIVATE_KEY }}
85-
permission-pull-requests: write
82+
token-server: ${{ vars.FEDERATED_GITHUB_ACCESS_TOKEN_SERVER }}
83+
repositories: ${{ github.event.repository.name }}
84+
permissions: |
85+
contents: read
86+
pull-requests: write
8687
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
8788
with:
8889
ref: ${{ github.event.repository.default_branch }}

.github/workflows/cherry-pick.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
types: [created]
66

77
permissions:
8-
contents: none # we rely on the GitHub App token instead
8+
id-token: write # required for GitHub OIDC Federation Service token
99

1010
jobs:
1111
cherry-pick:
@@ -21,5 +21,3 @@ jobs:
2121
with:
2222
pr-number: ${{ github.event.issue.number }}
2323
comment-body: ${{ github.event.comment.body }}
24-
secrets:
25-
GARDENER_GITHUB_ACTIONS_PRIVATE_KEY: ${{ secrets.GARDENER_GITHUB_ACTIONS_PRIVATE_KEY }}

.github/workflows/non-release.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,15 @@ jobs:
2323
mode: snapshot
2424
secrets: inherit
2525
permissions:
26-
contents: write
26+
contents: read
2727
packages: write
2828
id-token: write
29-
pull-requests: write
3029

3130
component-descriptor:
3231
if: ${{ github.event_name != 'pull_request_target' || (github.event_name == 'pull_request_target' && github.event.label.name == vars.DEFAULT_LABEL_OK_TO_TEST && vars.DEFAULT_LABEL_OK_TO_TEST != '') }}
3332
uses: gardener/cc-utils/.github/workflows/post-build.yaml@master
3433
needs:
3534
- build
36-
secrets: inherit
3735
permissions:
3836
id-token: write
3937
contents: write

.github/workflows/prepare-hotfix-branch.yaml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ on:
1010
required: false
1111
type: string
1212
default: ''
13-
secrets:
14-
GARDENER_GITHUB_ACTIONS_PRIVATE_KEY:
15-
description: "Private key for the Gardener GitHub Actions app"
16-
required: true
1713
workflow_dispatch:
1814
inputs:
1915
tag:
@@ -27,7 +23,7 @@ on:
2723
default: .github/actions/prepare-hotfix
2824

2925
permissions:
30-
contents: none # we rely on the GitHub App token instead
26+
id-token: write # required for GitHub OIDC Federation Service token
3127

3228
jobs:
3329
prepare-hotfix:
@@ -36,14 +32,15 @@ jobs:
3632
TAG: ${{ inputs.tag }}
3733
steps:
3834
- name: Create GitHub App token
39-
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
35+
uses: gardener/cc-utils/.github/actions/github-auth@master
4036
id: app-token
4137
with:
42-
app-id: ${{ vars.GARDENER_GITHUB_ACTIONS_APP_ID }}
43-
private-key: ${{ secrets.GARDENER_GITHUB_ACTIONS_PRIVATE_KEY }}
44-
permission-contents: write
45-
permission-pull-requests: write
46-
permission-workflows: write
38+
token-server: ${{ vars.FEDERATED_GITHUB_ACCESS_TOKEN_SERVER }}
39+
repositories: ${{ github.event.repository.name }}
40+
permissions: |
41+
contents: write
42+
pull-requests: write
43+
workflows: write
4744
4845
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
4946
with:

.github/workflows/release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ on:
1212
jobs:
1313
build:
1414
uses: ./.github/workflows/build.yaml
15+
secrets: inherit
1516
permissions:
16-
contents: write
17+
contents: read
1718
id-token: write
1819
packages: write
19-
pull-requests: write
2020
with:
2121
mode: release
2222

0 commit comments

Comments
 (0)