Repository navigation
Commit d06feac
feat(oauth2): support non-mTLS token URLs and unbound actor tokens in IdentityPoolCredentials (#14430)
## Summary
Allows `actor_token` and `actor_token_type` to be used in
`IdentityPoolCredentials` with standard (non-mTLS) STS and IAM
impersonation endpoints and without requiring client certificate
(`certificate_config`) configuration.
## Context & Rationale
In #13955, client-side guardrails (`isMtlsConfigured()` and
`validateMtlsEndpoint()`) were enforced in the `IdentityPoolCredentials`
constructor because Google STS initially required actor tokens to be
paired with certificate-bound tokens over mTLS. Per the original design
discussion, this was intentionally designed as a one-way door that could
be loosened in a non-breaking manner once backend support for non-mTLS
actor token exchanges was ready.
## Changes
1. **Removed Constructor mTLS Restrictions:**
- Removed `isMtlsConfigured()` check in
`IdentityPoolCredentials(Builder)` so actor tokens can be configured
with standard `HttpTransportFactory` instances and without a
`certificate` block.
- Removed `validateMtlsEndpoint()` checks on `tokenUrl` and
`serviceAccountImpersonationUrl`, allowing standard public endpoints
(e.g., `https://sts.googleapis.com/v1/token`) to be used with actor
tokens.
- Preserved strict pairing validation between `actorTokenSupplier` and
`actorTokenType`, as well as JSON format checks for file-based actor
token extraction.
2. **401 Handling & Cert Rotation:**
- When `x509Provider == null` (non-mTLS credentials),
`refreshAccessToken()` uses standard transport without snapshotting a
`KeyStore`, and `401 Unauthorized` errors propagate immediately without
retry.
- When `x509Provider != null && transportFactory instanceof
MtlsHttpTransportFactory` (mTLS credentials), per-cycle certificate
pinning and single-retry cert reload on `401` remain unchanged.
3. **Javadoc & Test Coverage:**
- Updated class-level and builder Javadocs on `IdentityPoolCredentials`.
- Updated negative constructor tests to positive verification tests
(`*_succeeds`).
- Added
`refreshAccessToken_401WithActorTokenAndNonMtlsTransport_bubblesUpWithoutRetry`
and
`fromStream_fileCredentialSource_withoutCertificateConfig_andActorToken_withNonMtlsUrl_refreshesSuccessfully`
to verify end-to-end non-mTLS actor token exchanges.
## Verification
- All **1,035** unit tests passing in `oauth2_http` module (including
all **88** tests in `IdentityPoolCredentialsTest`).
- 100% compliant with `fmt-maven-plugin:2.25:check`.
---------
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>1 parent ed2bd40 commit d06feac
4 files changed
Lines changed: 547 additions & 206 deletions
File tree
- google-auth-library-java/oauth2_http
- javatests/com/google/auth/oauth2
- java/com/google/auth/oauth2
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
176 | 181 | | |
177 | 182 | | |
178 | 183 | | |
| |||
195 | 200 | | |
196 | 201 | | |
197 | 202 | | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
| 203 | + | |
211 | 204 | | |
212 | 205 | | |
213 | 206 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | 45 | | |
47 | 46 | | |
48 | 47 | | |
49 | 48 | | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
59 | | - | |
60 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
| 107 | + | |
111 | 108 | | |
112 | 109 | | |
113 | 110 | | |
| |||
171 | 168 | | |
172 | 169 | | |
173 | 170 | | |
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 | 171 | | |
212 | 172 | | |
213 | 173 | | |
| |||
242 | 202 | | |
243 | 203 | | |
244 | 204 | | |
245 | | - | |
246 | 205 | | |
247 | 206 | | |
248 | 207 | | |
| |||
266 | 225 | | |
267 | 226 | | |
268 | 227 | | |
269 | | - | |
| 228 | + | |
270 | 229 | | |
271 | 230 | | |
272 | 231 | | |
| |||
463 | 422 | | |
464 | 423 | | |
465 | 424 | | |
466 | | - | |
467 | | - | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
468 | 431 | | |
469 | 432 | | |
470 | 433 | | |
| |||
640 | 603 | | |
641 | 604 | | |
642 | 605 | | |
643 | | - | |
| 606 | + | |
644 | 607 | | |
645 | 608 | | |
646 | 609 | | |
| |||
653 | 616 | | |
654 | 617 | | |
655 | 618 | | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | | - | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
660 | 624 | | |
661 | 625 | | |
662 | 626 | | |
| |||
696 | 660 | | |
697 | 661 | | |
698 | 662 | | |
699 | | - | |
700 | | - | |
701 | | - | |
| 663 | + | |
| 664 | + | |
702 | 665 | | |
703 | | - | |
704 | | - | |
| 666 | + | |
| 667 | + | |
705 | 668 | | |
706 | 669 | | |
707 | 670 | | |
| |||
768 | 731 | | |
769 | 732 | | |
770 | 733 | | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
771 | 740 | | |
772 | 741 | | |
773 | 742 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
380 | 380 | | |
381 | 381 | | |
382 | 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 | + | |
383 | 413 | | |
384 | 414 | | |
385 | 415 | | |
| |||
449 | 479 | | |
450 | 480 | | |
451 | 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 | + | |
452 | 532 | | |
453 | 533 | | |
454 | 534 | | |
| |||
0 commit comments