Apply the agent-token machinery only to listed agent listener methods

The agent listener treats every method as an agent RPC: the bearer becomes an agent token, the agent type defaults to Kubernetes when the gitlab-agent-type header is absent, and the per-token connection limiter charges a Redis bucket keyed on it. A service that authenticates its own callers has no way to opt out. That is how Rails's token-exchange JWT rides through !4627 (merged) as a "Kubernetes agent token" that nothing reads, and why every Rails call buys a limiter bucket (ash2k's note).

newAgentServer now takes the methods that carry an agent token, by full method name. Those get the agent RPC API interceptor and the connection limiter, which panics without the agent RPC API. Every other method gets a plain modserver.RPCAPI from the API server's factory. Health checks are ordinary members of that second group, no longer a special case in the chain. The in-memory server shares the chain and the registrations.

The set is built in code where the agent server is constructed. A proto method option was tried first and does not work here: pkg/tunnel and pkg/autoflow are separate Go modules that cannot import anything under internal/, and an option's Go package would be linked into agentk through every annotated rpc package. An audience abstraction on the registrar was set aside as premature. Discussion in the thread below.

An integration test sweeping every route on the agent listener is tracked in #1225. !4627 (merged) serves AutoFlow's token-exchange methods on this listener, the first without an agent token.

Related to #1220 (closed)

Edited by Romuald Atchadé

Merge request reports

Loading
Loading