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>
This commit is contained in:
parent
86f8415122
commit
6a81e5da2a
2 changed files with 5 additions and 3 deletions
|
|
@ -26,7 +26,9 @@ import (
|
||||||
// This example demonstrates how to integrate auth.RequireBearerToken middleware
|
// This example demonstrates how to integrate auth.RequireBearerToken middleware
|
||||||
// with an MCP server to provide authenticated access to MCP tools and resources.
|
// with an MCP server to provide authenticated access to MCP tools and resources.
|
||||||
|
|
||||||
var httpAddr = flag.String("http", ":8080", "HTTP address to listen on")
|
// Default to loopback to avoid exposing powerful demo endpoints to the local network.
|
||||||
|
// Set -http 0.0.0.0:8080 to intentionally expose it.
|
||||||
|
var httpAddr = flag.String("http", "localhost:8080", "HTTP address to listen on")
|
||||||
|
|
||||||
// JWTClaims represents the claims in our JWT tokens.
|
// JWTClaims represents the claims in our JWT tokens.
|
||||||
// In a real application, you would include additional claims like issuer, audience, etc.
|
// In a real application, you would include additional claims like issuer, audience, etc.
|
||||||
|
|
|
||||||
|
|
@ -70,8 +70,8 @@ fi
|
||||||
go build -o "$WORKDIR/conformance-server" ./conformance/everything-server
|
go build -o "$WORKDIR/conformance-server" ./conformance/everything-server
|
||||||
|
|
||||||
# Start the server in the background
|
# Start the server in the background
|
||||||
echo "Starting conformance server on port $PORT..."
|
echo "Starting conformance server on localhost:$PORT..."
|
||||||
"$WORKDIR/conformance-server" -http=":$PORT" &
|
"$WORKDIR/conformance-server" -http="localhost:$PORT" &
|
||||||
SERVER_PID=$!
|
SERVER_PID=$!
|
||||||
|
|
||||||
echo "Server pid is $SERVER_PID"
|
echo "Server pid is $SERVER_PID"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue