go-sdk/oauthex
Repository files (latest commit first)
Filename Latest commit message Latest commit date
sravan kilaru 3b917b466c
oauthex: build defaultDiscoveryTransport lazily instead of at import (#1278)
Fixes #1276

## What's happening

`oauthex` builds `defaultDiscoveryTransport` as a package-level var, so
it
runs at import time. That path calls `proxyConfigured`, which invokes
`http.DefaultTransport`'s proxy func (`http.ProxyFromEnvironment`).
net/http
reads the proxy env vars only once and caches the result, so this
import-time
call freezes the proxy config before `main()` can set `HTTPS_PROXY`.

New in v1.8.0, which is why it's a regression — just importing `.../mcp`
(which pulls in `oauthex`) triggers it, even with no use of the SDK.

## Fix

Wrap the setup in `sync.OnceValue` so it runs on first use instead of at
import. Still built once and reused.

## Testing (removed)

- Ran the issue's repro against this branch via a local `replace`:
prints
  `proxy=http://127.0.0.1:9` now, `proxy=<nil>` before.
- Added a regression test in `oauthex`.
- `go test ./...` passes.

Co-authored-by: Guglielmo Colombo <guglielmoc@google.com>
2026-09-18 09:41:05 +02:00
..
testdata oauthex: move internal/oauthex to oauthex (#559) 2025-10-07 08:39:49 -04:00
audience.go oauthex: add MatchesResource helper (RFC 9728/8707 audience comparison) (#970) 2026-06-16 15:20:09 +02:00
audience_test.go oauthex: add MatchesResource helper (RFC 9728/8707 audience comparison) (#970) 2026-06-16 15:20:09 +02:00
auth_meta.go mcp: add optional issuer validator for pre-registered client validation (SEP-2352) (#946) 2026-05-29 12:46:34 +00:00
auth_meta_test.go Compare auth server metadata issuer ignoring trailing slash (#955) 2026-05-14 07:26:57 +00:00
client.go mcp: add optional issuer validator for pre-registered client validation (SEP-2352) (#946) 2026-05-29 12:46:34 +00:00
client_test.go mcp: add optional issuer validator for pre-registered client validation (SEP-2352) (#946) 2026-05-29 12:46:34 +00:00
dcr.go oauthex: bound dcr read to 1mb (#1206) 2026-08-28 09:43:05 +02:00
dcr_test.go oauthex: accept 200 in client registration (#877) 2026-04-01 16:51:18 +02:00
discovery_test.go oauthex: oauth discovery checks (#1220) 2026-09-02 21:07:19 +02:00
oauth2.go oauthex: build defaultDiscoveryTransport lazily instead of at import (#1278) 2026-09-18 09:41:05 +02:00
oauthex.go all: client side OAuth support (#785) 2026-02-27 15:30:13 +01:00
oauthex_test.go all: stabilize client OAuth support (#861) 2026-03-31 12:36:31 +02:00
resource_meta.go all: stabilize client OAuth support (#861) 2026-03-31 12:36:31 +02:00
resource_meta_test.go all: stabilize client OAuth support (#861) 2026-03-31 12:36:31 +02:00
token_exchange.go all: stabilize client OAuth support (#861) 2026-03-31 12:36:31 +02:00
token_exchange_test.go all: stabilize client OAuth support (#861) 2026-03-31 12:36:31 +02:00
url_scheme_test.go all: stabilize client OAuth support (#861) 2026-03-31 12:36:31 +02:00