Commit c498ccf
feat: service sccount to service account impersonation to support universe domain (#1528)
for context: b/340602527 Changes in this pr: - Override `getUniverseDomain()` to grab source credentials’s universe domain (UD) by default. Always use source credentials UD, not explicit provided UD. (In current design, impersonated credentials may not have universe domain in the outer layer. relay on UD from source credential. This may change in future) - Fix `isDefaultUniverseDomain()` in `GoogleCredentials` to account for `getUniverseDomain()` overrides in child classes. - In refreshAccessToken(), use endpoint url pattern to account for TPC case. - note that I choose to bypass this refreshIfExpired step because it wrongly steps into code path meant only for OAuth2 token request (GDU flow). Filed #1534 to address this separately. But for GDU flow here, this refresh step is redundant because the SSJ will get re-generated at [initialize request](https://github.com/googleapis/google-auth-library-java/blob/a987ecd06fd25a0048cdb3da6d1df4d029d85d79/oauth2_http/java/com/google/auth/oauth2/ImpersonatedCredentials.java#L558). Also skip this step for SA GDU with SSJ flow. - Throw IllegalStateException if UD is explicitly set (with parent class setter) and not matching source credential's UD - Fix toBuilder() to invoke super, and fix related issue with createScoped. (see #1489, #1428); Also fix equals() to compare super first. Not in this pr: - idtoken and signBlob endpoint changes are out-of-scope for this pr, will raise separate pr for it. sa-to-sa impersonation is successfully E2E tested for TPC usage according to [go/prptst-testing-service-account-impersonation](http://goto.google.com/prptst-testing-service-account-impersonation). --------- Co-authored-by: Blake Li <blakeli@google.com>1 parent f154edb commit c498ccf
File tree
6 files changed
+286
-52
lines changed- oauth2_http
- javatests/com/google/auth/oauth2
- java/com/google/auth/oauth2
6 files changed
+286
-52
lines changedLines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
266 | | - | |
| 266 | + | |
267 | 267 | | |
268 | 268 | | |
269 | | - | |
270 | | - | |
| 269 | + | |
| 270 | + | |
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
| |||
Lines changed: 71 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | 106 | | |
110 | 107 | | |
111 | 108 | | |
| |||
423 | 420 | | |
424 | 421 | | |
425 | 422 | | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
| 423 | + | |
434 | 424 | | |
435 | 425 | | |
436 | 426 | | |
| |||
457 | 447 | | |
458 | 448 | | |
459 | 449 | | |
460 | | - | |
| 450 | + | |
461 | 451 | | |
462 | 452 | | |
463 | 453 | | |
| |||
472 | 462 | | |
473 | 463 | | |
474 | 464 | | |
475 | | - | |
| 465 | + | |
476 | 466 | | |
477 | 467 | | |
478 | 468 | | |
479 | 469 | | |
480 | 470 | | |
481 | 471 | | |
482 | 472 | | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
483 | 495 | | |
484 | 496 | | |
485 | 497 | | |
| |||
489 | 501 | | |
490 | 502 | | |
491 | 503 | | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
496 | 516 | | |
497 | 517 | | |
498 | 518 | | |
| |||
504 | 524 | | |
505 | 525 | | |
506 | 526 | | |
507 | | - | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
508 | 532 | | |
509 | 533 | | |
510 | 534 | | |
| |||
603 | 627 | | |
604 | 628 | | |
605 | 629 | | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
606 | 633 | | |
607 | 634 | | |
608 | 635 | | |
| |||
616 | 643 | | |
617 | 644 | | |
618 | 645 | | |
619 | | - | |
| 646 | + | |
620 | 647 | | |
621 | 648 | | |
622 | 649 | | |
| |||
636 | 663 | | |
637 | 664 | | |
638 | 665 | | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
639 | 673 | | |
640 | 674 | | |
641 | 675 | | |
642 | 676 | | |
643 | 677 | | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
644 | 689 | | |
645 | 690 | | |
646 | 691 | | |
| |||
726 | 771 | | |
727 | 772 | | |
728 | 773 | | |
729 | | - | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
730 | 781 | | |
731 | 782 | | |
732 | 783 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
84 | 89 | | |
85 | 90 | | |
86 | 91 | | |
| |||
Lines changed: 16 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
992 | 992 | | |
993 | 993 | | |
994 | 994 | | |
995 | | - | |
996 | | - | |
997 | | - | |
998 | | - | |
999 | | - | |
1000 | | - | |
1001 | | - | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
1002 | 1008 | | |
1003 | 1009 | | |
1004 | 1010 | | |
| |||
1021 | 1027 | | |
1022 | 1028 | | |
1023 | 1029 | | |
1024 | | - | |
| 1030 | + | |
1025 | 1031 | | |
1026 | 1032 | | |
1027 | 1033 | | |
1028 | 1034 | | |
1029 | | - | |
| 1035 | + | |
1030 | 1036 | | |
1031 | 1037 | | |
1032 | 1038 | | |
1033 | 1039 | | |
1034 | 1040 | | |
1035 | 1041 | | |
1036 | 1042 | | |
1037 | | - | |
| 1043 | + | |
1038 | 1044 | | |
1039 | 1045 | | |
1040 | 1046 | | |
| |||
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
612 | 612 | | |
613 | 613 | | |
614 | 614 | | |
615 | | - | |
| 615 | + | |
616 | 616 | | |
617 | 617 | | |
618 | 618 | | |
619 | 619 | | |
620 | | - | |
| 620 | + | |
621 | 621 | | |
622 | 622 | | |
623 | 623 | | |
| |||
647 | 647 | | |
648 | 648 | | |
649 | 649 | | |
650 | | - | |
| 650 | + | |
651 | 651 | | |
652 | 652 | | |
653 | 653 | | |
| |||
677 | 677 | | |
678 | 678 | | |
679 | 679 | | |
680 | | - | |
| 680 | + | |
681 | 681 | | |
682 | 682 | | |
683 | 683 | | |
684 | 684 | | |
685 | | - | |
| 685 | + | |
686 | 686 | | |
687 | 687 | | |
688 | 688 | | |
| |||
0 commit comments