Repository navigation
826 lines (800 loc) · 38.7 KB
/
Copy pathgoogle.yml
File metadata and controls
826 lines (800 loc) · 38.7 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
name: Google Cloud Test
on:
push:
branches:
- main
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
env:
RUST_BACKTRACE: "1"
REQSIGN_GOOGLE_CLOUD_STORAGE_SCOPE: https://www.googleapis.com/auth/devstorage.read_only
REQSIGN_GOOGLE_CLOUD_STORAGE_URL: https://storage.googleapis.com/storage/v1/b/reqsign
REQSIGN_GOOGLE_CLOUD_STORAGE_PROBE_URL: https://storage.googleapis.com/storage/v1/b/reqsign/o/live%2Fcredential-ok?alt=media
REQSIGN_GOOGLE_CLOUD_STORAGE_SIGNED_PROBE_URL: https://storage.googleapis.com/reqsign/live/credential-ok
REQSIGN_GOOGLE_CAB_BUCKET: reqsign
REQSIGN_GOOGLE_CAB_OBJECT_PREFIX: live/cab/allowed/
REQSIGN_GOOGLE_IMPERSONATED_SERVICE_ACCOUNT: reqsign-impersonated@reqsign.iam.gserviceaccount.com
permissions: {}
jobs:
unit_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Run deterministic tests and redacted real-response replays
run: |
cargo test -p reqsign-google --lib --tests --all-features --no-fail-fast
cargo test -p reqsign-google --doc --all-features --no-fail-fast
check_secrets:
runs-on: ubuntu-latest
outputs:
trusted: ${{ steps.check.outputs.trusted }}
steps:
- name: Check whether live credentials are available
id: check
env:
EVENT_NAME: ${{ github.event_name }}
IS_FORK: ${{ github.event.pull_request.head.repo.fork }}
ACTOR: ${{ github.actor }}
run: |
if [[ "$EVENT_NAME" == "push" || ( "$EVENT_NAME" == "pull_request" && "$IS_FORK" == "false" && "$ACTOR" != "dependabot[bot]" ) ]]; then
echo "trusted=true" >> "$GITHUB_OUTPUT"
else
echo "trusted=false" >> "$GITHUB_OUTPUT"
fi
prepare_live_resources:
name: Prepare Google Cloud live probes
needs: check_secrets
if: needs.check_secrets.outputs.trusted == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Setup 1Password Connect
uses: 1Password/load-secrets-action/configure@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
with:
connect-host: ${{ secrets.OP_CONNECT_HOST }}
connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
- name: Load workload identity configuration
uses: 1Password/load-secrets-action@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
with:
export-env: true
env:
GOOGLE_WORKLOAD_IDENTITY_PROVIDER: op://reqsign/google/workload_identity_provider
GOOGLE_SERVICE_ACCOUNT: op://reqsign/google/service_account_email
- name: Authenticate probe writer through workload identity
id: auth
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
with:
create_credentials_file: false
token_format: access_token
access_token_lifetime: 900s
access_token_scopes: https://www.googleapis.com/auth/cloud-platform
workload_identity_provider: ${{ env.GOOGLE_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ env.GOOGLE_SERVICE_ACCOUNT }}
- name: Create and verify fixed Cloud Storage probes
env:
GOOGLE_ACCESS_TOKEN: ${{ steps.auth.outputs.access_token }}
run: |
for object in live%2Fcredential-ok live%2Fcab%2Fallowed%2Fcredential-ok; do
curl --fail-with-body --silent --show-error \
--request POST \
--header "Authorization: Bearer $GOOGLE_ACCESS_TOKEN" \
--header "Content-Type: text/plain" \
--data-binary $'reqsign-live-google-ok\n' \
"https://storage.googleapis.com/upload/storage/v1/b/reqsign/o?uploadType=media&name=$object" \
>/dev/null
done
test "$(curl --fail-with-body --silent --show-error \
--header "Authorization: Bearer $GOOGLE_ACCESS_TOKEN" \
"$REQSIGN_GOOGLE_CLOUD_STORAGE_PROBE_URL")" = "reqsign-live-google-ok"
test_static_provider:
name: StaticCredentialProvider live test
needs:
- check_secrets
- prepare_live_resources
if: needs.check_secrets.outputs.trusted == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup 1Password Connect
uses: 1Password/load-secrets-action/configure@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
with:
connect-host: ${{ secrets.OP_CONNECT_HOST }}
connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
- name: Load Google service-account credential
id: load_secrets
uses: 1Password/load-secrets-action@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
env:
GOOGLE_CREDENTIAL_BASE64: op://reqsign/google/credential_base64
- name: Test StaticCredentialProvider against Cloud Storage
env:
GOOGLE_CREDENTIAL_BASE64: ${{ steps.load_secrets.outputs.GOOGLE_CREDENTIAL_BASE64 }}
REQSIGN_GOOGLE_TEST_STATIC: "on"
run: |
export REQSIGN_GOOGLE_CREDENTIAL="$GOOGLE_CREDENTIAL_BASE64"
cargo test -p reqsign-google --test main credential_providers::static_provider:: -- --no-capture
test_file_provider:
name: FileCredentialProvider live test
needs:
- check_secrets
- prepare_live_resources
if: needs.check_secrets.outputs.trusted == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup 1Password Connect
uses: 1Password/load-secrets-action/configure@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
with:
connect-host: ${{ secrets.OP_CONNECT_HOST }}
connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
- name: Load Google service-account credential
id: load_secrets
uses: 1Password/load-secrets-action@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
env:
GOOGLE_CREDENTIAL_BASE64: op://reqsign/google/credential_base64
- name: Set up service-account credential file
env:
GOOGLE_CREDENTIAL_BASE64: ${{ steps.load_secrets.outputs.GOOGLE_CREDENTIAL_BASE64 }}
run: |
credential_path="$RUNNER_TEMP/google-service-account.json"
printf '%s' "$GOOGLE_CREDENTIAL_BASE64" | base64 --decode > "$credential_path"
test -s "$credential_path"
chmod 600 "$credential_path"
echo "GOOGLE_APPLICATION_CREDENTIALS=$credential_path" >> "$GITHUB_ENV"
- name: Test FileCredentialProvider against Cloud Storage
env:
REQSIGN_GOOGLE_TEST_FILE: "on"
run: |
cargo test -p reqsign-google --test main credential_providers::file::test_file_credential_provider_live -- --exact --no-capture
test_env_provider:
name: EnvCredentialProvider live test
needs:
- check_secrets
- prepare_live_resources
if: needs.check_secrets.outputs.trusted == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup 1Password Connect
uses: 1Password/load-secrets-action/configure@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
with:
connect-host: ${{ secrets.OP_CONNECT_HOST }}
connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
- name: Load Google service-account credential
id: load_secrets
uses: 1Password/load-secrets-action@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
env:
GOOGLE_CREDENTIAL_BASE64: op://reqsign/google/credential_base64
- name: Set up environment credential file
env:
GOOGLE_CREDENTIAL_BASE64: ${{ steps.load_secrets.outputs.GOOGLE_CREDENTIAL_BASE64 }}
run: |
credential_path="$RUNNER_TEMP/google-service-account.json"
printf '%s' "$GOOGLE_CREDENTIAL_BASE64" | base64 --decode > "$credential_path"
test -s "$credential_path"
chmod 600 "$credential_path"
echo "GOOGLE_APPLICATION_CREDENTIALS=$credential_path" >> "$GITHUB_ENV"
- name: Test EnvCredentialProvider against Cloud Storage
env:
REQSIGN_GOOGLE_TEST_ENV: "on"
run: |
cargo test -p reqsign-google --test main credential_providers::env::test_env_credential_provider_live -- --exact --no-capture
test_well_known_provider:
name: WellKnownCredentialProvider live test
needs:
- check_secrets
- prepare_live_resources
if: needs.check_secrets.outputs.trusted == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup 1Password Connect
uses: 1Password/load-secrets-action/configure@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
with:
connect-host: ${{ secrets.OP_CONNECT_HOST }}
connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
- name: Load Google service-account credential
id: load_secrets
uses: 1Password/load-secrets-action@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
env:
GOOGLE_CREDENTIAL_BASE64: op://reqsign/google/credential_base64
- name: Set up well-known service-account credential
env:
GOOGLE_CREDENTIAL_BASE64: ${{ steps.load_secrets.outputs.GOOGLE_CREDENTIAL_BASE64 }}
run: |
mkdir -p "$HOME/.config/gcloud"
printf '%s' "$GOOGLE_CREDENTIAL_BASE64" | base64 --decode > "$HOME/.config/gcloud/application_default_credentials.json"
test -s "$HOME/.config/gcloud/application_default_credentials.json"
chmod 600 "$HOME/.config/gcloud/application_default_credentials.json"
- name: Test WellKnownCredentialProvider against Cloud Storage
env:
REQSIGN_GOOGLE_TEST_WELL_KNOWN: "on"
run: |
cargo test -p reqsign-google --test main credential_providers::env::test_well_known_credential_provider_live -- --exact --no-capture
test_default_provider:
name: DefaultCredentialProvider live test
needs:
- check_secrets
- prepare_live_resources
if: needs.check_secrets.outputs.trusted == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup 1Password Connect
uses: 1Password/load-secrets-action/configure@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
with:
connect-host: ${{ secrets.OP_CONNECT_HOST }}
connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
- name: Load Google service-account credential
id: load_secrets
uses: 1Password/load-secrets-action@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
env:
GOOGLE_CREDENTIAL_BASE64: op://reqsign/google/credential_base64
- name: Set up default credential file
env:
GOOGLE_CREDENTIAL_BASE64: ${{ steps.load_secrets.outputs.GOOGLE_CREDENTIAL_BASE64 }}
run: |
credential_path="$RUNNER_TEMP/google-service-account.json"
printf '%s' "$GOOGLE_CREDENTIAL_BASE64" | base64 --decode > "$credential_path"
test -s "$credential_path"
chmod 600 "$credential_path"
echo "GOOGLE_APPLICATION_CREDENTIALS=$credential_path" >> "$GITHUB_ENV"
- name: Test DefaultCredentialProvider against Cloud Storage
env:
REQSIGN_GOOGLE_TEST_DEFAULT: "on"
run: |
cargo test -p reqsign-google --test main credential_providers::default::test_default_credential_provider -- --exact --no-capture
test_service_account_token_provider:
name: ServiceAccountTokenCredentialProvider live test
needs:
- check_secrets
- prepare_live_resources
if: needs.check_secrets.outputs.trusted == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup 1Password Connect
uses: 1Password/load-secrets-action/configure@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
with:
connect-host: ${{ secrets.OP_CONNECT_HOST }}
connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
- name: Load Google service-account credential
id: load_secrets
uses: 1Password/load-secrets-action@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
env:
GOOGLE_CREDENTIAL_BASE64: op://reqsign/google/credential_base64
- name: Test ServiceAccountTokenCredentialProvider and server-side CAB
env:
GOOGLE_CREDENTIAL_BASE64: ${{ steps.load_secrets.outputs.GOOGLE_CREDENTIAL_BASE64 }}
REQSIGN_GOOGLE_TEST_SERVICE_ACCOUNT_TOKEN: "on"
run: |
export REQSIGN_GOOGLE_CREDENTIAL="$GOOGLE_CREDENTIAL_BASE64"
cargo test -p reqsign-google --test service_account_token -- --no-capture
test_authorized_user_provider:
name: Authorized user provider live test
needs:
- check_secrets
- prepare_live_resources
if: needs.check_secrets.outputs.trusted == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup 1Password Connect
uses: 1Password/load-secrets-action/configure@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
with:
connect-host: ${{ secrets.OP_CONNECT_HOST }}
connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
- name: Load authorized-user credential
id: load_secrets
uses: 1Password/load-secrets-action@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
env:
GOOGLE_AUTHORIZED_USER_BASE64: op://reqsign/google/authorized_user_base64
- name: Set up authorized-user credential
env:
GOOGLE_AUTHORIZED_USER_BASE64: ${{ steps.load_secrets.outputs.GOOGLE_AUTHORIZED_USER_BASE64 }}
run: |
credential_path="$RUNNER_TEMP/google-authorized-user.json"
printf '%s' "$GOOGLE_AUTHORIZED_USER_BASE64" | base64 --decode > "$credential_path"
test -s "$credential_path"
chmod 600 "$credential_path"
mkdir -p "$HOME/.config/gcloud"
cp "$credential_path" "$HOME/.config/gcloud/application_default_credentials.json"
echo "REQSIGN_GOOGLE_AUTHORIZED_USER_CREDENTIALS=$credential_path" >> "$GITHUB_ENV"
- name: Test AuthorizedUserCredentialProvider against Cloud Storage
env:
REQSIGN_GOOGLE_TEST_AUTHORIZED_USER: "on"
REQSIGN_GOOGLE_TEST_AUTHORIZED_USER_GCLOUD: "on"
run: |
cargo test -p reqsign-google --test main credential_providers::authorized_user:: -- --no-capture
test_workload_identity_provider:
name: Workload Identity provider live test
needs:
- check_secrets
- prepare_live_resources
if: needs.check_secrets.outputs.trusted == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup 1Password Connect
uses: 1Password/load-secrets-action/configure@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
with:
connect-host: ${{ secrets.OP_CONNECT_HOST }}
connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
- name: Load workload identity configuration
uses: 1Password/load-secrets-action@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
with:
export-env: true
env:
GOOGLE_WORKLOAD_IDENTITY_PROVIDER: op://reqsign/google/workload_identity_provider
GOOGLE_SERVICE_ACCOUNT: op://reqsign/google/service_account_email
- name: Load caller-bound GitHub OIDC subject token
run: |
audience="//iam.googleapis.com/${GOOGLE_WORKLOAD_IDENTITY_PROVIDER}"
encoded_audience=$(jq --null-input --raw-output --arg value "$audience" '$value | @uri')
subject_token=$(curl --fail-with-body --silent --show-error --header "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=${encoded_audience}" |
jq --exit-status --raw-output '.value')
test -n "$subject_token"
echo "::add-mask::$subject_token"
echo "REQSIGN_GOOGLE_SUBJECT_TOKEN=$subject_token" >> "$GITHUB_ENV"
echo "REQSIGN_GOOGLE_WORKLOAD_IDENTITY_AUDIENCE=$audience" >> "$GITHUB_ENV"
- name: Authenticate to Google Cloud through workload identity
id: auth
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
with:
create_credentials_file: true
token_format: access_token
access_token_lifetime: 3600s
access_token_scopes: https://www.googleapis.com/auth/cloud-platform
workload_identity_provider: ${{ env.GOOGLE_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ env.GOOGLE_SERVICE_ACCOUNT }}
- name: Test Workload Identity and caller-provided subject tokens
env:
REQSIGN_GOOGLE_TEST_WORKLOAD_IDENTITY: "on"
REQSIGN_GOOGLE_ACCESS_TOKEN: ${{ steps.auth.outputs.access_token }}
run: |
cargo test -p reqsign-google --test main credential_providers::external_account:: -- --no-capture
test_token_provider:
name: TokenCredentialProvider live test
needs:
- check_secrets
- prepare_live_resources
if: needs.check_secrets.outputs.trusted == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup 1Password Connect
uses: 1Password/load-secrets-action/configure@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
with:
connect-host: ${{ secrets.OP_CONNECT_HOST }}
connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
- name: Load workload identity configuration
uses: 1Password/load-secrets-action@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
with:
export-env: true
env:
GOOGLE_WORKLOAD_IDENTITY_PROVIDER: op://reqsign/google/workload_identity_provider
GOOGLE_SERVICE_ACCOUNT: op://reqsign/google/service_account_email
- name: Authenticate to Google Cloud through workload identity
id: auth
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
with:
create_credentials_file: false
token_format: access_token
access_token_lifetime: 3600s
access_token_scopes: https://www.googleapis.com/auth/cloud-platform
workload_identity_provider: ${{ env.GOOGLE_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ env.GOOGLE_SERVICE_ACCOUNT }}
- name: Test TokenCredentialProvider against Cloud Storage
env:
REQSIGN_GOOGLE_TEST_TOKEN: "on"
REQSIGN_GOOGLE_ACCESS_TOKEN: ${{ steps.auth.outputs.access_token }}
run: |
cargo test -p reqsign-google --test main credential_providers::token::test_token_credential_provider_live -- --exact --no-capture
test_service_account_impersonation_provider:
name: ServiceAccountImpersonationCredentialProvider live test
needs:
- check_secrets
- prepare_live_resources
if: needs.check_secrets.outputs.trusted == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup 1Password Connect
uses: 1Password/load-secrets-action/configure@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
with:
connect-host: ${{ secrets.OP_CONNECT_HOST }}
connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
- name: Load workload identity configuration
uses: 1Password/load-secrets-action@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
with:
export-env: true
env:
GOOGLE_WORKLOAD_IDENTITY_PROVIDER: op://reqsign/google/workload_identity_provider
GOOGLE_SERVICE_ACCOUNT: op://reqsign/google/service_account_email
- name: Authenticate to Google Cloud through workload identity
id: auth
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
with:
create_credentials_file: false
token_format: access_token
access_token_lifetime: 3600s
access_token_scopes: https://www.googleapis.com/auth/cloud-platform
workload_identity_provider: ${{ env.GOOGLE_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ env.GOOGLE_SERVICE_ACCOUNT }}
- name: Test typed service-account impersonation and IAM signBlob
env:
REQSIGN_GOOGLE_TEST_SERVICE_ACCOUNT_IMPERSONATION: "on"
REQSIGN_GOOGLE_ACCESS_TOKEN: ${{ steps.auth.outputs.access_token }}
run: |
cargo test -p reqsign-google --test main credential_providers::service_account_impersonation:: -- --no-capture
test_client_side_cab:
name: Client-side Credential Access Boundary live test
needs:
- check_secrets
- prepare_live_resources
if: needs.check_secrets.outputs.trusted == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup 1Password Connect
uses: 1Password/load-secrets-action/configure@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
with:
connect-host: ${{ secrets.OP_CONNECT_HOST }}
connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
- name: Load workload identity configuration
uses: 1Password/load-secrets-action@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
with:
export-env: true
env:
GOOGLE_WORKLOAD_IDENTITY_PROVIDER: op://reqsign/google/workload_identity_provider
GOOGLE_SERVICE_ACCOUNT: op://reqsign/google/service_account_email
- name: Authenticate to Google Cloud through workload identity
id: auth
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
with:
create_credentials_file: false
token_format: access_token
access_token_lifetime: 3600s
access_token_scopes: https://www.googleapis.com/auth/cloud-platform
workload_identity_provider: ${{ env.GOOGLE_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ env.GOOGLE_SERVICE_ACCOUNT }}
- name: Test client-side Credential Access Boundary
env:
REQSIGN_GOOGLE_TEST_CAB: "on"
REQSIGN_GOOGLE_CAB_SOURCE_TOKEN: ${{ steps.auth.outputs.access_token }}
run: |
export REQSIGN_GOOGLE_CAB_SOURCE_EXPIRES_AT
REQSIGN_GOOGLE_CAB_SOURCE_EXPIRES_AT=$(date --utc --date='+50 minutes' '+%Y-%m-%dT%H:%M:%SZ')
cargo test -p reqsign-google --features credential-access-boundary-client-side --test credential_access_boundary -- --no-capture
signing_test:
name: Google request signing live test
needs:
- check_secrets
- prepare_live_resources
if: needs.check_secrets.outputs.trusted == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup 1Password Connect
uses: 1Password/load-secrets-action/configure@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
with:
connect-host: ${{ secrets.OP_CONNECT_HOST }}
connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
- name: Load Google service-account credential
id: load_secrets
uses: 1Password/load-secrets-action@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
env:
GOOGLE_CREDENTIAL_BASE64: op://reqsign/google/credential_base64
- name: Test standard and service-account signed URL signing
env:
GOOGLE_CREDENTIAL_BASE64: ${{ steps.load_secrets.outputs.GOOGLE_CREDENTIAL_BASE64 }}
REQSIGN_GOOGLE_TEST: "on"
run: |
export REQSIGN_GOOGLE_CREDENTIAL="$GOOGLE_CREDENTIAL_BASE64"
cargo test -p reqsign-google --test main signing:: -- --no-capture
test_impersonated_adc_provider:
name: Impersonated ADC provider live test
needs:
- check_secrets
- prepare_live_resources
if: needs.check_secrets.outputs.trusted == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup 1Password Connect
uses: 1Password/load-secrets-action/configure@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
with:
connect-host: ${{ secrets.OP_CONNECT_HOST }}
connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
- name: Load impersonated ADC credential
id: load_secrets
uses: 1Password/load-secrets-action@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
env:
GOOGLE_IMPERSONATED_ADC_BASE64: op://reqsign/google/impersonated_sa_base64
- name: Set up impersonated ADC credential
env:
GOOGLE_IMPERSONATED_ADC_BASE64: ${{ steps.load_secrets.outputs.GOOGLE_IMPERSONATED_ADC_BASE64 }}
run: |
credential_path="$RUNNER_TEMP/google-impersonated-adc.json"
printf '%s' "$GOOGLE_IMPERSONATED_ADC_BASE64" | base64 --decode > "$credential_path"
test -s "$credential_path"
chmod 600 "$credential_path"
echo "REQSIGN_GOOGLE_IMPERSONATED_SERVICE_ACCOUNT_CREDENTIALS=$credential_path" >> "$GITHUB_ENV"
- name: Test ImpersonatedServiceAccountCredentialProvider against Cloud Storage
env:
REQSIGN_GOOGLE_TEST_IMPERSONATED_SERVICE_ACCOUNT: "on"
run: |
cargo test -p reqsign-google --test main credential_providers::impersonated_service_account::test_impersonated_service_account_credential_provider -- --exact --no-capture
test_vm_metadata_provider:
name: VM metadata provider live test
needs:
- check_secrets
- prepare_live_resources
if: needs.check_secrets.outputs.trusted == 'true'
runs-on: ubuntu-latest
timeout-minutes: 30
env:
GOOGLE_PROJECT_ID: reqsign
GOOGLE_METADATA_SERVICE_ACCOUNT: reqsign-metadata@reqsign.iam.gserviceaccount.com
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup 1Password Connect
uses: 1Password/load-secrets-action/configure@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
with:
connect-host: ${{ secrets.OP_CONNECT_HOST }}
connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
- name: Load Google control-plane configuration
uses: 1Password/load-secrets-action@70062d7a876d3eb6334754fa26efd2fbd90c32f2 # v5.0.1
with:
export-env: true
env:
GOOGLE_WORKLOAD_IDENTITY_PROVIDER: op://reqsign/google/workload_identity_provider
GOOGLE_SERVICE_ACCOUNT: op://reqsign/google/service_account_email
- name: Authenticate Google control plane through workload identity
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
with:
create_credentials_file: true
workload_identity_provider: ${{ env.GOOGLE_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ env.GOOGLE_SERVICE_ACCOUNT }}
- name: Set up Google Cloud CLI
uses: google-github-actions/setup-gcloud@aa5489c8933f4cc7a4f7d45035b3b1440c9c10db # v3.0.1
with:
project_id: ${{ env.GOOGLE_PROJECT_ID }}
- name: Build VM metadata live test binary
id: build
run: |
messages="$RUNNER_TEMP/google-metadata-cargo-messages.json"
cargo test -p reqsign-google --test main --no-run --message-format=json > "$messages"
executable=$(jq --raw-output 'select(.profile.test == true and .target.name == "main") | .executable' "$messages" | tail -n 1)
test -n "$executable"
test -x "$executable"
echo "executable=$executable" >> "$GITHUB_OUTPUT"
- name: Upload VM metadata live test binary
id: artifact
env:
TEST_EXECUTABLE: ${{ steps.build.outputs.executable }}
run: |
artifact_name="ci-artifact-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
gcloud storage cp "$TEST_EXECUTABLE" "gs://reqsign/$artifact_name" --quiet
echo "name=$artifact_name" >> "$GITHUB_OUTPUT"
- name: Create private Compute Engine VM
id: vm
env:
ARTIFACT_NAME: ${{ steps.artifact.outputs.name }}
run: |
vm_name="reqsign-metadata-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
startup_script="$RUNNER_TEMP/google-metadata-startup.sh"
cat > "$startup_script" <<SCRIPT
#!/usr/bin/env bash
set -euo pipefail
exec > >(tee /dev/ttyS0) 2>&1
token_response=\$(curl --connect-timeout 15 --fail --silent --show-error \
--header 'Metadata-Flavor: Google' \
'http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token?scopes=https://www.googleapis.com/auth/cloud-platform')
storage_token=\$(python3 -c 'import json,sys; print(json.loads(sys.argv[1])["access_token"])' "\$token_response")
curl --connect-timeout 15 --fail --silent --show-error \
--header "Authorization: Bearer \$storage_token" \
"https://storage.googleapis.com/storage/v1/b/reqsign/o/${ARTIFACT_NAME}?alt=media" \
--output /tmp/reqsign-google-metadata-live-test
chmod 700 /tmp/reqsign-google-metadata-live-test
REQSIGN_GOOGLE_TEST_VM_METADATA=on \
REQSIGN_GOOGLE_CLOUD_STORAGE_SCOPE='https://www.googleapis.com/auth/devstorage.read_only' \
REQSIGN_GOOGLE_CLOUD_STORAGE_PROBE_URL='https://storage.googleapis.com/storage/v1/b/reqsign/o/live%2Fcredential-ok?alt=media' \
/tmp/reqsign-google-metadata-live-test credential_providers::vm_metadata:: --nocapture
echo REQSIGN_GOOGLE_METADATA_TEST_SUCCEEDED
SCRIPT
for zone in us-east1-b us-east1-c us-east1-d; do
if gcloud compute instances create "$vm_name" --project="$GOOGLE_PROJECT_ID" --zone="$zone" --machine-type=e2-micro --subnet=default --no-address --image-family=ubuntu-2404-lts-amd64 --image-project=ubuntu-os-cloud --service-account="$GOOGLE_METADATA_SERVICE_ACCOUNT" --scopes=https://www.googleapis.com/auth/cloud-platform --metadata-from-file=startup-script="$startup_script" --max-run-duration=15m --instance-termination-action=DELETE --boot-disk-auto-delete --labels=project=reqsign,purpose=live-test,github-run-id="$GITHUB_RUN_ID" --quiet; then
echo "name=$vm_name" >> "$GITHUB_OUTPUT"
echo "zone=$zone" >> "$GITHUB_OUTPUT"
exit
fi
done
echo "No configured Compute Engine zone had capacity" >&2
exit 1
- name: Wait for VM metadata live test
env:
VM_NAME: ${{ steps.vm.outputs.name }}
VM_ZONE: ${{ steps.vm.outputs.zone }}
run: |
deadline=$((SECONDS + 900))
while (( SECONDS < deadline )); do
output=$(gcloud compute instances get-serial-port-output "$VM_NAME" --zone="$VM_ZONE" --port=1 --start=0 2>/dev/null || true)
if grep --quiet REQSIGN_GOOGLE_METADATA_TEST_SUCCEEDED <<< "$output"; then
exit
fi
if grep --quiet 'FAILED' <<< "$output"; then
printf '%s\n' "$output"
exit 1
fi
sleep 10
done
gcloud compute instances get-serial-port-output "$VM_NAME" --zone="$VM_ZONE" --port=1 --start=0 || true
echo "VM metadata live test did not finish before the timeout" >&2
exit 1
- name: Delete ephemeral Google resources
if: always()
env:
ARTIFACT_NAME: ${{ steps.artifact.outputs.name }}
VM_NAME: ${{ steps.vm.outputs.name }}
VM_ZONE: ${{ steps.vm.outputs.zone }}
run: |
if [[ -n "$VM_NAME" ]] && [[ -n "$VM_ZONE" ]] && gcloud compute instances describe "$VM_NAME" --zone="$VM_ZONE" >/dev/null 2>&1; then
gcloud compute instances delete "$VM_NAME" --zone="$VM_ZONE" --quiet
fi
if [[ -n "$ARTIFACT_NAME" ]]; then
gcloud storage rm "gs://reqsign/$ARTIFACT_NAME" --quiet
fi
summary:
name: Test Summary
needs:
- unit_test
- check_secrets
- prepare_live_resources
- test_static_provider
- test_file_provider
- test_env_provider
- test_well_known_provider
- test_default_provider
- test_service_account_token_provider
- test_authorized_user_provider
- test_workload_identity_provider
- test_token_provider
- test_service_account_impersonation_provider
- test_client_side_cab
- signing_test
- test_impersonated_adc_provider
- test_vm_metadata_provider
if: always() && !cancelled()
runs-on: ubuntu-latest
steps:
- name: Summarize Google credential coverage
env:
UNIT_RESULT: ${{ needs.unit_test.result }}
TRUSTED: ${{ needs.check_secrets.outputs.trusted }}
PREPARE_RESULT: ${{ needs.prepare_live_resources.result }}
STATIC_RESULT: ${{ needs.test_static_provider.result }}
FILE_RESULT: ${{ needs.test_file_provider.result }}
ENV_RESULT: ${{ needs.test_env_provider.result }}
WELL_KNOWN_RESULT: ${{ needs.test_well_known_provider.result }}
DEFAULT_RESULT: ${{ needs.test_default_provider.result }}
SERVICE_ACCOUNT_TOKEN_RESULT: ${{ needs.test_service_account_token_provider.result }}
AUTHORIZED_USER_RESULT: ${{ needs.test_authorized_user_provider.result }}
WORKLOAD_IDENTITY_RESULT: ${{ needs.test_workload_identity_provider.result }}
TOKEN_RESULT: ${{ needs.test_token_provider.result }}
SERVICE_ACCOUNT_IMPERSONATION_RESULT: ${{ needs.test_service_account_impersonation_provider.result }}
CLIENT_SIDE_CAB_RESULT: ${{ needs.test_client_side_cab.result }}
SIGNING_RESULT: ${{ needs.signing_test.result }}
IMPERSONATED_ADC_RESULT: ${{ needs.test_impersonated_adc_provider.result }}
VM_METADATA_RESULT: ${{ needs.test_vm_metadata_provider.result }}
run: |
{
echo "## Google Cloud Test Summary"
echo
echo "| Coverage | Real service acceptance | Result |"
echo "|----------|-------------------------|--------|"
echo "| Unit tests and redacted real-response replays | Local | $UNIT_RESULT |"
if [[ "$TRUSTED" == "true" ]]; then
echo "| Fixed Cloud Storage probes | Workload Identity and Cloud Storage | $PREPARE_RESULT |"
echo "| StaticCredentialProvider | OAuth and Cloud Storage | $STATIC_RESULT |"
echo "| FileCredentialProvider | OAuth and Cloud Storage | $FILE_RESULT |"
echo "| EnvCredentialProvider | OAuth and Cloud Storage | $ENV_RESULT |"
echo "| WellKnownCredentialProvider | OAuth and Cloud Storage | $WELL_KNOWN_RESULT |"
echo "| DefaultCredentialProvider | OAuth and Cloud Storage | $DEFAULT_RESULT |"
echo "| ServiceAccountTokenCredentialProvider and server-side CAB | OAuth, STS, and Cloud Storage | $SERVICE_ACCOUNT_TOKEN_RESULT |"
echo "| Authorized user provider | OAuth and Cloud Storage | $AUTHORIZED_USER_RESULT |"
echo "| Workload Identity provider | GitHub OIDC, STS, IAM Credentials, and Cloud Storage | $WORKLOAD_IDENTITY_RESULT |"
echo "| TokenCredentialProvider | Workload Identity and Cloud Storage | $TOKEN_RESULT |"
echo "| ServiceAccountImpersonationCredentialProvider and IAM signBlob | IAM Credentials and Cloud Storage | $SERVICE_ACCOUNT_IMPERSONATION_RESULT |"
echo "| Client-side Credential Access Boundary | STS and Cloud Storage | $CLIENT_SIDE_CAB_RESULT |"
echo "| Impersonated ADC provider | OAuth, IAM Credentials, and Cloud Storage | $IMPERSONATED_ADC_RESULT |"
echo "| VmMetadataCredentialProvider | Compute Engine metadata and Cloud Storage | $VM_METADATA_RESULT |"
echo "| Google request signing | OAuth, signed URLs, and Cloud Storage | $SIGNING_RESULT |"
else
echo "| Live service integration tests | Skipped because Connect secrets are unavailable | skipped |"
fi
} >> "$GITHUB_STEP_SUMMARY"
test "$UNIT_RESULT" = "success"
if [[ "$TRUSTED" == "true" ]]; then
test "$PREPARE_RESULT" = "success"
test "$STATIC_RESULT" = "success"
test "$FILE_RESULT" = "success"
test "$ENV_RESULT" = "success"
test "$WELL_KNOWN_RESULT" = "success"
test "$DEFAULT_RESULT" = "success"
test "$SERVICE_ACCOUNT_TOKEN_RESULT" = "success"
test "$AUTHORIZED_USER_RESULT" = "success"
test "$WORKLOAD_IDENTITY_RESULT" = "success"
test "$TOKEN_RESULT" = "success"
test "$SERVICE_ACCOUNT_IMPERSONATION_RESULT" = "success"
test "$CLIENT_SIDE_CAB_RESULT" = "success"
test "$IMPERSONATED_ADC_RESULT" = "success"
test "$VM_METADATA_RESULT" = "success"
test "$SIGNING_RESULT" = "success"
fi