Commit a890d17
authored
Fail-fast OIDC env var validation at config load time (#3367)
When an HTTP server uses `auth.type: "github-oidc"`, missing
`ACTIONS_ID_TOKEN_REQUEST_URL` was only surfaced on first request. The
gateway would start, report healthy, then fail when a client actually
hit the OIDC server.
### Changes
- **`internal/config/validation.go`** — Check
`ACTIONS_ID_TOKEN_REQUEST_URL` in `validateAuthConfig()` after
confirming `auth.type == "github-oidc"`, returning a fail-fast
validation error at config load time
- **`internal/launcher/launcher.go`** — Pre-populate `serverErrors`
during `New()` for OIDC-misconfigured servers so `/health` immediately
reflects error state (defensive fallback for configs that bypass
validation, e.g. tests)
- **Tests** — Added cases for missing env var validation and early error
recording; set env var in existing tests that construct valid OIDC
configs
```go
// validateAuthConfig now fails fast for missing OIDC env vars
if auth.Type == "github-oidc" {
if os.Getenv("ACTIONS_ID_TOKEN_REQUEST_URL") == "" {
return rules.MissingRequired(
"ACTIONS_ID_TOKEN_REQUEST_URL", "environment", authPath,
"Server requires OIDC authentication but ACTIONS_ID_TOKEN_REQUEST_URL is not set. "+
"OIDC auth requires running in GitHub Actions with `permissions: { id-token: write }`")
}
}
```
> [!WARNING]
>
> <details>
> <summary>Firewall rules blocked me from connecting to one or more
addresses (expand for details)</summary>
>
> #### I tried to connect to the following addresses, but was blocked by
firewall rules:
>
> - `example.com`
> - Triggering command: `/tmp/go-build1150468762/b514/launcher.test
/tmp/go-build1150468762/b514/launcher.test
-test.testlogfile=/tmp/go-build1150468762/b514/testlog.txt
-test.paniconexit0 -test.timeout=10m0s insp�� uf@v1.36.11/type-errorsas
om/tetratelabs/w-ifaceassert x_amd64/vet g_.a ce
64/pkg/tool/linu--format x_amd64/vet /usr�� g_.a
64/pkg/tool/linux_amd64/vet x_amd64/vet -I /known/anypb
64/pkg/tool/linux_amd64/vet x_amd64/vet` (dns block)
> - `invalid-host-that-does-not-exist-12345.com`
> - Triggering command: `/tmp/go-build3631266208/b001/config.test
/tmp/go-build3631266208/b001/config.test
-test.testlogfile=/tmp/go-build3631266208/b001/testlog.txt
-test.paniconexit0 -test.timeout=10m0s -test.v=true
ache/go/1.25.8/x64/src/runtime/c--gdwarf-5 YVt4/qIWeKIr-djJe-CXpYVt4
x_amd64/compile -I /tmp/go-build102-unsafeptr=false -I x_amd64/compile
7443�� ache/go/1.25.8/x64/src/runtime/c/tmp/go-build1027443045/b148/
ache/go/1.25.8/x64/src/crypto/in-imultiarch .13/x64/bin/as --gdwarf-5
--64 -o 9964951/b135/_x012.o` (dns block)
> - Triggering command: `/tmp/go-build2092181885/b001/config.test
/tmp/go-build2092181885/b001/config.test
-test.testlogfile=/tmp/go-build2092181885/b001/testlog.txt
-test.paniconexit0 -test.timeout=10m0s -test.v=true 64/src/net -trimpath
x_amd64/vet -I /tmp/go-build102-qE /x64=/_/GOROOT x_amd64/vet ut-2��
7443045/b147/_pkg_.a -I x_amd64/vet ctor --64 E=3 x_amd64/vet` (dns
block)
> - Triggering command: `/tmp/go-build1129750467/b001/config.test
/tmp/go-build1129750467/b001/config.test
-test.testlogfile=/tmp/go-build1129750467/b001/testlog.txt
-test.paniconexit0 -test.timeout=10m0s -test.v=true g_.a
Wn3v/y-pYGV7LMnpJY6ujWn3v 64/pkg/tool/linux_amd64/vet . on --64
64/pkg/tool/linux_amd64/vet 9964�� 5vRKptRn1 .cfg
64/pkg/tool/linux_amd64/compile . 9964951/b187/ --64
64/pkg/tool/linux_amd64/compile` (dns block)
> - `nonexistent.local`
> - Triggering command: `/tmp/go-build1150468762/b514/launcher.test
/tmp/go-build1150468762/b514/launcher.test
-test.testlogfile=/tmp/go-build1150468762/b514/testlog.txt
-test.paniconexit0 -test.timeout=10m0s insp�� uf@v1.36.11/type-errorsas
om/tetratelabs/w-ifaceassert x_amd64/vet g_.a ce
64/pkg/tool/linu--format x_amd64/vet /usr�� g_.a
64/pkg/tool/linux_amd64/vet x_amd64/vet -I /known/anypb
64/pkg/tool/linux_amd64/vet x_amd64/vet` (dns block)
> - `slow.example.com`
> - Triggering command: `/tmp/go-build1150468762/b514/launcher.test
/tmp/go-build1150468762/b514/launcher.test
-test.testlogfile=/tmp/go-build1150468762/b514/testlog.txt
-test.paniconexit0 -test.timeout=10m0s insp�� uf@v1.36.11/type-errorsas
om/tetratelabs/w-ifaceassert x_amd64/vet g_.a ce
64/pkg/tool/linu--format x_amd64/vet /usr�� g_.a
64/pkg/tool/linux_amd64/vet x_amd64/vet -I /known/anypb
64/pkg/tool/linux_amd64/vet x_amd64/vet` (dns block)
> - `this-host-does-not-exist-12345.com`
> - Triggering command: `/tmp/go-build1150468762/b523/mcp.test
/tmp/go-build1150468762/b523/mcp.test
-test.testlogfile=/tmp/go-build1150468762/b523/testlog.txt
-test.paniconexit0 -test.timeout=10m0s -goversion go1.25.8 -c=4
-nolocalimports -importcfg /tmp/go-build1150468762/b517/importcfg -pack
/tmp/go-build1150468762/b517/_testmain.go /usr�� fg
olang.org/protobuf@v1.36.11/inte-ifaceassert x_amd64/vet
ache/go/1.25.8/x/usr/libexec/docker/docker-init .cfg de/node/bin/bash
x_amd64/vet` (dns block)
>
> If you need me to access, download, or install something from one of
these locations, you can either:
>
> - Configure [Actions setup
steps](https://gh.io/copilot/actions-setup-steps) to set up my
environment, which run before the firewall is enabled
> - Add the appropriate URLs or hosts to the custom allowlist in this
repository's [Copilot coding agent
settings](https://github.com/github/gh-aw-mcpg/settings/copilot/coding_agent)
(admins only)
>
> </details>File tree
5 files changed
+70
-3
lines changed- internal
- config
- launcher
5 files changed
+70
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1027 | 1027 | | |
1028 | 1028 | | |
1029 | 1029 | | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
1030 | 1033 | | |
1031 | 1034 | | |
1032 | 1035 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
258 | 258 | | |
259 | 259 | | |
260 | 260 | | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
261 | 272 | | |
262 | 273 | | |
263 | 274 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
956 | 956 | | |
957 | 957 | | |
958 | 958 | | |
| 959 | + | |
959 | 960 | | |
960 | 961 | | |
961 | 962 | | |
| |||
1016 | 1017 | | |
1017 | 1018 | | |
1018 | 1019 | | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
1019 | 1034 | | |
1020 | 1035 | | |
1021 | 1036 | | |
1022 | 1037 | | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
1023 | 1044 | | |
1024 | 1045 | | |
1025 | 1046 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
76 | 80 | | |
77 | 81 | | |
78 | | - | |
| 82 | + | |
79 | 83 | | |
80 | 84 | | |
81 | 85 | | |
| 86 | + | |
| 87 | + | |
82 | 88 | | |
83 | 89 | | |
84 | 90 | | |
| |||
91 | 97 | | |
92 | 98 | | |
93 | 99 | | |
94 | | - | |
| 100 | + | |
95 | 101 | | |
96 | 102 | | |
97 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
776 | 776 | | |
777 | 777 | | |
778 | 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 | + | |
779 | 805 | | |
780 | 806 | | |
781 | 807 | | |
| |||
0 commit comments