Skip to content

Commit 57e235e

Browse files
committed
draft: add TTL parameter
1 parent 3458a09 commit 57e235e

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

incubating/obtain-oidc-id-token/step.yaml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '1.0'
22
kind: step-type
33
metadata:
4-
version: 1.2.3
4+
version: 1.3.0
55
name: obtain-oidc-id-token
66
description: >-
77
Obtain ID token from Codefresh OIDC Provider
@@ -84,6 +84,10 @@ spec:
8484
"AUDIENCE": {
8585
"type": "string",
8686
"description": "the audience of the ID token. For multiple audiences, use a comma-separated list. Defaults to the address of the Codefresh platform instance (For SaaS, https://g.codefresh.io)"
87+
},
88+
"TTL": {
89+
"type": "number",
90+
"description": "TODO"
8791
}
8892
}
8993
}
@@ -111,23 +115,47 @@ spec:
111115
shell: bash
112116
environment:
113117
- 'AUDIENCE=${{AUDIENCE}}'
118+
- 'TTL=${{TTL}}'
114119
commands:
115120
- |
116121
URL="$CF_OIDC_REQUEST_URL"
117122
123+
echo "vasil url: ${URL}"
124+
118125
# This means that audience was provided by the user
119126
if [ -z "$(echo "$AUDIENCE" | grep '${{AUDIENCE')" ]; then
120127
ENCODED_AUDIENCE=$(echo -n "$AUDIENCE" | jq -s -R -r '@uri')
121128
URL="$URL?audience=$ENCODED_AUDIENCE"
122129
fi
123130
131+
# This means that audience was provided by the user
132+
if [ -z "$(echo "$TTL" | grep '${{TTL')" ]; then
133+
# ENCODED_AUDIENCE=$(echo -n "$AUDIENCE" | jq -s -R -r '@uri')
134+
135+
# TODO: don't use ? if audience was already added
136+
URL="$URL?ttl=$TTL"
137+
fi
138+
139+
echo "vasil url: ${URL}"
140+
124141
RESPONSE=$(curl -H "Authorization: $CF_OIDC_REQUEST_TOKEN" "$URL")
142+
143+
echo "vasil response: ${RESPONSE}"
144+
125145
ID_TOKEN=$(echo "$RESPONSE" | jq -r ".id_token")
126146
147+
echo "vasil token: ${ID_TOKEN}"
148+
127149
if [ -z "$ID_TOKEN" ] || [ "$ID_TOKEN" = "null" ]; then
150+
echo "vasil exit flow"
151+
128152
echo "Failed to obtain ID token; API response:"
129153
echo "$RESPONSE"
130154
exit 1
131155
fi
132156
157+
echo "vasil before cf_export"
158+
133159
cf_export ID_TOKEN=$ID_TOKEN --mask
160+
161+
echo "vasil after cf_export"

0 commit comments

Comments
 (0)