-
-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (44 loc) Β· 1.83 KB
/
example-oidc.yml
File metadata and controls
49 lines (44 loc) Β· 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
name: Test OIDC
on: push
jobs:
test-oidc:
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Test OIDC Token Request
run: |
echo "Testing OIDC token functionality"
echo "ACTIONS_ID_TOKEN_REQUEST_URL: $ACTIONS_ID_TOKEN_REQUEST_URL"
echo "ACTIONS_ID_TOKEN_REQUEST_TOKEN: ${ACTIONS_ID_TOKEN_REQUEST_TOKEN:0:20}..."
# Install curl if not available
if ! command -v curl &> /dev/null; then
echo "Installing curl..."
apt-get update -qq && apt-get install -y -qq curl jq > /dev/null 2>&1
fi
# Request OIDC token
if [ -n "$ACTIONS_ID_TOKEN_REQUEST_URL" ] && [ -n "$ACTIONS_ID_TOKEN_REQUEST_TOKEN" ]; then
echo "Requesting OIDC token..."
RESPONSE=$(curl -s -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
-H "Content-Type: application/json" \
-d '{"aud":"sigstore"}' \
"$ACTIONS_ID_TOKEN_REQUEST_URL")
if echo "$RESPONSE" | grep -q "value"; then
echo "β
Successfully obtained OIDC token"
TOKEN=$(echo "$RESPONSE" | grep -o '"value":"[^"]*"' | cut -d'"' -f4)
# Decode and display token claims
PAYLOAD=$(echo "$TOKEN" | cut -d'.' -f2)
# Add padding if needed
PADDED=$(printf '%s' "$PAYLOAD"; printf '=%.0s' {1..2})
echo "Token claims:"
echo "$PADDED" | base64 -d 2>/dev/null | jq . || echo "Could not decode token"
echo "β
OIDC integration test passed!"
else
echo "β Failed to obtain OIDC token"
echo "Response: $RESPONSE"
exit 1
fi
else
echo "β OIDC environment variables not set"
exit 1
fi