Skip to content

Commit 6a81e5d

Browse files
TheodorNEngoyTheodor N. EngøyTheodor N. Engøy
authored
examples: bind auth-middleware server to localhost by default (#784)
The auth-middleware example currently defaults to `-http :8080`, which binds to all interfaces (LAN-exposed) by default. This changes the default to `localhost:8080` and adds a short comment noting `-http 0.0.0.0:8080` if you intentionally want to expose it. Rationale: this example serves token-generation endpoints and authenticated MCP routes; binding loopback by default avoids accidental exposure while keeping the opt-in remote behavior. --------- Co-authored-by: Theodor N. Engøy <theodornengoy@Mac.home> Co-authored-by: Theodor N. Engøy <theodornengoy@eduroam-193-157-246-146.wlan.uio.no>
1 parent 86f8415 commit 6a81e5d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

examples/server/auth-middleware/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ import (
2626
// This example demonstrates how to integrate auth.RequireBearerToken middleware
2727
// with an MCP server to provide authenticated access to MCP tools and resources.
2828

29-
var httpAddr = flag.String("http", ":8080", "HTTP address to listen on")
29+
// Default to loopback to avoid exposing powerful demo endpoints to the local network.
30+
// Set -http 0.0.0.0:8080 to intentionally expose it.
31+
var httpAddr = flag.String("http", "localhost:8080", "HTTP address to listen on")
3032

3133
// JWTClaims represents the claims in our JWT tokens.
3234
// In a real application, you would include additional claims like issuer, audience, etc.

scripts/server-conformance.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ fi
7070
go build -o "$WORKDIR/conformance-server" ./conformance/everything-server
7171

7272
# Start the server in the background
73-
echo "Starting conformance server on port $PORT..."
74-
"$WORKDIR/conformance-server" -http=":$PORT" &
73+
echo "Starting conformance server on localhost:$PORT..."
74+
"$WORKDIR/conformance-server" -http="localhost:$PORT" &
7575
SERVER_PID=$!
7676

7777
echo "Server pid is $SERVER_PID"

0 commit comments

Comments
 (0)