@@ -25,6 +25,8 @@ pub struct GitHubClaims {
25
25
pub repository : String ,
26
26
pub workflow_ref : String ,
27
27
pub environment : Option < String > ,
28
+ pub run_id : String ,
29
+ pub sha : String ,
28
30
}
29
31
30
32
impl GitHubClaims {
@@ -116,7 +118,9 @@ mod tests {
116
118
"repository_owner_id": "65",
117
119
"repository": "octo-org/octo-repo",
118
120
"workflow_ref": "octo-org/octo-automation/.github/workflows/oidc.yml@refs/heads/main",
119
- "environment": "prod"
121
+ "environment": "prod",
122
+ "run_id": "example-run-id",
123
+ "sha": "example-sha"
120
124
}
121
125
"# ) ;
122
126
@@ -132,6 +136,8 @@ mod tests {
132
136
"aud" : AUDIENCE ,
133
137
"repository" : "octo-org/octo-repo" ,
134
138
"repository_owner_id" : "65" ,
139
+ "run_id" : "example-run-id" ,
140
+ "sha" : "example-sha" ,
135
141
"workflow_ref" : "octo-org/octo-automation/.github/workflows/oidc.yml@refs/heads/main" ,
136
142
"iss" : "https://token.actions.githubusercontent.com" ,
137
143
"exp" : now + 30 ,
@@ -148,7 +154,9 @@ mod tests {
148
154
"repository_owner_id": "65",
149
155
"repository": "octo-org/octo-repo",
150
156
"workflow_ref": "octo-org/octo-automation/.github/workflows/oidc.yml@refs/heads/main",
151
- "environment": null
157
+ "environment": null,
158
+ "run_id": "example-run-id",
159
+ "sha": "example-sha"
152
160
}
153
161
"# ) ;
154
162
@@ -163,14 +171,16 @@ mod tests {
163
171
"aud" : AUDIENCE ,
164
172
"repository" : "octo-org/octo-repo" ,
165
173
"repository_owner_id" : "65" ,
174
+ "run_id" : "example-run-id" ,
175
+ "sha" : "example-sha" ,
166
176
"workflow_ref" : "octo-org/octo-automation/.github/workflows/oidc.yml@refs/heads/main" ,
167
177
"iss" : "https://token.actions.githubusercontent.com" ,
168
178
"exp" : now + 30 ,
169
179
"iat" : now,
170
180
} ) ) ?;
171
181
172
182
let error = GitHubClaims :: decode ( & jwt, AUDIENCE , & DECODING_KEY ) . unwrap_err ( ) ;
173
- assert_compact_debug_snapshot ! ( error, @r#"Error(Json(Error("missing field `jti`", line: 1, column: 251 )))"# ) ;
183
+ assert_compact_debug_snapshot ! ( error, @r#"Error(Json(Error("missing field `jti`", line: 1, column: 297 )))"# ) ;
174
184
175
185
Ok ( ( ) )
176
186
}
@@ -184,6 +194,8 @@ mod tests {
184
194
"aud" : "somebody-else" ,
185
195
"repository" : "octo-org/octo-repo" ,
186
196
"repository_owner_id" : "65" ,
197
+ "run_id" : "example-run-id" ,
198
+ "sha" : "example-sha" ,
187
199
"workflow_ref" : "octo-org/octo-automation/.github/workflows/oidc.yml@refs/heads/main" ,
188
200
"iss" : "https://token.actions.githubusercontent.com" ,
189
201
"exp" : now + 30 ,
@@ -205,6 +217,8 @@ mod tests {
205
217
"aud" : [ AUDIENCE , "somebody-else" ] ,
206
218
"repository" : "octo-org/octo-repo" ,
207
219
"repository_owner_id" : "65" ,
220
+ "run_id" : "example-run-id" ,
221
+ "sha" : "example-sha" ,
208
222
"workflow_ref" : "octo-org/octo-automation/.github/workflows/oidc.yml@refs/heads/main" ,
209
223
"iss" : "https://token.actions.githubusercontent.com" ,
210
224
"exp" : now + 30 ,
@@ -224,14 +238,16 @@ mod tests {
224
238
"jti" : "example-id" ,
225
239
"aud" : AUDIENCE ,
226
240
"repository_owner_id" : "65" ,
241
+ "run_id" : "example-run-id" ,
242
+ "sha" : "example-sha" ,
227
243
"workflow_ref" : "octo-org/octo-automation/.github/workflows/oidc.yml@refs/heads/main" ,
228
244
"iss" : "https://token.actions.githubusercontent.com" ,
229
245
"exp" : now + 30 ,
230
246
"iat" : now,
231
247
} ) ) ?;
232
248
233
249
let error = GitHubClaims :: decode ( & jwt, AUDIENCE , & DECODING_KEY ) . unwrap_err ( ) ;
234
- assert_compact_debug_snapshot ! ( error, @r#"Error(Json(Error("missing field `repository`", line: 1, column: 236 )))"# ) ;
250
+ assert_compact_debug_snapshot ! ( error, @r#"Error(Json(Error("missing field `repository`", line: 1, column: 282 )))"# ) ;
235
251
236
252
Ok ( ( ) )
237
253
}
@@ -243,14 +259,16 @@ mod tests {
243
259
"jti" : "example-id" ,
244
260
"aud" : AUDIENCE ,
245
261
"repository" : "octo-org/octo-repo" ,
262
+ "run_id" : "example-run-id" ,
263
+ "sha" : "example-sha" ,
246
264
"workflow_ref" : "octo-org/octo-automation/.github/workflows/oidc.yml@refs/heads/main" ,
247
265
"iss" : "https://token.actions.githubusercontent.com" ,
248
266
"exp" : now + 30 ,
249
267
"iat" : now,
250
268
} ) ) ?;
251
269
252
270
let error = GitHubClaims :: decode ( & jwt, AUDIENCE , & DECODING_KEY ) . unwrap_err ( ) ;
253
- assert_compact_debug_snapshot ! ( error, @r#"Error(Json(Error("missing field `repository_owner_id`", line: 1, column: 243 )))"# ) ;
271
+ assert_compact_debug_snapshot ! ( error, @r#"Error(Json(Error("missing field `repository_owner_id`", line: 1, column: 289 )))"# ) ;
254
272
255
273
Ok ( ( ) )
256
274
}
@@ -263,13 +281,15 @@ mod tests {
263
281
"aud" : AUDIENCE ,
264
282
"repository" : "octo-org/octo-repo" ,
265
283
"repository_owner_id" : "65" ,
284
+ "run_id" : "example-run-id" ,
285
+ "sha" : "example-sha" ,
266
286
"iss" : "https://token.actions.githubusercontent.com" ,
267
287
"exp" : now + 30 ,
268
288
"iat" : now,
269
289
} ) ) ?;
270
290
271
291
let error = GitHubClaims :: decode ( & jwt, AUDIENCE , & DECODING_KEY ) . unwrap_err ( ) ;
272
- assert_compact_debug_snapshot ! ( error, @r#"Error(Json(Error("missing field `workflow_ref`", line: 1, column: 185 )))"# ) ;
292
+ assert_compact_debug_snapshot ! ( error, @r#"Error(Json(Error("missing field `workflow_ref`", line: 1, column: 231 )))"# ) ;
273
293
274
294
Ok ( ( ) )
275
295
}
@@ -283,6 +303,8 @@ mod tests {
283
303
"aud" : AUDIENCE ,
284
304
"repository" : "octo-org/octo-repo" ,
285
305
"repository_owner_id" : "65" ,
306
+ "run_id" : "example-run-id" ,
307
+ "sha" : "example-sha" ,
286
308
"workflow_ref" : "octo-org/octo-automation/.github/workflows/oidc.yml@refs/heads/main" ,
287
309
"exp" : now + 30 ,
288
310
"iat" : now,
@@ -303,6 +325,8 @@ mod tests {
303
325
"aud" : AUDIENCE ,
304
326
"repository" : "octo-org/octo-repo" ,
305
327
"repository_owner_id" : "65" ,
328
+ "run_id" : "example-run-id" ,
329
+ "sha" : "example-sha" ,
306
330
"workflow_ref" : "octo-org/octo-automation/.github/workflows/oidc.yml@refs/heads/main" ,
307
331
"iss" : "https://gitlab.com" ,
308
332
"exp" : now + 30 ,
@@ -324,13 +348,15 @@ mod tests {
324
348
"aud" : AUDIENCE ,
325
349
"repository" : "octo-org/octo-repo" ,
326
350
"repository_owner_id" : "65" ,
351
+ "run_id" : "example-run-id" ,
352
+ "sha" : "example-sha" ,
327
353
"workflow_ref" : "octo-org/octo-automation/.github/workflows/oidc.yml@refs/heads/main" ,
328
354
"iss" : "https://token.actions.githubusercontent.com" ,
329
355
"iat" : now,
330
356
} ) ) ?;
331
357
332
358
let error = GitHubClaims :: decode ( & jwt, AUDIENCE , & DECODING_KEY ) . unwrap_err ( ) ;
333
- assert_compact_debug_snapshot ! ( error, @r#"Error(Json(Error("missing field `exp`", line: 1, column: 253 )))"# ) ;
359
+ assert_compact_debug_snapshot ! ( error, @r#"Error(Json(Error("missing field `exp`", line: 1, column: 299 )))"# ) ;
334
360
335
361
Ok ( ( ) )
336
362
}
@@ -344,6 +370,8 @@ mod tests {
344
370
"aud" : AUDIENCE ,
345
371
"repository" : "octo-org/octo-repo" ,
346
372
"repository_owner_id" : "65" ,
373
+ "run_id" : "example-run-id" ,
374
+ "sha" : "example-sha" ,
347
375
"workflow_ref" : "octo-org/octo-automation/.github/workflows/oidc.yml@refs/heads/main" ,
348
376
"iss" : "https://token.actions.githubusercontent.com" ,
349
377
"exp" : now - 3000 ,
@@ -365,13 +393,15 @@ mod tests {
365
393
"aud" : AUDIENCE ,
366
394
"repository" : "octo-org/octo-repo" ,
367
395
"repository_owner_id" : "65" ,
396
+ "run_id" : "example-run-id" ,
397
+ "sha" : "example-sha" ,
368
398
"workflow_ref" : "octo-org/octo-automation/.github/workflows/oidc.yml@refs/heads/main" ,
369
399
"iss" : "https://token.actions.githubusercontent.com" ,
370
400
"exp" : now + 30 ,
371
401
} ) ) ?;
372
402
373
403
let error = GitHubClaims :: decode ( & jwt, AUDIENCE , & DECODING_KEY ) . unwrap_err ( ) ;
374
- assert_compact_debug_snapshot ! ( error, @r#"Error(Json(Error("missing field `iat`", line: 1, column: 253 )))"# ) ;
404
+ assert_compact_debug_snapshot ! ( error, @r#"Error(Json(Error("missing field `iat`", line: 1, column: 299 )))"# ) ;
375
405
376
406
Ok ( ( ) )
377
407
}
@@ -385,6 +415,8 @@ mod tests {
385
415
"aud" : AUDIENCE ,
386
416
"repository" : "octo-org/octo-repo" ,
387
417
"repository_owner_id" : "65" ,
418
+ "run_id" : "example-run-id" ,
419
+ "sha" : "example-sha" ,
388
420
"workflow_ref" : "octo-org/octo-automation/.github/workflows/oidc.yml@refs/heads/main" ,
389
421
"iss" : "https://token.actions.githubusercontent.com" ,
390
422
"exp" : now + 300 ,
0 commit comments