Skip to content

Commit 838d36d

Browse files
committed
/.github/workflows/bump-dependency.yaml: fix auth job
1 parent bc2a456 commit 838d36d

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

.github/workflows/bump-dependency.yaml

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,40 @@ on:
66

77
jobs:
88
auth:
9-
name: Authenticate Caller
10-
runs-on: ubuntu-22.04
9+
runs-on: ubuntu-latest
10+
outputs:
11+
token: ${{ steps.decrypt.outputs.token }}
1112
steps:
12-
- name: Check client token
13+
- name: Install age
14+
run: |
15+
sudo apt-get update
16+
sudo apt-get install -y age
17+
18+
- name: Decrypt client token
19+
id: decrypt
1320
env:
14-
PAYLOAD_TOKEN: ${{ github.event.client_payload.token }}
15-
EXPECTED_TOKEN: ${{ secrets.CLIENT_AUTH_TOKEN }}
21+
AGE_PRIVATE_KEY: ${{ secrets.CLIENT_AGE_PRIVATE_KEY }}
22+
CIPHERTEXT: ${{ github.event.client_payload.client_auth_ciphertext }}
1623
run: |
1724
set -euo pipefail
18-
# refuse to proceed without a token
19-
if [ -z "${PAYLOAD_TOKEN:-}" ]; then
20-
echo "Unauthorized: missing token"
21-
exit 1
22-
fi
23-
# simple equality check; doesn't echo secrets
24-
if [ "${PAYLOAD_TOKEN}" != "${EXPECTED_TOKEN}" ]; then
25-
echo "Unauthorized: bad token"
25+
umask 177
26+
printf '%s\n' "$AGE_PRIVATE_KEY" > ./age.key
27+
28+
TOKEN=$(printf '%s' "$CIPHERTEXT" | age -d -i ./age.key)
29+
30+
echo "::add-mask::$TOKEN"
31+
echo "token=$TOKEN" >> "$GITHUB_OUTPUT"
32+
33+
- name: Validate token
34+
env:
35+
TOKEN: ${{ steps.decrypt.outputs.token }}
36+
EXPECTED: ${{ secrets.CLIENT_AUTH_TOKEN }}
37+
run: |
38+
set -euo pipefail
39+
if [ "$TOKEN" != "$EXPECTED" ]; then
40+
echo "Unauthorized dispatch: token mismatch" >&2
2641
exit 1
2742
fi
28-
echo "Caller authenticated"
2943
3044
get-label:
3145
name: Get Label

0 commit comments

Comments
 (0)