Commit 1e0ae83
authored
config: apply DialContextFunc to OAuth2 token-fetch transport (#911)
newOauth2TokenSource builds its own http.Transport to fetch tokens but
doesn't set DialContext on it. Any DialContextFunc passed via
WithDialContextFunc is applied to the main request transport but silently
skipped for the token endpoint.
Set DialContext on the token transport the same way it is set on the main
one. When dialContextFunc is nil the behaviour is unchanged since
http.Transport falls back to its default dialer.
Added TestOAuth2DialContextFunc to verify that WithDialContextFunc blocks
the token endpoint fetch, not only the final request.
Signed-off-by: Yuri Tseretyan <yuriy.tseretyan@grafana.com>1 parent b51d01b commit 1e0ae83
2 files changed
Lines changed: 35 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
987 | 987 | | |
988 | 988 | | |
989 | 989 | | |
| 990 | + | |
990 | 991 | | |
991 | 992 | | |
992 | 993 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1599 | 1599 | | |
1600 | 1600 | | |
1601 | 1601 | | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
| 1635 | + | |
1602 | 1636 | | |
1603 | 1637 | | |
1604 | 1638 | | |
| |||
0 commit comments