Files
seaweedfs/weed/security
Chris LuandClaude Opus 5.5 4a58968439 Cut per-request CPU on filer gRPC tokens and S3 header scrubbing (#13414)
* security: reuse the filer admin token signed in the same second

An admin token's only claim is its expiry, which jwt truncates to the
second, so every token signed with one key in one second is the same.
Each filer gRPC call from a client with a filer signing key signed a new
one: about 4us and 40 allocations per call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* security: add a filer token without copying the outgoing metadata

WithFilerToken copied the outgoing metadata twice on every filer gRPC
call to check for an authorization the caller set and to add its own.
Look the key up in place and append the token instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: canonicalize the scrubbed internal header names once

scrubInternalHeaders runs on every request, and Header.Del
canonicalized each of its nine names again; five are not in canonical
form, so each request allocated their canonical forms anew. Delete the
precomputed canonical keys instead: 775ns and 5 allocations down to
120ns and none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* security: benchmark the token path with a fixed key, test the reuse itself

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* security: keep GenJwtForFilerAdmin's doc comment on the function

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-04 23:50:18 -08:00
..