Skip to content

auth: public routes by name, and a reduced health body for anonymous callers - #812

Open
bburda wants to merge 7 commits into
feat/rate-limit-orderfrom
feat/public-routes
Open

bburda wants to merge 7 commits into
feat/rate-limit-orderfrom
feat/public-routes

Conversation

@bburda

@bburda bburda commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

Pull Request

Summary

  • auth.public_routes lists routes a caller can reach without a token on a gateway that requires authentication. Each entry is METHOD /path and matches one route exactly. The list is empty by default.
  • An entry that does not parse stops the gateway at start and names its position. Empty entries are stripped, so [""] is an empty list, as for the other string arrays.
  • When GET /api/v1/health is listed, a caller without a valid token gets only status, timestamp, warning_schema_version, an empty warnings and x-medkit-reduced: true. A caller with a valid token gets the full body. This lets a liveness probe check a closed gateway.
  • The Bearer scheme name in Authorization is matched case-insensitively (RFC 7235).

Breaking changes: none for an existing configuration, because the default list is empty.


Issue


Type

  • Bug fix
  • New feature or tests
  • Breaking change
  • Documentation only

Testing

export MEDKIT_JWT_SECRET=$(head -c 32 /dev/urandom | base64)
export MEDKIT_CLIENTS="me:change-me-please:admin"
ros2 run ros2_medkit_gateway gateway_node --ros-args -p 'auth.public_routes:=["GET /api/v1/health"]'

In a second shell:

curl -s localhost:8080/api/v1/health                                    # 5 keys, "x-medkit-reduced": true
curl -s -o /dev/null -w '%{http_code}\n' localhost:8080/api/v1/areas    # 401

A malformed entry stops the start:

ros2 run ros2_medkit_gateway gateway_node --ros-args -p 'auth.public_routes:=["GET /api/v1/*"]'
# exits 1: auth.public_routes entry 1 ("GET /api/v1/*") is invalid: ...

Checklist

  • Breaking changes are clearly described (and announced in docs / changelog if needed)
  • Tests were added or updated if needed
  • Docs were updated if behavior or public API changed

@bburda
bburda added this pull request to stack #802 November 22, 2026 17:22

// Returned before any section is built, so a section added later stays out of the reduced body.
if (serves_reduced_body(ctx_, req)) {
response.x_medkit_reduced = true;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under require_auth_for: all, a peer that lists GET /api/v1/health now answers a missing or rejected aggregation.peer_auth_header with a reduced 200 instead of 401. PeerClient::check_health takes any 200 as healthy, so the peer shows online with no instance id while discovery and fan-out to it get 401. When the body has x-medkit-reduced: true, have check_health log that the credential was not accepted and mark the peer unhealthy if a protected read also returns 401, and add an aggregator test against a listed peer under both all and write.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants